From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: TIL about use of eval in user Org macros.. Documentation? Date: Wed, 20 Dec 2017 22:30:16 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c033d1c4bcaa10560cd21d1" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRmsf-0007aj-3M for emacs-orgmode@gnu.org; Wed, 20 Dec 2017 17:30:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRmsd-0007wo-TV for emacs-orgmode@gnu.org; Wed, 20 Dec 2017 17:30:29 -0500 Received: from mail-yw0-x22f.google.com ([2607:f8b0:4002:c05::22f]:36100) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRmsd-0007wL-My for emacs-orgmode@gnu.org; Wed, 20 Dec 2017 17:30:27 -0500 Received: by mail-yw0-x22f.google.com with SMTP id r205so2294698ywb.3 for ; Wed, 20 Dec 2017 14:30:27 -0800 (PST) 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-org list --94eb2c033d1c4bcaa10560cd21d1 Content-Type: text/plain; charset="UTF-8" Hello, The commit message in this commit is golden: http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=3ac619c8ac9934a2a1368f3de8ffad951f900067 Using that info, I came up with a "classified" version of n macro for markdown/HTML: #+MACRO: sec (eval (concat "" (number-to-string (org-macro--counter-increment $1 $2)) "")) Based on that I have two questions: 1. Can you please document the use of eval form in Org macro definitions in the Org manual(.org)? Its awesome wasn't evident to me until I read that commit message. 2. (Another question on canonical approach) What would be the recommended approach for an exporter backend to add new macros or override existing macros (like "n" macro to wrap the string with HTML class as an example)? Should it update org-macro-templates in org-export-before-processing-hook? or something similar? -- Kaushal Modi --94eb2c033d1c4bcaa10560cd21d1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Using that info, I came up with a "classifie= d" version of n macro for markdown/HTML:

#+MACRO: sec (eval (co= ncat "<span class=3D\"section-num\">" (number-to-= string (org-macro--counter-increment $1 $2)) "</span>"))
Based on that I have two questions:

1. Can you plea= se document the use of eval form in Org macro definitions in the Org manual= (.org)? Its awesome wasn't evident to me until I read that commit messa= ge.
2. (Another question on canonical approach) What would be the = recommended approach for an exporter backend to add new macros or override = existing macros (like "n" macro to wrap the string with HTML clas= s as an example)? Should it update org-macro-templates in org-export-before= -processing-hook? or something similar?
--

Kaushal Modi

--94eb2c033d1c4bcaa10560cd21d1--