branch: externals/org
commit fb9940bc40c3afcd05aec6801493081df9468516
Author: Steven Allen <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    Ignore the syntax-table text-prop when binding a temp syntax-table
    
    This ensures we can, e.g., scan for matching brackets without having the
    syntax-table text property interfere with our search.
    
    * lisp/org-macs.el (org-with-syntax-table): Add a org-specific
    `with-syntax-table' macro that binds `parse-sexp-lookup-properties' to
    nil while evaluating the body.
---
 lisp/org-agenda.el  |  2 +-
 lisp/org-capture.el |  2 +-
 lisp/org-element.el |  6 +++---
 lisp/org-macs.el    | 10 ++++++++++
 lisp/org.el         |  8 ++++----
 5 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 0444d0d81e..8242f80366 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4809,7 +4809,7 @@ is active."
            (setq rtn (list (format "ORG-AGENDA-ERROR: No such org-file %s"
                                    file))))
          (with-current-buffer buffer
-           (with-syntax-table (org-search-syntax-table)
+           (org-with-syntax-table (org-search-syntax-table)
              (unless (derived-mode-p 'org-mode)
                (error "Agenda file %s is not in Org mode" file))
              (let ((case-fold-search t))
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 45348b7e91..3c80408544 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -2091,7 +2091,7 @@ marked Sexp are evaluated when this argument is nil."
        ;; Only mark valid and non-escaped sexp.
        ((org-capture-escaped-%) nil)
        (t
-       (let ((end (with-syntax-table emacs-lisp-mode-syntax-table
+       (let ((end (org-with-syntax-table emacs-lisp-mode-syntax-table
                     (ignore-errors (scan-sexps (1- (point)) 1)))))
          (when end
            (put-text-property (- (point) 2) end 'org-embedded-elisp t))))))))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 22fdec4d2e..3dd33b11e1 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -507,7 +507,7 @@ past the brackets."
                          (_ nil)))
          (pos (point)))
       (when syntax-table
-       (with-syntax-table syntax-table
+       (org-with-syntax-table syntax-table
          (let ((end (ignore-errors (scan-lists pos 1 0))))
            (when end
              (goto-char end)
@@ -3399,7 +3399,7 @@ Assume point is at the beginning of the citation."
                         (match-string-no-properties 1))))
           ;; Ignore blanks between cite type and prefix or key.
           (start (match-end 0))
-          (closing (with-syntax-table org-element--pair-square-table
+          (closing (org-with-syntax-table org-element--pair-square-table
                      (ignore-errors (scan-lists begin 1 0)))))
       (save-excursion
        (when (and closing
@@ -3640,7 +3640,7 @@ When at a footnote reference, return a new syntax node of
 `:end', `:contents-begin', `:contents-end' and `:post-blank' as
 properties.  Otherwise, return nil."
   (when (looking-at org-footnote-re)
-    (let ((closing (with-syntax-table org-element--pair-square-table
+    (let ((closing (org-with-syntax-table org-element--pair-square-table
                     (ignore-errors (scan-lists (point) 1 0)))))
       (when closing
        (save-excursion
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index c6f2a9033e..c3be41d025 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -274,6 +274,16 @@ This function is only useful when called from Agenda 
buffer."
   `(cl-letf (((symbol-function #'org-element--cache-active-p) (lambda (&rest 
_) nil)))
      ,@body))
 
+(defmacro org-with-syntax-table (table &rest body)
+  "Evaluate BODY with syntax table of current buffer set to TABLE.
+
+This is the same as `with-syntax-table' except that it also binds
+`parse-sexp-lookup-properties' to nil."
+  (declare (debug t) (indent 1))
+  `(with-syntax-table ,table
+     (let ((parse-sexp-lookup-properties nil))
+       ,@body)))
+
 
 ;;; Buffer and windows
 
diff --git a/lisp/org.el b/lisp/org.el
index dcb1232c0d..47d02433e9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11816,7 +11816,7 @@ See also `org-scan-tags'."
                   (mm
                    (cond
                     (regexp                    ; [2]
-                      `(with-syntax-table org-mode-tags-syntax-table
+                      `(org-with-syntax-table org-mode-tags-syntax-table
                          (org-match-any-p ,(substring tag 1 -1) tags-list)))
                     (propp
                      (let* (;; Determine property name.
@@ -11970,7 +11970,7 @@ the list of tags in this group."
            (add-text-properties
             (match-beginning 0) (match-end 0) '(regexp t) return-match)))
        ;; For each tag token found in MATCH, compute a regexp and  it
-       (with-syntax-table org-mode-tags-syntax-table
+       (org-with-syntax-table org-mode-tags-syntax-table
          (replace-regexp-in-string
           key-regexp
           (lambda (m)
@@ -16993,7 +16993,7 @@ This uses the `org-mode-transpose-word-syntax-table' 
syntax
 table, which interprets characters in `org-emphasis-alist' as
 word constituents."
   (interactive)
-  (with-syntax-table org-mode-transpose-word-syntax-table
+  (org-with-syntax-table org-mode-transpose-word-syntax-table
     (call-interactively 'transpose-words)))
 
 (defvar org-ctrl-c-ctrl-c-hook nil
@@ -19902,7 +19902,7 @@ width for filling.
 
 For convenience, when point is at a plain list, an item or
 a footnote definition, try to fill the first paragraph within."
-  (with-syntax-table org-mode-transpose-word-syntax-table
+  (org-with-syntax-table org-mode-transpose-word-syntax-table
     ;; Move to end of line in order to get the first paragraph within
     ;; a plain list or a footnote definition.
     (let ((element (save-excursion (end-of-line) (org-element-at-point))))

Reply via email to