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

From: Dmitry Gutov <[email-masked]>
Date: Tue, 31 Jan 2023 04:37:49 +0200

On 28/01/2023 14:20, Eli Zaretskii wrote:
> Here's the patch I promised above:

Your patch modifies the part which called the show-paren-mode to set up 
the timer, but the timer is started unconditionally, so predicate check 
is inside the timer function. So it seems incorrect to me.

I suggest trying the patch below.

It makes sure the buffer-local value of show-paren-mode is kept 
buffer-local even if it matches the global one (while it's = t), so that 
the later check

   (or (local-variable-p 'show-paren-mode)
       ;; If not, check that the predicate matches.
       (buffer-match-p show-paren-predicate (current-buffer)))

works correctly.

diff --git a/lisp/paren.el b/lisp/paren.el
index b2a79624c0f..437dc057c46 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -165,8 +165,8 @@ show-paren-local-mode
    (cond
     ((eq show-paren-mode (default-value 'show-paren-mode))
      (unless show-paren-mode
-      (show-paren--delete-overlays))
-    (kill-local-variable 'show-paren-mode))
+      (show-paren--delete-overlays)
+      (kill-local-variable 'show-paren-mode)))
     ((not (default-value 'show-paren-mode))
      ;; Locally enabled, but globally disabled.
      (show-paren-mode 1)                ; Setup the timer.