From: Dmitry Gutov <dgutov@yandex.ru>
To: Lars Ingebrigtsen <larsi@gnus.org>, "Paul W. Rankin" <pwr@bydasein.com>
Cc: Phil Sainty <psainty@orcon.net.nz>,
29381@debbugs.gnu.org, Stefan Kangas <stefan@marxist.se>,
Andreas Schwab <schwab@suse.de>
Subject: bug#29381: show-paren-mode should not be globalized
Date: Fri, 10 Sep 2021 02:57:43 +0300 [thread overview]
Message-ID: <619d681e-d286-25ab-4ee3-913c473339da@yandex.ru> (raw)
In-Reply-To: <87fsum2j4j.fsf@gnus.org>
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
On 03.09.2021 10:50, Lars Ingebrigtsen wrote:
> "Paul W. Rankin"<pwr@bydasein.com> writes:
>
>> There are plenty of minor modes that use FOO-mode (global) and
>> FOO-local-mode
> That's a good point; didn't know that. Perhaps we should flip this
> around as suggested, then, and I'm reopening this bug report.
Here's a patch, modeled after electric-indent-local-mode.
[-- Attachment #2: show-paren-local-mode.diff --]
[-- Type: text/x-patch, Size: 1299 bytes --]
diff --git a/lisp/paren.el b/lisp/paren.el
index a45a08abd3..5c3c85828b 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -114,8 +114,28 @@ show-paren-mode
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."
next prev parent reply other threads:[~2021-09-09 23:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 10:28 bug#29381: show-paren-mode should not be globalized Paul Rankin
2017-11-21 10:36 ` Andreas Schwab
2017-11-21 10:45 ` Paul Rankin
2020-08-10 16:14 ` Stefan Kangas
2020-08-12 13:14 ` Phil Sainty
2021-09-03 6:58 ` Lars Ingebrigtsen
2021-09-03 7:26 ` Paul W. Rankin via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-03 7:50 ` Lars Ingebrigtsen
2021-09-09 23:57 ` Dmitry Gutov [this message]
2021-09-10 10:52 ` Lars Ingebrigtsen
2021-09-11 2:15 ` Dmitry Gutov
2021-09-11 12:43 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=619d681e-d286-25ab-4ee3-913c473339da@yandex.ru \
--to=dgutov@yandex.ru \
--cc=29381@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=psainty@orcon.net.nz \
--cc=pwr@bydasein.com \
--cc=schwab@suse.de \
--cc=stefan@marxist.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).