unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29381: show-paren-mode should not be globalized
@ 2017-11-21 10:28 Paul Rankin
  2017-11-21 10:36 ` Andreas Schwab
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Rankin @ 2017-11-21 10:28 UTC (permalink / raw)
  To: 29381

show-paren-mode is only relevant to buffers displaying code.

As a text editor, not all Emacs buffers will be code.

Therefore show-paren-mode should not be globalized minor mode.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2017-11-21 10:36 UTC (permalink / raw)
  To: Paul Rankin; +Cc: 29381

On Nov 21 2017, Paul Rankin <hello@paulwrankin.com> wrote:

> show-paren-mode is only relevant to buffers displaying code.

I disagree.  Plain text also uses balanced parens (like this).

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  2017-11-21 10:36 ` Andreas Schwab
@ 2017-11-21 10:45   ` Paul Rankin
  2020-08-10 16:14     ` Stefan Kangas
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Rankin @ 2017-11-21 10:45 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 29381

On Tue, 21 Nov 2017, at 08:36 PM, Andreas Schwab wrote:
> On Nov 21 2017, Paul Rankin <hello@paulwrankin.com> wrote:
>
> > show-paren-mode is only relevant to buffers displaying code.
>
> I disagree.  Plain text also uses balanced parens (like this).

Luckily we don’t need agreement, given that the solution is only to make
the mode non-global, which will allow user preference, similar to minor
modes that are only relevant to non-code text, e.g. visual-line-mode.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  2017-11-21 10:45   ` Paul Rankin
@ 2020-08-10 16:14     ` Stefan Kangas
  2020-08-12 13:14       ` Phil Sainty
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2020-08-10 16:14 UTC (permalink / raw)
  To: Paul Rankin; +Cc: 29381, Andreas Schwab

Paul Rankin <hello@paulwrankin.com> writes:

> On Tue, 21 Nov 2017, at 08:36 PM, Andreas Schwab wrote:
>> On Nov 21 2017, Paul Rankin <hello@paulwrankin.com> wrote:
>>
>> > show-paren-mode is only relevant to buffers displaying code.
>>
>> I disagree.  Plain text also uses balanced parens (like this).
>
> Luckily we don’t need agreement, given that the solution is only to make
> the mode non-global, which will allow user preference, similar to minor
> modes that are only relevant to non-code text, e.g. visual-line-mode.

I don't see any benefit to doing that. But if someone wants to do it,
IMO it should be a _new_ minor mode and not a change to the existing
one.

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  2020-08-10 16:14     ` Stefan Kangas
@ 2020-08-12 13:14       ` Phil Sainty
  2021-09-03  6:58         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Phil Sainty @ 2020-08-12 13:14 UTC (permalink / raw)
  To: Paul Rankin; +Cc: 29381, Andreas Schwab, Stefan Kangas

Note that show-paren-mode is not "globalized"; it is simply a
global minor mode.  If it was a globalized mode, then there would
(necessarily) be a buffer-local mode already.

Changing it to a globalized mode would actually be a possible
solution to your issue, as you could then provide a way for the
user to determine whether or not the buffer-local mode was enabled
for any given buffer.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-03  6:58 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 29381, Andreas Schwab, Paul Rankin, Stefan Kangas

Phil Sainty <psainty@orcon.net.nz> writes:

> Note that show-paren-mode is not "globalized"; it is simply a
> global minor mode.  If it was a globalized mode, then there would
> (necessarily) be a buffer-local mode already.
>
> Changing it to a globalized mode would actually be a possible
> solution to your issue, as you could then provide a way for the
> user to determine whether or not the buffer-local mode was enabled
> for any given buffer.

Well...  if the user wants the mode disabled in some mode, the user can
say (setq-local show-paren-mode nil) in the hook for the mode.  (And can
check whether it's enabled by just looking at that variable.)

On the other hand, it'd make the mode more regular -- perhaps the user
just wants to switch it on in just a particular buffer.

But we can't really change the names of the global(ized) version of the
mode, because that'd break people's setups.  So instead of having a
global-show-paren-mode/show-paren-mode, we'd have
show-paren-mode/show-parent-mode-this-buffer (or something), which is
also pretty confusing.

So taking all that into consideration, I think it'd better to just leave
things as they are, and I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Paul W. Rankin via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-09-03  7:26 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Phil Sainty, 29381, Stefan Kangas, Andreas Schwab


On 2021-09-03 16:58, Lars Ingebrigtsen wrote:
> 
> But we can't really change the names of the global(ized) version of the
> mode, because that'd break people's setups.  So instead of having a
> global-show-paren-mode/show-paren-mode, we'd have
> show-paren-mode/show-parent-mode-this-buffer (or something), which is
> also pretty confusing.
> 
> So taking all that into consideration, I think it'd better to just 
> leave
> things as they are, and I'm closing this bug report.

There are plenty of minor modes that use FOO-mode (global) and 
FOO-local-mode but on the other hand I must recognise your straw man. 
Tally another up for your stats Lars!





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-03  7:50 UTC (permalink / raw)
  To: Paul W. Rankin; +Cc: Phil Sainty, 29381, Stefan Kangas, Andreas Schwab

"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.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  2021-09-03  7:50             ` Lars Ingebrigtsen
@ 2021-09-09 23:57               ` Dmitry Gutov
  2021-09-10 10:52                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Gutov @ 2021-09-09 23:57 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Paul W. Rankin
  Cc: Phil Sainty, 29381, Stefan Kangas, Andreas Schwab

[-- 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."

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  2021-09-09 23:57               ` Dmitry Gutov
@ 2021-09-10 10:52                 ` Lars Ingebrigtsen
  2021-09-11  2:15                   ` Dmitry Gutov
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-10 10:52 UTC (permalink / raw)
  To: Dmitry Gutov
  Cc: Phil Sainty, 29381, Paul W. Rankin, Stefan Kangas, Andreas Schwab

