New minor mode 'show-paren-local-mode'
* lisp/paren.el (show-paren--delete-overlays): New function, extracted from show-paren-mode. (show-paren-local-mode): New minor mode. (show-paren-mode): Update docstring to mention it (bug#29381). * doc/emacs/programs.texi (Matching): Update show-paren-mode section.
This commit is contained in:
parent
5c18d35acb
commit
d37dcfa30f
3 changed files with 33 additions and 6 deletions
|
@ -813,7 +813,8 @@ displayed. The default is 102400.
|
|||
of automatic matching. Whenever point is before an opening delimiter
|
||||
or after a closing delimiter, the delimiter, its matching delimiter,
|
||||
and optionally the text between them are highlighted. To toggle Show
|
||||
Paren mode, type @kbd{M-x show-paren-mode}. To customize it, type
|
||||
Paren mode, type @kbd{M-x show-paren-mode}. To toggle it in single
|
||||
buffer, type @kbd{M-x show-paren-local-mode}. To customize it, type
|
||||
@kbd{M-x customize-group @key{RET} paren-showing}. The customizable
|
||||
options which control the operation of this mode include:
|
||||
|
||||
|
|
4
etc/NEWS
4
etc/NEWS
|
@ -983,6 +983,10 @@ achieve that.
|
|||
It used to be enabled when Emacs is started in GUI mode but not when started
|
||||
in text mode. The cursor still only actually blinks in GUI frames.
|
||||
|
||||
** New minor mode 'show-paren-local-mode'.
|
||||
It serves as a local counterpart for 'show-paren-mode', allowing you
|
||||
to toggle it separately in different buffers.
|
||||
|
||||
|
||||
* Changes in Specialized Modes and Packages in Emacs 28.1
|
||||
|
||||
|
|
|
@ -101,9 +101,11 @@ its position."
|
|||
(define-minor-mode show-paren-mode
|
||||
"Toggle visualization of matching parens (Show Paren mode).
|
||||
|
||||
Show Paren mode is a global minor mode. When enabled, any
|
||||
matching parenthesis is highlighted in `show-paren-style' after
|
||||
`show-paren-delay' seconds of Emacs idle time."
|
||||
When enabled, any matching parenthesis is highlighted in `show-paren-style'
|
||||
after `show-paren-delay' seconds of Emacs idle time.
|
||||
|
||||
This is a global minor mode. To toggle the mode in a single buffer,
|
||||
use `show-paren-local-mode'."
|
||||
:global t :group 'paren-showing
|
||||
;; Enable or disable the mechanism.
|
||||
;; First get rid of the old idle timer.
|
||||
|
@ -114,8 +116,28 @@ matching parenthesis is highlighted in `show-paren-style' after
|
|||
show-paren-delay t
|
||||
#'show-paren-function))
|
||||
(unless show-paren-mode
|
||||
(delete-overlay show-paren--overlay)
|
||||
(delete-overlay show-paren--overlay-1)))
|
||||
(show-paren--delete-overlays)))
|
||||
|
||||
(defun show-paren--delete-overlays ()
|
||||
(delete-overlay show-paren--overlay)
|
||||
(delete-overlay show-paren--overlay-1))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode show-paren-local-mode
|
||||
"Toggle `show-paren-mode' only in this buffer."
|
||||
:variable (buffer-local-value 'show-paren-mode (current-buffer))
|
||||
(cond
|
||||
((eq show-paren-mode (default-value 'show-paren-mode))
|
||||
(unless 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.
|
||||
(setq-default show-paren-mode nil) ; But keep it globally disabled.
|
||||
)
|
||||
(t ;; Locally disabled only.
|
||||
(show-paren--delete-overlays))))
|
||||
|
||||
(defun show-paren--unescaped-p (pos)
|
||||
"Determine whether the paren after POS is unescaped."
|
||||
|
|
Loading…
Add table
Reference in a new issue