GNU bug report logs - #61098
29.0.60; Confusing behavior of show-paren-mode

Previous Next

Package: emacs;

Reported by: Rah Guzar <rahguzar <at> zohomail.eu>

Date: Fri, 27 Jan 2023 16:28:02 UTC

Severity: normal

Found in version 29.0.60

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


Message #55 received at 61098-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: rahguzar <at> zohomail.eu, Eli Zaretskii <eliz <at> gnu.org>,
 61098-done <at> debbugs.gnu.org
Subject: Re: bug#61098: 29.0.60; Confusing behavior of show-paren-mode
Date: Sun, 5 Feb 2023 21:09:36 +0200
On 05/02/2023 20:57, Stefan Monnier via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
>> +  :variable ( (and show-paren-mode
>> +                   (buffer-match-p show-paren-predicate (current-buffer)))
>> +              .
>>                 (lambda (val) (setq-local show-paren-mode val)))
> This doesn't look quote right because it doesn't pay attention to
> `local-variable-p`.  We should extract the test performed in the timer
> and reuse it here.

Thank you, makes sense.

Here's the patch I installed:

diff --git a/lisp/paren.el b/lisp/paren.el
index 7ee4e9ae682..4c91fd29490 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -161,8 +161,9 @@ show-paren--delete-overlays
 ;;;###autoload
 (define-minor-mode show-paren-local-mode
   "Toggle `show-paren-mode' only in this buffer."
-  :variable ( show-paren-mode .
-              (lambda (val) (setq-local show-paren-mode val)))
+  :variable ((show-paren--enabled-p)
+             .
+             (lambda (val) (setq-local show-paren-mode val)))
   (cond
    ((eq show-paren-mode (default-value 'show-paren-mode))
     (unless show-paren-mode
@@ -428,14 +429,17 @@ show-paren--show-context-in-overlay
 ;; `show-paren-delay'.
 (defvar-local show-paren--last-pos nil)

+(defun show-paren--enabled-p ()
+  (and show-paren-mode
+       ;; If we're using `show-paren-local-mode', then
+       ;; always heed the value.
+       (or (local-variable-p 'show-paren-mode)
+           ;; If not, check that the predicate matches.
+           (buffer-match-p show-paren-predicate (current-buffer)))))
+
 (defun show-paren-function ()
   "Highlight the parentheses until the next input arrives."
-  (let ((data (and show-paren-mode
-                   ;; If we're using `show-paren-local-mode', then
-                   ;; always heed the value.
-                   (or (local-variable-p 'show-paren-mode)
-                       ;; If not, check that the predicate matches.
-                       (buffer-match-p show-paren-predicate 
(current-buffer)))
+  (let ((data (and (show-paren--enabled-p)
                    (funcall show-paren-data-function))))
     (if (not data)
         (progn





This bug report was last modified 2 years and 165 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.