summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2020-10-30 18:10:06 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2020-10-30 18:10:06 -0400
commit7500abaa8ef1cec772b197d28d3c3c47b4bc5a86 (patch)
tree9792fb5461154b2999505810da2afa18349c7117
parent3f1dd62a0c87aa9b1a7243c1604bdbd5a29dd138 (diff)
downloademacs-7500abaa8ef1cec772b197d28d3c3c47b4bc5a86.tar.gz
* 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`.
-rw-r--r--lisp/progmodes/cperl-mode.el7
-rw-r--r--lisp/simple.el2
-rw-r--r--test/lisp/progmodes/cperl-mode-tests.el39
3 files changed, 24 insertions, 24 deletions
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 94f42cb2bc4..ebbea6bed92 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 2e40e3261c9..a9d79d031e8 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 75010f7d0f3..9a7b5e4d6dd 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)))))