summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-01-29 00:52:49 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-01-29 00:52:49 +0100
commit9ab973d0a64b0733528a74f3b8fcefb65a3abb0c (patch)
treede0860ff2af4bac62002d32d4e9de3b188d9a47f
parent75ee067410abf0ebab77b1b05d7dcfe2ddf53f4d (diff)
downloadorg-mode-9ab973d0a64b0733528a74f3b8fcefb65a3abb0c.tar.gz
org-macro: Fix expansion in narrowed buffers
* lisp/org-macro.el (org-macro-replace-all): Expand macro even outside narrowed part of the buffer. * testing/lisp/test-org-macro.el (test-org/macro-replace-all): Add test. Reported-by: Kaushal Modi <kaushal.modi@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/104562>
-rw-r--r--lisp/org-macro.el2
-rw-r--r--testing/lisp/test-org-macro.el12
2 files changed, 12 insertions, 2 deletions
diff --git a/lisp/org-macro.el b/lisp/org-macro.el
index b27261d..fee33f6 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 4934d93..26c5674 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,*???)}}}<point>"
(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}}}\n<point>Contents"
+ (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."