bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#61098: 29.0.60; Confusing behavior of show-paren-mode


From: Dmitry Gutov
Subject: bug#61098: 29.0.60; Confusing behavior of show-paren-mode
Date: Sun, 5 Feb 2023 21:09:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

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






reply via email to

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