1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-21 06:55:35 +00:00

ox: New custom option to disable macro replacement

* lisp/ox.el (org-export-replace-macros): New custom option
controlling macro replacement.
(org-export--annotate-info): Honor it, except when processing inline
code block results and their {{{results...}}} macro.
* etc/ORG-NEWS (Allow disabling macro replacement during export):
Announce the new option.
* doc/org-manual.org (Macro Replacement):
(Summary of the export process): Document the new option.
This commit is contained in:
Ihor Radchenko 2024-07-08 13:52:32 +02:00
parent f7ef4071b2
commit 90d4ae92eb
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 27 additions and 6 deletions

View File

@ -12682,9 +12682,11 @@ The following command allows navigating to the included document:
#+cindex: @samp{MACRO}, keyword
#+vindex: org-export-global-macros
Macros replace text snippets during export. Macros are defined
globally in ~org-export-global-macros~, or document-wise with the
following syntax:
#+vindex: org-export-replace-macros
Macros replace text snippets during export[fn::The macro replacement
can be disabled by setting ~org-export-replace-macros~ to nil (default
is t).]. Macros are defined globally in ~org-export-global-macros~,
or document-wise with the following syntax:
: #+MACRO: name replacement text; $1, $2 are arguments
@ -16702,7 +16704,8 @@ export keywords, does not contribute to the export output.]:
3. Remove commented subtrees in the whole buffer (see [[*Comment
Lines]]);
4. Replace macros in the whole buffer (see [[*Macro Replacement]]);
4. Replace macros in the whole buffer (see [[*Macro Replacement]]),
unless ~org-export-replace-macros~ is nil;
5. When ~org-export-use-babel~ is non-nil (default), process code
blocks:

View File

@ -43,6 +43,15 @@ or newer.
# adding new customizations, or changing the interpretation of the
# existing customizations.
*** Allow disabling macro replacement during export
New custom option ~org-export-replace-macros~ controls whether Org
mode replaces macros in the buffer before export. Set it to nil to
disable macro replacement.
This variable has no effect on the ={{{results...}}}= macros for inline
code block results.
*** Allow headline/olp target in ~org-capture-templates~ to be a function/variable
The variable ~org-capture-templates~ accepts a target specification as

View File

@ -860,6 +860,14 @@ This option can also be set with the OPTIONS keyword, e.g.,
:package-version '(Org . "9.7")
:type 'boolean)
(defcustom org-export-replace-macros t
"When non-nil, replace macros before export.
This variable does not affect {{{results}}} macros when processing
code block results."
:group 'org-export-general
:package-version '(Org . "9.8")
:type 'boolean)
(defcustom org-export-snippet-translation-alist nil
"Alist between export snippets backends and exporter backends.
@ -3048,8 +3056,9 @@ still inferior to file-local settings."
(org-export-backend-name backend))
(org-export-expand-include-keyword nil nil nil nil (plist-get info :expand-links))
(org-export--delete-comment-trees)
(org-macro-initialize-templates org-export-global-macros)
(org-macro-replace-all org-macro-templates parsed-keywords)
(when org-export-replace-macros
(org-macro-initialize-templates org-export-global-macros)
(org-macro-replace-all org-macro-templates parsed-keywords))
;; Refresh buffer properties and radio targets after previous
;; potentially invasive changes.
(org-set-regexps-and-options)