From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brett Viren Subject: Switch for exported file types when evaluating code blocks Date: Wed, 17 Jul 2013 18:08:17 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzZxi-00057x-FS for emacs-orgmode@gnu.org; Wed, 17 Jul 2013 18:12:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzZxf-0007ls-L2 for emacs-orgmode@gnu.org; Wed, 17 Jul 2013 18:12:42 -0400 Received: from smtpgw.bnl.gov ([2620:10a:0:3::30]:57208 helo=iron3.sec.bnl.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzZtn-0006JJ-MO for emacs-orgmode@gnu.org; Wed, 17 Jul 2013 18:08:39 -0400 Received: from bviren by lycastus.phy.bnl.gov with local (Exim 4.80) (envelope-from ) id 1UzZtR-0008BD-Ll for emacs-orgmode@gnu.org; Wed, 17 Jul 2013 18:08:17 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, I'm hitting on an old theme in a new way here.=20=20 I want graphics files which are exported by evaluated code blocks to be generated in a format best suited to their intended use. For HTML I want either PNG or SVG. For LaTeX/PDF I almost always want PDF. For inline viewing in emacs I want either PNG or SVG. To that end I went a'googling and found this idea: http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec= -4-3 It doesn't work with my copies[1] of emacs and org-mode but I was able to adapt it. I suck at elisp so this is probably more an accomplishment to me than it appears to most of you! In any case, here is a short org document based on the one I found above in worg which shows what I ended up with: * COMMENT setup #+begin_src emacs-lisp :results silent (defmacro by-backend (&rest body) `(case (if (boundp 'backend) backend nil) ,@body)) #+end_src * A graph #+header: :file (by-backend (html "graph.png") (latex "graph.pdf") (t "grap= h.svg")) #+header: :export results #+begin_src dot digraph Name { tail -> head; } #+end_src I think the real learning experience for me was that I could put lisp directly in a header like this! Now, I just gotta learn elisp better.... Also, I'd certainly be interested to hear of any better ways to accomplish this. Thanks, =2DBrett. [1] The versions I'm using are - Org-mode version 8.0.3 (8.0.3-elpa @ /home/bviren/.emacs.d/elpa/org-2013= 0514/) - GNU Emacs 24.1.1 (i486-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-07-20= on murphy, modified by Debian --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlHnFdEACgkQEixH2Z0dKCwNFwCfax3eDgpBNmRjsEkp6W5psW8o ni0An0lxcG5E76DdQUV4ATq/UYmeBWtv =bJlb -----END PGP SIGNATURE----- --=-=-=--