Explorar el Código

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>
Nicolas Goaziou hace 9 años
padre
commit
9ab973d0a6
Se han modificado 2 ficheros con 12 adiciones y 2 borrados
  1. 1 1
      lisp/org-macro.el
  2. 11 1
      testing/lisp/test-org-macro.el

+ 1 - 1
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)))

+ 11 - 1
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."