From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id ktI6HbcTuV8dfQAA0tVLHw (envelope-from ) for ; Sat, 21 Nov 2020 13:18:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id OMCAGLcTuV+tSgAAB5/wlQ (envelope-from ) for ; Sat, 21 Nov 2020 13:18:47 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9EE68940237 for ; Sat, 21 Nov 2020 13:18:46 +0000 (UTC) Received: from localhost ([::1]:56512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgSmq-0004gj-QX for larch@yhetil.org; Sat, 21 Nov 2020 08:18:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgSmO-0004f6-98 for emacs-orgmode@gnu.org; Sat, 21 Nov 2020 08:18:16 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:37998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kgSmL-0005yi-JM for emacs-orgmode@gnu.org; Sat, 21 Nov 2020 08:18:15 -0500 Received: by mail-pf1-x433.google.com with SMTP id 10so10603180pfp.5 for ; Sat, 21 Nov 2020 05:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:in-reply-to:message-id:date :mime-version; bh=SNEBFRdhrdyPIoyoWiL90FnjQW/5UByAIjyNFBFUrvw=; b=syd/I65jxwdQtZfOo2IFetHFEgiUzfx0Qbzi9d0SSya0L5fZjL3xVzFAFlqDgiMCdA zKo7leuMHo4nV+jd/dT8OMoIVCdJWWyLRlqB9op3VqAWbfCGMvmUzF7f6PKxCXD8q7Kg yjlrhCMQOPs/ausBUghuXrSeesX2ER509RMipVVwDmopva0jmJNxEItkeWNPmKpIvKiT jKqdw4PNyAHmShfKN+khZmeernRZTj1Xp0fvoABiZzEze0zEGHuk0qvjv1sDEYZDPt0d d07ejUAfUrY6TG4TN5eSw45p53GFTpDVZO24Fyw+PRBT9XAIptM5OF1lgl1C2uV+iD+/ Guag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject :in-reply-to:message-id:date:mime-version; bh=SNEBFRdhrdyPIoyoWiL90FnjQW/5UByAIjyNFBFUrvw=; b=r8hQFLjmPBMLBGJzmysi0ua8+FjuC7AO7FUtq5/6x40YqXOQez+zvs6c256flmhVa+ JBqkWh5TbmNrd9zkvxKZrVvd4eqE600kYCI7f1JojS3COi5XP4+qgia//Q/FuvoINNuE SBe15Qg2yYoJpe1kBL3DUYJQw1SpcyV7fCh7tSnxr+f+7/Qcs8czYeZkw86F3L7eddgQ y+MTE0wbHw3YWE9wPRiQmnTxBwxNakXA8ZP4oXV3Sn+gUglNxg89pNA+EwXVMhn3aIor sZ3cnXr4tZMIQmeUfcPE2xOcFhloCDbOubYUr6ytTs7RbKtow4CxtRDFlmIA9uSN/jCA ifhg== X-Gm-Message-State: AOAM531jsnGLq1qayxwY9AvvsMeRdvOv0g3FAYCoK/mgaP7qSV1u5ST0 V86W0T6GAR35gI8wERVCRmVszr8DXQqwLA== X-Google-Smtp-Source: ABdhPJzioZ5COlMGX5jiO8OTgZrBcMnUOkFWpB4KMAHgmvCO39rd/xhTAyhitrQ/dI434k3j5iLx8A== X-Received: by 2002:a63:4765:: with SMTP id w37mr20612813pgk.332.1605964691743; Sat, 21 Nov 2020 05:18:11 -0800 (PST) Received: from tim-desktop (220-235-9-147.dyn.iinet.net.au. [220.235.9.147]) by smtp.gmail.com with ESMTPSA id v1sm7950972pjs.16.2020.11.21.05.18.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 05:18:10 -0800 (PST) References: <20201121105633.kgwzxc2l6oo5yeau@localhost.localdomain> User-agent: mu4e 1.5.7; emacs 27.1.50 From: Tim Cross To: emacs-orgmode@gnu.org Subject: Re: looking for a macro eval workaround (9.1 vs 9.2 and +) for export backend test In-reply-to: <20201121105633.kgwzxc2l6oo5yeau@localhost.localdomain> Message-ID: <87pn46hmr4.fsf@gmail.com> Date: Sun, 22 Nov 2020 00:18:07 +1100 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=theophilusx@gmail.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=syd/I65j; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: tr6GsQomJKwF Bruno BEAUFILS 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