emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] is there a macro to have backend-specific behavior?


From: Adonay Felipe Nogueira
Subject: Re: [O] is there a macro to have backend-specific behavior?
Date: Sat, 03 Mar 2018 14:33:31 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

> Is there a way to define a macro that has different behaviors depending
> on export backend? I have macros that use the @@latex:foo@@ syntax, but
> in that case I "foo" is supposed to be literal latex.

Perhaps this might do something similar  to what you expect:

--8<---------------cut here---------------start------------->8---
#+macro: make-hyperlink-to-custom-id (eval (cond ((org-export-derived-backend-p 
org-export-current-backend 'html) (concat "[[file:" (buffer-file-name) 
":$1]]")) ((org-export-derived-backend-p org-export-current-backend 'latex) 
"[[$1]]") (t "[[$1]]")))
--8<---------------cut here---------------end--------------->8---

It could have been shorter, some other people might be able to help out.

There is a flaw though, since the branch from the 'html conditional
returns an absolute path, and I don't know if this is what you want, and
it of course refers to the Org mode original document as you asked ---
that is: it won't link to the object in the HTML that actually has that
custom identity.

I hope this helps.

-- 
- https://libreplanet.org/wiki/User:Adfeno
- Palestrante e consultor sobre /software/ livre (não confundir com
  gratis).
- "WhatsApp"? Ele não é livre. Por favor, veja formas de se comunicar
  instantaneamente comigo no endereço abaixo.
- Contato: https://libreplanet.org/wiki/User:Adfeno#vCard
- Arquivos comuns aceitos (apenas sem DRM): Corel Draw, Microsoft
  Office, MP3, MP4, WMA, WMV.
- Arquivos comuns aceitos e enviados: CSV, GNU Dia, GNU Emacs Org, GNU
  GIMP, Inkscape SVG, JPG, LibreOffice (padrão ODF), OGG, OPUS, PDF
  (apenas sem DRM), PNG, TXT, WEBM.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]