From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: org-exp-block patch and Graphviz Demo Date: Wed, 10 Jun 2009 10:12:24 -0700 Message-ID: References: <20090527190924.GS10324@thinkpad.adamsinfoserv.com> <87prdthzpw.fsf@selenimh.orion.org> <20090528224724.GC10324@thinkpad.adamsinfoserv.com> <20090609155018.GX11193@thinkpad.adamsinfoserv.com> <20090610152940.GA11193@thinkpad.adamsinfoserv.com> <20090610162240.GB11193@thinkpad.adamsinfoserv.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MERLm-00070e-KX for emacs-orgmode@gnu.org; Wed, 10 Jun 2009 13:12:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MERLi-0006zz-7y for emacs-orgmode@gnu.org; Wed, 10 Jun 2009 13:12:34 -0400 Received: from [199.232.76.173] (port=34828 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MERLi-0006zw-2a for emacs-orgmode@gnu.org; Wed, 10 Jun 2009 13:12:30 -0400 Received: from mail-px0-f202.google.com ([209.85.216.202]:36723) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MERLh-0006aT-FY for emacs-orgmode@gnu.org; Wed, 10 Jun 2009 13:12:29 -0400 Received: by pxi40 with SMTP id 40so897411pxi.14 for ; Wed, 10 Jun 2009 10:12:28 -0700 (PDT) In-Reply-To: <20090610162240.GB11193@thinkpad.adamsinfoserv.com> (Russell Adams's message of "Wed, 10 Jun 2009 11:22:40 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Russell Adams writes: > On Wed, Jun 10, 2009 at 09:06:09AM -0700, Eric Schulte wrote: >> Really it would probably be much easier to do this with a new block >> type... what do the commands look like when you do this by hand? >> >> Cheers -- Eric > > dot -Teps -o file.eps file.dot > epstopdf file.eps > > Quick and simple. > I just posted a patch to org-exp-blocks.el that fixes a small typo/bug. After that patch is applied, the code below[1] can be used to add a new block type which will automatically process blocks with dot then eps. For example the following block specification will create out-w-eps.eps and org-w-eps.pdf files on export. #+begin_dot-and-eps out-w-eps digraph test { a -> { b c d e }; e -> { f g h i }; }; #+end_dot-and-eps Cheers -- Eric [1] (defun org-export-blocks-format-dot-and-eps (body &rest headers) "Pass block BODY to the dot graphing utility creating an eps file which is then processed by eps to create a pdf. Specify the path at which the final pdf image should be created as the first element of headers, any additional elements of headers will be passed to the dot utility as command line arguments. #+begin_dot_and_eps duh digraph test { a -> { b c d e }; e -> { f g h i }; }; #+end_dot" (message "dot-and-eps-formatting...") (let ((out-file (if headers (car headers))) (args (if (cdr headers) (mapconcat 'identity (cdr headers) " "))) (data-file (make-temp-file "org-dot"))) (cond ((or htmlp latexp docbookp) (with-temp-file data-file (insert body)) (shell-command (message (concat "dot -Teps " data-file " " args " -o " out-file ".eps"))) (shell-command (message (concat "epstopdf " out-file ".eps"))) (format "\n[[file:%s.pdf]]\n" out-file)) (t (concat "\n#+BEGIN_EXAMPLE\n" body (if (string-match "\n$" body) "" "\n") "#+END_EXAMPLE\n"))))) (org-export-blocks-add-block '(dot-and-eps org-export-blocks-format-dot-and-eps nil))