From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Antero Mejr via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68234: [PATCH] Increase blink-matching-paren-distance by 300kb. Date: Fri, 05 Jan 2024 21:10:10 +0000 Message-ID: <87o7dzlc5p.fsf@mailbox.org> References: <8734vejmaz.fsf@mailbox.org> <87v88ai77a.fsf_-_@mailbox.org> <83v889wd16.fsf@gnu.org> <83frzcw783.fsf@gnu.org> <87sf3bld22.fsf@mailbox.org> Reply-To: Antero Mejr Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6290"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Kangas , 68234@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 05 22:12:27 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rLrUR-0001RU-6d for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Jan 2024 22:12:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLrU4-000225-Ta; Fri, 05 Jan 2024 16:12:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rLrTy-0001yo-LP for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 16:11:59 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rLrTy-0001pz-7D for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 16:11:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLrU2-00077f-CS for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 16:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Antero Mejr Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Jan 2024 21:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68234 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68234-submit@debbugs.gnu.org id=B68234.170448907927328 (code B ref 68234); Fri, 05 Jan 2024 21:12:02 +0000 Original-Received: (at 68234) by debbugs.gnu.org; 5 Jan 2024 21:11:19 +0000 Original-Received: from localhost ([127.0.0.1]:58066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLrTL-00076h-4k for submit@debbugs.gnu.org; Fri, 05 Jan 2024 16:11:19 -0500 Original-Received: from mout-p-101.mailbox.org ([80.241.56.151]:59454) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLrTG-00076P-Jd for 68234@debbugs.gnu.org; Fri, 05 Jan 2024 16:11:18 -0500 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4T6GMp64Hkz9sbL; Fri, 5 Jan 2024 22:11:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1704489062; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=peTsC5z9AvypX558Nvdh+P2se+nZb3M7nRIBfas4ngw=; b=Y8xCC8IjyY1fixMLAIVYV//CrVdFHUierHvadwl+LArsUY/y+N21Psx7RcdykffxxX6XT3 0f7yebpPbaKXZ3DJUlfYYDTH0vhdXELY5sdYrJ5/9vbkwwLIUka9/Xi7xWf09OE98xz1jj DheqeNxJpRvqO5q8N6kmhHwHYNdAI8wSBXq+6QJ+hkXbl3EPL2VnbF+i8Sbu1DU8LWARtf KUOU24NS2EcQQNz8q7Xf1u3HcSkob56j2OzJb7QVizc1I/Bxbw0Cml1inEIqTOYo3dRpVE 0isDEolgq4hyCa4Qg5R41wDa6rgGcBQyTGpmy5YIZUh0JWCfqHd3fjYy3Bi/PA== In-Reply-To: <87sf3bld22.fsf@mailbox.org> (Antero Mejr's message of "Fri, 05 Jan 2024 20:50:45 +0000") X-MBO-RS-META: mhyne9u4b1q5t6ijg8ckzk5z9h9kiucn X-MBO-RS-ID: d0c08d82b02262306a8 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277416 Archived-At: --=-=-= Content-Type: text/plain Antero Mejr writes: > Eli Zaretskii 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Don-t-show-mismatched-parens-if-search-region-is-nar.patch >From bb48036f39affb549fd71ee417d4cf9b111eaabf Mon Sep 17 00:00:00 2001 From: Antero Mejr 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 --=-=-=--