diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2023-02-05 21:07:45 +0200 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2023-02-05 21:08:45 +0200 |
commit | 793c24a6ac72aada1981907185dbfbf6e82a0124 (patch) | |
tree | f90664a8f169d6a6f59ec7f0c6be4a18733d13b6 | |
parent | 60089dcfe06c64ff75d14f042fda1b052d0bad69 (diff) | |
download | emacs-793c24a6ac72aada1981907185dbfbf6e82a0124.tar.gz |
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).
-rw-r--r-- | lisp/paren.el | 20 |
1 files changed, 12 insertions, 8 deletions
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 @@ 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 |