emacs-diffs
[Top][All Lists]
Advanced

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

master 9474ac1b61: Default show-paren-mode to off in special-mode buffer


From: Lars Ingebrigtsen
Subject: master 9474ac1b61: Default show-paren-mode to off in special-mode buffers
Date: Fri, 2 Sep 2022 08:23:29 -0400 (EDT)

branch: master
commit 9474ac1b61935b198a2cf252e7b0ec9cfa70344e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Default show-paren-mode to off in special-mode buffers
    
    * 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.
---
 doc/emacs/programs.texi | 14 ++++++++++----
 doc/misc/efaq.texi      | 11 +----------
 etc/NEWS                | 11 +++++++++++
 lisp/paren.el           | 19 ++++++++++++++++++-
 4 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi
index 795aabee74..b87c659483 100644
--- a/doc/emacs/programs.texi
+++ b/doc/emacs/programs.texi
@@ -834,10 +834,16 @@ 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 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
diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi
index 43fa005434..8ec23a529d 100644
--- a/doc/misc/efaq.texi
+++ b/doc/misc/efaq.texi
@@ -2364,16 +2364,7 @@ new paragraph.  There are many packages available to 
deal with this
 @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:
 
diff --git a/etc/NEWS b/etc/NEWS
index 89f4cd0ac7..1512d45fdc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -162,6 +162,17 @@ of 'user-emacs-directory'.
 
 * 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
diff --git a/lisp/paren.el b/lisp/paren.el
index d7580de9a9..13e219c8f6 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -118,6 +118,14 @@ On non-graphical frames, the context is shown in the echo 
area."
   (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
@@ -126,6 +134,9 @@ On non-graphical frames, the context is shown in the echo 
area."
 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
@@ -414,7 +425,13 @@ It is the default value of `show-paren-data-function'."
 
 (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]