diff --git a/lisp/org-macro.el b/lisp/org-macro.el index b27261df5..fee33f618 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -188,7 +188,7 @@ found in the buffer with no definition in TEMPLATES. Optional argument KEYWORDS, when non-nil is a list of keywords, as strings, where macro expansion is allowed." - (save-excursion + (org-with-wide-buffer (goto-char (point-min)) (let ((properties-regexp (format "\\`EXPORT_%s\\+?\\'" (regexp-opt keywords))) diff --git a/testing/lisp/test-org-macro.el b/testing/lisp/test-org-macro.el index 4934d93c1..26c56745c 100644 --- a/testing/lisp/test-org-macro.el +++ b/testing/lisp/test-org-macro.el @@ -107,7 +107,17 @@ (org-test-with-temp-text "* H1\n:PROPERTIES:\n:A: 1\n:END:\n* H2\n{{{property(A,*???)}}}" (org-macro-initialize-templates) - (org-macro-replace-all org-macro-templates)))) + (org-macro-replace-all org-macro-templates))) + ;; Macro expansion ignores narrowing. + (should + (string-match + "expansion" + (org-test-with-temp-text + "#+MACRO: macro expansion\n{{{macro}}}\nContents" + (narrow-to-region (point) (point-max)) + (org-macro-initialize-templates) + (org-macro-replace-all org-macro-templates) + (org-with-wide-buffer (buffer-string)))))) (ert-deftest test-org-macro/escape-arguments () "Test `org-macro-escape-arguments' specifications."