emacs-diffs
[Top][All Lists]
Advanced

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

master 7500aba: * lisp/simple.el (blink-matching-open): Fix bug#37127


From: Stefan Monnier
Subject: master 7500aba: * lisp/simple.el (blink-matching-open): Fix bug#37127
Date: Fri, 30 Oct 2020 18:10:12 -0400 (EDT)

branch: master
commit 7500abaa8ef1cec772b197d28d3c3c47b4bc5a86
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/simple.el (blink-matching-open): Fix bug#37127
    
    Don't call `syntax-propertize` from within narrowing
    
    * lisp/progmodes/cperl-mode.el (cperl-forward-re): Revert last patch,
    since it is now redundant.
    
    * test/lisp/progmodes/cperl-mode-tests.el (cperl-bug37127):
    Remove unused var; fix test so it really catches the previous bug;
    tweak the code to use mode-agnostic commands so it also works in 
`perl-mode`.
---
 lisp/progmodes/cperl-mode.el            |  7 ------
 lisp/simple.el                          |  2 +-
 test/lisp/progmodes/cperl-mode-tests.el | 39 +++++++++++++++++++--------------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 94f42cb..ebbea6b 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -3225,13 +3225,6 @@ modify syntax-type text property if the situation is too 
hard."
                 (and cperl-brace-recursing
                      (or (eq ostart  ?\{)
                          (eq starter ?\{)))
-                ;; If we are at the end of a narrowed buffer, then a
-                ;; scan error should not be reported to the user.
-                ;; This situation actually happens when a closing
-                ;; paren is entered in a regular expression.
-                ;; Reported in Bug#37127.
-                (and (eobp) (buffer-narrowed-p)
-                     (equal (car bb) 'scan-error))
                 (message
                  "End of `%s%s%c ... %c' string/RE not found: %s"
                  argument
diff --git a/lisp/simple.el b/lisp/simple.el
index 2e40e32..a9d79d0 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8014,6 +8014,7 @@ The function should return non-nil if the two tokens do 
not match.")
           (blinkpos
             (save-excursion
               (save-restriction
+               (syntax-propertize (point))
                 (if blink-matching-paren-distance
                     (narrow-to-region
                      (max (minibuffer-prompt-end) ;(point-min) unless minibuf.
@@ -8024,7 +8025,6 @@ The function should return non-nil if the two tokens do 
not match.")
                             (not blink-matching-paren-dont-ignore-comments))))
                   (condition-case ()
                       (progn
-                       (syntax-propertize (point))
                         (forward-sexp -1)
                         ;; backward-sexp skips backward over prefix chars,
                         ;; so move back to the matching paren.
diff --git a/test/lisp/progmodes/cperl-mode-tests.el 
b/test/lisp/progmodes/cperl-mode-tests.el
index 75010f7..9a7b5e4 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -224,28 +224,35 @@ point in the distant past, and is still broken in 
perl-mode. "
   "Verify that closing a paren in a regex goes without a message.
 Also check that the message is issued if the regex terminator is
 missing."
-  (let (collected-messages)
-    ;; Part one: Regex is ok, no messages
-    (ert-with-message-capture collected-messages
-      (with-temp-buffer
-        (insert "$_ =~ /(./;")
-        (cperl-mode)
-        (goto-char (point-min))
-        (search-forward ".")
-        (let ((last-command-event ?\)))
-          (cperl-electric-rparen 1)
-          (cperl-find-pods-heres (point-min) (point-max) t)))
-      (should (string-equal collected-messages "")))
-    ;; part two: Regex terminator missing -> message
+  ;; Part one: Regex is ok, no messages
+  (ert-with-message-capture collected-messages
+    (with-temp-buffer
+      (insert "$_ =~ /(./;")
+      (funcall cperl-test-mode)
+      (goto-char (point-min))
+      (search-forward ".")
+      (let ((last-command-event ?\))
+            ;; Don't emit "Matches ..." even if not visible (e.g. in batch).
+            (blink-matching-paren 'jump-offscreen))
+        (self-insert-command 1)
+        ;; `self-insert-command' doesn't call `blink-matching-open' in
+        ;; batch mode, so we need to call it explicitly.
+        (blink-matching-open))
+      (syntax-propertize (point-max)))
+    (should (string-equal collected-messages "")))
+  ;; part two: Regex terminator missing -> message
+  (when (eq cperl-test-mode #'cperl-mode)
+    ;; This test is only run in `cperl-mode' because only cperl-mode
+    ;; emits a message to warn about such unclosed REs.
     (ert-with-message-capture collected-messages
       (with-temp-buffer
         (insert "$_ =~ /(..;")
         (goto-char (point-min))
-        (cperl-mode)
+        (funcall cperl-test-mode)
         (search-forward ".")
         (let ((last-command-event ?\)))
-          (cperl-electric-rparen 1)
-          (cperl-find-pods-heres (point-min) (point-max) t)))
+          (self-insert-command 1))
+        (syntax-propertize (point-max)))
       (should (string-match "^End of .* string/RE"
                             collected-messages)))))
 



reply via email to

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