* doc/emacs/programs.texi (Matching): Mention the new user option.
* doc/misc/efaq.texi (Matching parentheses): Adjust text to the
current state of affairs.
* lisp/paren.el (show-paren-function): New user option (bug#50894).
(show-paren-mode): Mention it.
(show-paren-function): Use it.
or after a closing delimiter, the delimiter, its matching delimiter,
and optionally the text between them are highlighted. To toggle Show
Paren mode globally, type @kbd{M-x show-paren-mode}. To toggle it
-only in the current buffer, type @kbd{M-x show-paren-local-mode}. To
-customize it, type @w{@kbd{M-x customize-group @key{RET} paren-showing}}.
-The customizable options which control the operation of this mode
-include:
+only in the current buffer, type @kbd{M-x show-paren-local-mode}.
+
+@vindex show-paren-predicate
+ By default, this mode is switched on in all buffers that are meant
+for editing, but is not enabled in buffers that show data. This is
+controlled by the @code{show-paren-predicate} user option.
+
+ To customize the mode, type @w{@kbd{M-x customize-group @key{RET}
+paren-showing}}. The customizable options which control the operation
+of this mode include:
@itemize @bullet
@item
@cindex Pairs of parentheses, highlighting
@cindex Matching parentheses
-Call @code{show-paren-mode} in your init file (@pxref{Setting up a
-customization file}):
-
-@lisp
-(show-paren-mode 1)
-@end lisp
-
-You can also enable this mode by selecting the @samp{Paren Match
-Highlighting} option from the @samp{Options} menu of the Emacs menu bar
-at the top of any Emacs frame.
+By default, @code{show-paren-mode} is enabled in all editing buffers.
Alternatives to this mode include:
\f
* Incompatible changes in Emacs 29.1
+---
+*** 'show-paren-mode' is now disabled in 'special-mode' buffers.
+In Emacs versions previous to Emacs 28.1, 'show-paren-mode' defaulted
+off. In Emacs 28.1, the mode was switched on in all buffers. In
+Emacs 29.1, this was changed to be switched on in all editing-related
+buffers, but not in buffers that inherit from 'special-mode'. To get
+back to how things worked in Emacs 28.1, put the following in your
+init file:
+
+ (setopt show-paren-predicate t)
+
+++
*** Explicitly-set read-only state is preserved when reverting a buffer.
If you use the 'C-x C-q' command to change the read-only state of the
(let ((ol (make-overlay (point) (point) nil t))) (delete-overlay ol) ol)
"Overlay used to highlight the paren at point.")
+(defcustom show-paren-predicate '(not (derived-mode . special-mode))
+ "Whether to use `show-paren-mode' in a buffer.
+The default is to enable the mode in all buffers that have don't
+derive from `special-mode', which means that it's on (by default)
+in all editing buffers."
+ :type 'sexp
+ :safe #'booleanp
+ :version "29.1")
;;;###autoload
(define-minor-mode show-paren-mode
When enabled, any matching parenthesis is highlighted in `show-paren-style'
after `show-paren-delay' seconds of Emacs idle time.
+Also see `show-paren-predicate', which controls which buffers
+this mode is enabled in.
+
This is a global minor mode. To toggle the mode in a single buffer,
use `show-paren-local-mode'."
:global t :group 'paren-showing
(defun show-paren-function ()
"Highlight the parentheses until the next input arrives."
- (let ((data (and show-paren-mode (funcall show-paren-data-function))))
+ (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)))
+ (funcall show-paren-data-function))))
(if (not data)
(progn
;; If show-paren-mode is nil in this buffer or if not at a paren that