summaryrefslogtreecommitdiff
path: root/lisp/org/org-macro.el
diff options
context:
space:
mode:
authorRasmus <rasmus@gmx.us>2017-08-29 10:07:08 +0200
committerRasmus <rasmus@gmx.us>2017-08-29 10:13:31 +0200
commit3ad8ca429bac5e1354881cf4411d6f41dab36b44 (patch)
tree41d8dc789a212dc3b1e09f402714b09dc1462fc5 /lisp/org/org-macro.el
parentc1854b1d31e1b0a3a9e91ef41110a5fa77bedb31 (diff)
Update Org to v9.0.10
Please see etc/ORG-NEWS for major changes. Note, this is a bugfix release.
Diffstat (limited to 'lisp/org/org-macro.el')
-rw-r--r--lisp/org/org-macro.el98
1 files changed, 48 insertions, 50 deletions
diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el
index 3dc9c5450ed..3b8f8140c9c 100644
--- a/lisp/org/org-macro.el
+++ b/lisp/org/org-macro.el
@@ -186,56 +186,54 @@ 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
- (goto-char (point-min))
- (let ((properties-regexp
- (format "\\`EXPORT_%s\\+?\\'" (regexp-opt keywords)))
- record)
- (while (re-search-forward "{{{[-A-Za-z0-9_]" nil t)
- (unless (save-match-data (org-in-commented-heading-p))
- (let* ((datum (save-match-data (org-element-context)))
- (type (org-element-type datum))
- (macro
- (cond
- ((eq type 'macro) datum)
- ;; In parsed keywords and associated node
- ;; properties, force macro recognition.
- ((or (and (eq type 'keyword)
- (member (org-element-property :key datum)
- keywords))
- (and (eq type 'node-property)
- (string-match-p properties-regexp
- (org-element-property :key
- datum))))
- (save-excursion
- (goto-char (match-beginning 0))
- (org-element-macro-parser))))))
- (when macro
- (let* ((value (org-macro-expand macro templates))
- (begin (org-element-property :begin macro))
- (signature (list begin
- macro
- (org-element-property :args macro))))
- ;; Avoid circular dependencies by checking if the same
- ;; macro with the same arguments is expanded at the
- ;; same position twice.
- (cond ((member signature record)
- (error "Circular macro expansion: %s"
- (org-element-property :key macro)))
- (value
- (push signature record)
- (delete-region
- begin
- ;; Preserve white spaces after the macro.
- (progn (goto-char (org-element-property :end macro))
- (skip-chars-backward " \t")
- (point)))
- ;; Leave point before replacement in case of
- ;; recursive expansions.
- (save-excursion (insert value)))
- (finalize
- (error "Undefined Org macro: %s; aborting"
- (org-element-property :key macro))))))))))))
+ (org-with-wide-buffer
+ (goto-char (point-min))
+ (let ((properties-regexp (format "\\`EXPORT_%s\\+?\\'"
+ (regexp-opt keywords)))
+ record)
+ (while (re-search-forward "{{{[-A-Za-z0-9_]" nil t)
+ (unless (save-match-data (org-in-commented-heading-p))
+ (let* ((datum (save-match-data (org-element-context)))
+ (type (org-element-type datum))
+ (macro
+ (cond
+ ((eq type 'macro) datum)
+ ;; In parsed keywords and associated node
+ ;; properties, force macro recognition.
+ ((or (and (eq type 'keyword)
+ (member (org-element-property :key datum) keywords))
+ (and (eq type 'node-property)
+ (string-match-p properties-regexp
+ (org-element-property :key datum))))
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (org-element-macro-parser))))))
+ (when macro
+ (let* ((value (org-macro-expand macro templates))
+ (begin (org-element-property :begin macro))
+ (signature (list begin
+ macro
+ (org-element-property :args macro))))
+ ;; Avoid circular dependencies by checking if the same
+ ;; macro with the same arguments is expanded at the
+ ;; same position twice.
+ (cond ((member signature record)
+ (error "Circular macro expansion: %s"
+ (org-element-property :key macro)))
+ (value
+ (push signature record)
+ (delete-region
+ begin
+ ;; Preserve white spaces after the macro.
+ (progn (goto-char (org-element-property :end macro))
+ (skip-chars-backward " \t")
+ (point)))
+ ;; Leave point before replacement in case of
+ ;; recursive expansions.
+ (save-excursion (insert value)))
+ (finalize
+ (error "Undefined Org macro: %s; aborting"
+ (org-element-property :key macro))))))))))))
(defun org-macro-escape-arguments (&rest args)
"Build macro's arguments string from ARGS.