From: Tim Cross <theophilusx@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: looking for a macro eval workaround (9.1 vs 9.2 and +) for export backend test
Date: Sun, 22 Nov 2020 00:18:07 +1100 [thread overview]
Message-ID: <87pn46hmr4.fsf@gmail.com> (raw)
In-Reply-To: <20201121105633.kgwzxc2l6oo5yeau@localhost.localdomain>
Bruno BEAUFILS <bruno@boulgour.com> writes:
> I have a *lot* of org files with a macro =if-backend= which enables me
> to decide what to export depending on the backend :
>
> #+begin_src org
> #+macro: if-backend (eval (if (org-export-derived-backend-p org-export-current-backend '$1) "$2"))
> #+end_src
>
> For instance, I use it to include =\hfill= in LaTeX family export
> engines but not in others (html for instance) :
>
> #+begin_src org
> #+macro: hfill {{{if-backend(latex, \\hfill{} )}}}
> #+end_src
>
> I generally use emacs 26.3 as distributed by Debian bullseyes (which
> offer org-mode version 9.1.9).
>
> On another box I need to work with a more recent org-mode, precisely
> 9.4.
>
> In that environment, due to an incompatible change introduced by
> [[https://orgmode.org/Changes_old.html#outline-container-org003add6][release 9.2]] the same macro has to be written in a different way :
>
> #+begin_src org
> #+macro: if-backend (eval (if (org-export-derived-backend-p org-export-current-backend (intern $1)) $2))
> #+end_src
>
> And thus I need to change also the macro using it, for instance the
> =hfill= macro has to be written that way :
>
> #+begin_src org
> #+macro: hfill {{{if-backend(latex, \hfill{} )}}}
> #+end_src
>
> For now I need to work on the same files in these two different environment.
>
> Do anyone have an idea on how to be able whether to define the
> =if-backend= in a way that it can work in both org versions or if
> there is a way to define these macro in different ways depending on
> org version?
>
> I would like to let the definitions in org files and not in emacs init
> files.
Hmm, I just use backend specific blocks for this purpose. e.g.
#+begin_export latex
\hfil{}
#+end_export
Pretty sure 9.1 supports the same (there was a change, which used
#+EXPORT_LATEX instead of #+begin_export, but I think the old version
still works in 9.4, can't remember which version the change was
introduced). So if 9.1 only supports EXPORT_LATEX, you should still be
able to use it under 9.4
IMO the org #+MACRO is really just a text substitution mechanism (like
C), not a 'real' macro (like elisp has) and as is the case with C, you
really need to keep them pretty simple. Once you start using them to
evaluate code, it isn't hard to find yourself in a mine field.
--
Tim Cross
next prev parent reply other threads:[~2020-11-21 13:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-21 10:56 looking for a macro eval workaround (9.1 vs 9.2 and +) for export backend test Bruno BEAUFILS
2020-11-21 13:18 ` Tim Cross [this message]
2020-11-22 20:49 ` Bruno BEAUFILS
2020-11-23 10:19 ` Eric S Fraga
2020-11-23 13:02 ` Bruno BEAUFILS
2020-11-23 13:12 ` Eric S Fraga
2020-11-29 17:30 ` Bruno BEAUFILS
2020-11-29 17:45 ` Eric S Fraga
2020-11-29 20:55 ` Tom Gillespie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pn46hmr4.fsf@gmail.com \
--to=theophilusx@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.