Dmitry Gutov <dgutov@yandex.ru> writes:

> Here's a patch, modeled after electric-indent-local-mode.

Haven't tried it, but it looks good to me.  It should probably be paired
with a mention from `show-paren-mode' to say the -local-mode should be
used to switch show-paren-mode off in specific buffers (and the same in
the manual).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  2021-09-10 10:52                 ` Lars Ingebrigtsen
@ 2021-09-11  2:15                   ` Dmitry Gutov
  2021-09-11 12:43                     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Gutov @ 2021-09-11  2:15 UTC (permalink / raw)
  To: Lars Ingebrigtsen
  Cc: Phil Sainty, 29381-done, Paul W. Rankin, Stefan Kangas,
	Andreas Schwab

On 10.09.2021 13:52, Lars Ingebrigtsen wrote:
> Dmitry Gutov <dgutov@yandex.ru> writes:
> 
>> Here's a patch, modeled after electric-indent-local-mode.
> 
> Haven't tried it, but it looks good to me.  It should probably be paired
> with a mention from `show-paren-mode' to say the -local-mode should be
> used to switch show-paren-mode off in specific buffers (and the same in
> the manual).

Makes sense.

I've pushed the change, and with this, I'm now closing the bug.

Please report if anything's still missing, of course.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#29381: show-paren-mode should not be globalized
  2021-09-11  2:15                   ` Dmitry Gutov
@ 2021-09-11 12:43                     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-11 12:43 UTC (permalink / raw)
  To: Dmitry Gutov
  Cc: Phil Sainty, 29381-done, Paul W. Rankin, Stefan Kangas,
	Andreas Schwab

Dmitry Gutov <dgutov@yandex.ru> writes:

> Makes sense.
>
> I've pushed the change, and with this, I'm now closing the bug.

Thanks; looks good to me.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-09-11 12:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-09-10 10:52                 ` Lars Ingebrigtsen
2021-09-11  2:15                   ` Dmitry Gutov
2021-09-11 12:43                     ` Lars Ingebrigtsen

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).