emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3b731b1: Fix slow abbrev expansion in `message-mode' in some circ


From: Lars Ingebrigtsen
Subject: master 3b731b1: Fix slow abbrev expansion in `message-mode' in some circumstances
Date: Tue, 19 Jan 2021 10:08:02 -0500 (EST)

branch: master
commit 3b731b123d11e4c13e2dd16b336b146081f94a30
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix slow abbrev expansion in `message-mode' in some circumstances
    
    * lisp/gnus/message.el (message--syntax-propertize): Use the
    correct Message mode syntax table to avoid having
    `message-cite-prefix-regexp' trigger very heavy backtracing when
    called from an abbrev context (which defines "_" as a word
    constituent) (bug#45944).
---
 lisp/gnus/message.el | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 50e0218..b22b454 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -3057,22 +3057,23 @@ See also `message-forbidden-properties'."
 
 (defun message--syntax-propertize (beg end)
   "Syntax-propertize certain message text specially."
-  (let ((citation-regexp (concat "^" message-cite-prefix-regexp ".*$"))
-        (smiley-regexp (regexp-opt message-smileys)))
-    (goto-char beg)
-    (while (search-forward-regexp citation-regexp
-                                  end 'noerror)
-      (let ((start (match-beginning 0))
-            (end (match-end 0)))
-        (add-text-properties start (1+ start)
-                             `(syntax-table ,(string-to-syntax "<")))
-        (add-text-properties end (min (1+ end) (point-max))
-                             `(syntax-table ,(string-to-syntax ">")))))
-    (goto-char beg)
-    (while (search-forward-regexp smiley-regexp
-            end 'noerror)
-      (add-text-properties (match-beginning 0) (match-end 0)
-                           `(syntax-table ,(string-to-syntax "."))))))
+  (with-syntax-table message-mode-syntax-table
+    (let ((citation-regexp (concat "^" message-cite-prefix-regexp ".*$"))
+          (smiley-regexp (regexp-opt message-smileys)))
+      (goto-char beg)
+      (while (search-forward-regexp citation-regexp
+                                    end 'noerror)
+       (let ((start (match-beginning 0))
+              (end (match-end 0)))
+          (add-text-properties start (1+ start)
+                               `(syntax-table ,(string-to-syntax "<")))
+          (add-text-properties end (min (1+ end) (point-max))
+                               `(syntax-table ,(string-to-syntax ">")))))
+      (goto-char beg)
+      (while (search-forward-regexp smiley-regexp
+                                   end 'noerror)
+       (add-text-properties (match-beginning 0) (match-end 0)
+                             `(syntax-table ,(string-to-syntax ".")))))))
 
 ;;;###autoload
 (define-derived-mode message-mode text-mode "Message"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]