From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christophe Rhodes Subject: Re: org-export-current-backend variable and org-mode 8 Date: Wed, 31 Jul 2013 20:09:02 +0100 Message-ID: <87y58mtult.fsf@cantab.net> References: <874nbavgmw.fsf@cantab.net> 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]:55132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4bm2-0001zM-5y for emacs-orgmode@gnu.org; Wed, 31 Jul 2013 15:09:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4blw-0007ow-1t for emacs-orgmode@gnu.org; Wed, 31 Jul 2013 15:09:26 -0400 Received: from plane.gmane.org ([80.91.229.3]:39663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4blv-0007oU-QN for emacs-orgmode@gnu.org; Wed, 31 Jul 2013 15:09:19 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V4blt-0002OL-Ng for emacs-orgmode@gnu.org; Wed, 31 Jul 2013 21:09:17 +0200 Received: from 81.174.155.115 ([81.174.155.115]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Jul 2013 21:09:17 +0200 Received: from csr21 by 81.174.155.115 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Jul 2013 21:09:17 +0200 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 Brett Viren writes: > Christophe Rhodes writes: > >> In org-mode 7, I was able to use the (documented) variable >> org-export-current-backend to test what the current backend is, allowing >> me to dynamically produce and include images of different formats >> depending on whether I was exporting to latex (tikz) or html (png). >> >> In org-mode 8, I cannot find this variable, or any documented variable >> of a similar nature. What is the recommended way for dispatching at the >> emacs-lisp level when exporting a document on the export backend? > > I don't know if this is exactly what you are asking for but I hit on the > following a few weeks ago. It defines an elisp macro inside the org > file and then calls it later in the header of a code block to switch the > output file names based on which backend (if any) is in effect. I hope > it helps. Thanks. Well, it proves at least that I'm not going mad :-( > If you have a better way to do these kind of output switches, I'd like > to know. > #+begin_src emacs-lisp :results silent > (defmacro by-backend (&rest body) > `(case (if (boundp 'backend) backend nil) ,@body)) > #+end_src It's funny -- I felt queasy using the bare backend variable in the olden 6.x days, and was very happy when org-export-current-backend showed up. Now, there's a real reason to be worried about using backend: it's fairly clearly used as an internal variable, and all it would take would be for lexical binding to be turned on for ox.el and this would (probably) stop working. If we're grubbing around in internals, I might be tempted instead by something like [untested] #+begin_src emacs-lisp :exports results :results silent (unless (boundp 'org-export-current-backend) (defadvice org-export-as (around oecb-around) (let ((org-export-current-backend (ad-get-arg 0))) ad-do-it))) #+end_src so that if (as I hope) org-export-current-backend makes a later reappearance, my documents can work with both org-mode 7 and 8, and maybe 9? I'm hoping that the disappearance of the variable is an oversight rather than intentional :-/ Cheers, Christophe --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlH5YM8ACgkQhMXieFLWjfLqVACdH4ySkc59VYR3J90FrxiK01Ps uewAniFF76eAQUqq11AhGuMO27wUnI+G =KHJo -----END PGP SIGNATURE----- --=-=-=--