GNU bug report logs - #61098
29.0.60; Confusing behavior of show-paren-mode

Previous Next

Package: emacs;

Reported by: Rah Guzar <rahguzar <at> zohomail.eu>

Date: Fri, 27 Jan 2023 16:28:02 UTC

Severity: normal

Found in version 29.0.60

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Rah Guzar <rahguzar <at> zohomail.eu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 61098 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: bug#61098: 29.0.60; Confusing behavior of show-paren-mode
Date: Mon, 30 Jan 2023 20:21:33 +0100
Hi,
  Thanks for the patch, it works as you described.

However I have questions about the show-paren-predicate variable.

When I see its default value  (not (derived-mode . special-mode))
it makes me think there is some dsl involved. The customize interface
mentions Lisp Expression as a possibility but the documentation doesn't
explain what form this expression is supposed to take. This makes me
think that the default is just a pseudo sentence intended to convey
what it does and there are only three possibilities.

If the latter is correct, I think a simpler way would be to disable
the mode in the body of special-mode if the value of `show-paren-predicate`
demands it. I think this will get rid of the problem that the mode is
disabled the first time show-paren-local-mode is called.

I am using the equivalent of this which adds a hook to special-mode-hook
to achieve the outcome and I am pretty happy with it.

Thanks again,
Rahguzar


Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Fri, 27 Jan 2023 17:03:14 +0100
>> From:  Rah Guzar via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>>
>> Dear Emacs maintainers,
>>    After updating to Emacs 29, I saw in NEWS that show-paren-mode
>>    is no longer enabled in special-mode buffers. I think that is a
>>    welcome change. However in some cases (like reading the elisp
>>    manual) it is helpful to have it enabled. My impression after
>>    reading the NEWS entry, the manual entry for show-paren-mode
>>    and documentation for show-paren-local-mode was that I should
>>    be able to able to turn on show-paren-mode buffer locally by
>>
>>             M-x show-paren-local-mode RET
>>
>>     However this doesn't work and after much confusion I realized
>>     that calling show-paren-local-mode has effect only if I customize
>>     show-paren-predicate. My (incorrect) impression after reading
>>     the documentation was that show-paren-predicate determines only
>>     whether show-paren-mode is enabled in a buffer by default but
>>     doesn't prohibit the possibility of turning it off.
>
> Your impression was correct: there should be no need to customize
> show-paren-predicate to turn on show-paren-local-mode in a buffer that
> is under a descendant of special-mode.  The patch below fixes the bug
> and allows you to do what you want without messing with
> show-paren-predicate.
>
> However, there's one glitch: after applying the patch, when you invoke
>
>    M-x show-paren-local-mode RET
>
> in a special-mode buffer, it says the mode is _disabled_, and indeed
> disables the mode.  You need to enable it by invoking the same command
> again.
>
> I'm not sure I understand the reason, but it is probably related to
> the fact that we use the same show-paren-mode variable for the
> localized mode, and the default value of that variable is t.
>
> Stefan, can you help here? how do we make show-paren-local-mode be
> enabled when the user explicitly invokes it?
>
> Here's the patch I promised above:
>
> diff --git a/lisp/paren.el b/lisp/paren.el
> index b2a7962..de14de2 100644
> --- a/lisp/paren.el
> +++ b/lisp/paren.el
> @@ -167,8 +167,11 @@ show-paren-local-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.
> +   ((or
> +     ;; Locally enabled, but globally disabled.
> +     (not (default-value 'show-paren-mode))
> +     ;; Disabled by 'show-paren-predicate'.
> +     (not (buffer-match-p show-paren-predicate (current-buffer))))
>      (show-paren-mode 1)                ; Setup the timer.
>      (setq-default show-paren-mode nil) ; But keep it globally disabled.
>      )




This bug report was last modified 2 years and 164 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.