emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 793c24a6ac: Make sure 'M-x show-paren-local-mode' turns on righ


From: Dmitry Gutov
Subject: emacs-29 793c24a6ac: Make sure 'M-x show-paren-local-mode' turns on right away
Date: Sun, 5 Feb 2023 14:08:56 -0500 (EST)

branch: emacs-29
commit 793c24a6ac72aada1981907185dbfbf6e82a0124
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Make sure 'M-x show-paren-local-mode' turns on right away
    
    * lisp/paren.el (show-paren--enabled-p): Extract from
    'show-paren-function'.
    (show-paren-local-mode): Use it in the :variable getter (bug#61098).
---
 lisp/paren.el | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/lisp/paren.el b/lisp/paren.el
index 7ee4e9ae68..4c91fd2949 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -161,8 +161,9 @@ use `show-paren-local-mode'."
 ;;;###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 @@ It is the default value of `show-paren-data-function'."
 ;; `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]