From: Antero Mejr via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stefan Kangas <stefankangas@gmail.com>, 68234@debbugs.gnu.org
Subject: bug#68234: [PATCH] Increase blink-matching-paren-distance by 300kb.
Date: Fri, 05 Jan 2024 21:10:10 +0000 [thread overview]
Message-ID: <87o7dzlc5p.fsf@mailbox.org> (raw)
In-Reply-To: <87sf3bld22.fsf@mailbox.org> (Antero Mejr's message of "Fri, 05 Jan 2024 20:50:45 +0000")
[-- Attachment #1: Type: text/plain, Size: 599 bytes --]
Antero Mejr <antero@mailbox.org> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>> I think we can at most double it at this time. This is a defcustom,
>> so people can always increase it in their local configurations if they
>> have much faster machines and need routinely to cope with such large
>> parenthetical expressions.
>
> If we're not increasing it that much, can we change the behavior to not
> wrongly indicate mismatched parens for expressions where you can't be
> sure? Patch is attached.
Updated version of the last patch, accounts for when
blink-matching-paren-distance is nil.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-show-mismatched-parens-if-search-region-is-nar.patch --]
[-- Type: text/x-patch, Size: 4237 bytes --]
From bb48036f39affb549fd71ee417d4cf9b111eaabf Mon Sep 17 00:00:00 2001
From: Antero Mejr <antero@mailbox.org>
Date: Fri, 5 Jan 2024 20:37:52 +0000
Subject: [PATCH] Don't show mismatched parens if search region is narrowed
* lisp/paren.el (show-paren--default): Don't highlight paren as
mismatched if region is narrowed.
* lisp/simple.el (blink-matching-open): Don't display mismatched paren
message if region is narrowed. (Bug#68234)
---
lisp/paren.el | 16 +++++++++++-----
lisp/simple.el | 17 +++++++++++------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/lisp/paren.el b/lisp/paren.el
index cb29b8311a5..267289f9273 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -246,7 +246,7 @@ It is the default value of `show-paren-data-function'."
(if (ppss-comment-depth (syntax-ppss))
nil
parse-sexp-ignore-comments))
- pos mismatch here-beg here-end)
+ pos mismatch here-beg here-end narrowed)
;;
;; Find the other end of the sexp.
(when dir
@@ -255,9 +255,14 @@ It is the default value of `show-paren-data-function'."
(save-restriction
;; Determine the range within which to look for a match.
(when blink-matching-paren-distance
- (narrow-to-region
- (max (point-min) (- (point) blink-matching-paren-distance))
- (min (point-max) (+ (point) blink-matching-paren-distance))))
+ (let ((start (- (point) blink-matching-paren-distance))
+ (end (+ (point) blink-matching-paren-distance)))
+ ;; If narrowed, the match may be outside the region.
+ (setq narrowed (or (and (< (point-min) start) (eq dir -1))
+ (and (> (point-max) end) (eq dir 1))))
+ (narrow-to-region
+ (max (point-min) start)
+ (min (point-max) end))))
;; Scan across one sexp within that range.
;; Errors or nil mean there is a mismatch.
(condition-case ()
@@ -275,7 +280,8 @@ It is the default value of `show-paren-data-function'."
;; If found a "matching" paren, see if it is the right
;; kind of paren to match the one we started at.
(if (not (integerp pos))
- (if mismatch (list here-beg here-end nil nil t))
+ (if (and mismatch (not narrowed))
+ (list here-beg here-end nil nil t))
(let ((beg (min pos outside)) (end (max pos outside)))
(unless (eq (syntax-class (syntax-after beg)) 8)
(setq mismatch
diff --git a/lisp/simple.el b/lisp/simple.el
index a464123f8b5..473532dc9bd 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9335,15 +9335,20 @@ The function should return non-nil if the two tokens do not match.")
blink-matching-paren)
(let* ((oldpos (point))
(message-log-max nil) ; Don't log messages about paren matching.
+ (narrowed nil)
(blinkpos
(save-excursion
(save-restriction
(syntax-propertize (point))
- (if blink-matching-paren-distance
- (narrow-to-region
- (max (minibuffer-prompt-end) ;(point-min) unless minibuf.
- (- (point) blink-matching-paren-distance))
- oldpos))
+ (when blink-matching-paren-distance
+ (let ((start (- (point)
+ blink-matching-paren-distance)))
+ ;; If narrowed, the match may be outside the region.
+ (setq narrowed (< (minibuffer-prompt-end) start))
+ (narrow-to-region
+ (max (minibuffer-prompt-end) ;(point-min) unless minibuf.
+ start)
+ oldpos)))
(let ((parse-sexp-ignore-comments
(and parse-sexp-ignore-comments
(not blink-matching-paren-dont-ignore-comments))))
@@ -9362,7 +9367,7 @@ The function should return non-nil if the two tokens do not match.")
(error nil))))))
(mismatch (funcall blink-matching-check-function blinkpos oldpos)))
(cond
- (mismatch
+ ((and mismatch (not narrowed))
(if blinkpos
(if (minibufferp)
(minibuffer-message "Mismatched parentheses")
--
2.43.0
next prev parent reply other threads:[~2024-01-05 21:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 18:37 bug#68234: [PATCH] Increase blink-matching-paren-distance by 300kb Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <handler.68234.B.170430710530123.ack@debbugs.gnu.org>
2024-01-03 18:48 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-04 11:31 ` Eli Zaretskii
2024-01-04 23:08 ` Stefan Kangas
2024-01-05 7:49 ` Eli Zaretskii
2024-01-05 20:50 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-05 21:10 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-01-06 7:01 ` Eli Zaretskii
2024-01-06 12:09 ` Stefan Kangas
2024-01-09 5:56 ` Stefan Kangas
2024-01-04 4:50 ` Stefan Kangas
2024-01-04 19:22 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-04 21:03 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-04 21:36 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7dzlc5p.fsf@mailbox.org \
--to=bug-gnu-emacs@gnu.org \
--cc=68234@debbugs.gnu.org \
--cc=antero@mailbox.org \
--cc=eliz@gnu.org \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.