Kaushal Modi <kaushal.m...@gmail.com> writes: > 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 "<span class=\"section-num\">" (number-to-string > (org-macro--counter-increment $1 $2)) "</span>")) > > 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. I guess it isn’t documented in the manual... I agree, there could be a second example and the mention of using lisp or at least a mention of the ‘org-export-global-macros’ docstring. > 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? Do you really need to overwrite an old macro? Couldn’t you define a new macro? org-export-before-processing-hook is definitely the right hook, cf. ‘org-export-as’. (defun fooreplace (backend) (when (eq backend 'mybackend) (goto-char (point-min)) (while (search-forward-regexp "{{{foo\\((?\\)" nil t) (replace-match "{{{myfoo\\1")) (goto-char (point-max)) (insert "\n#+macro: myfoo mybar\n")))) Rasmus -- May contains speling mistake