From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adonay Felipe Nogueira Subject: Re: is there a macro to have backend-specific behavior? Date: Sat, 03 Mar 2018 14:33:31 -0300 Message-ID: <87sh9hhxn8.fsf@hyperbola.info> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esB2R-0006qU-N0 for emacs-orgmode@gnu.org; Sat, 03 Mar 2018 12:33:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esB2O-0004ZK-Ju for emacs-orgmode@gnu.org; Sat, 03 Mar 2018 12:33:39 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:36313) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1esB2O-0004XR-Cv for emacs-orgmode@gnu.org; Sat, 03 Mar 2018 12:33:36 -0500 Received: from adfeno-pc1 (unknown [181.221.158.128]) (Authenticated sender: adfeno@hyperbola.info) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 408E9C5A5D for ; Sat, 3 Mar 2018 18:33:33 +0100 (CET) In-Reply-To: (Alan Schmitt's message of "Thu, 01 Feb 2018 10:58:31 +0100") 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" To: emacs-orgmode@gnu.org > 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-backe= nd-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. --=20 - https://libreplanet.org/wiki/User:Adfeno - Palestrante e consultor sobre /software/ livre (n=C3=A3o confundir com gratis). - "WhatsApp"? Ele n=C3=A3o =C3=A9 livre. Por favor, veja formas de se comun= icar instantaneamente comigo no endere=C3=A7o 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=C3=A3o ODF), OGG, OPUS, PDF (apenas sem DRM), PNG, TXT, WEBM.