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: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: rahguzar <at> zohomail.eu, dgutov <at> yandex.ru, 61098 <at> debbugs.gnu.org
Subject: bug#61098: 29.0.60; Confusing behavior of show-paren-mode
Date: Wed, 01 Feb 2023 19:48:11 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Rah Guzar <rahguzar <at> zohomail.eu>,  61098 <at> debbugs.gnu.org
> Date: Tue, 31 Jan 2023 17:42:09 -0500
> 
> > I'm still waiting for Stefan to help me understand why after that
> > patch "M-x show-paren-local-mode" _disables_ the mode rather than
> > enabling it.  Stefan, any wisdom?
> 
> Not sure.  I don't quite understand how your patch intends to work.
> >From where I sit I get the impression that it will result in an
> inconsistent state in various "corner" cases.
> 
> Dmitry's patch seems closer to my intuition (I might even suggest
> removing the `kill-local-variable` altogether).

I guess I don't understand what show-paren-local-mode does, then.  Let
me explain my line of reasoning:

  (define-minor-mode show-paren-local-mode
    "Toggle `show-paren-mode' only in this buffer."
    :variable ( show-paren-mode .
		(lambda (val) (setq-local show-paren-mode val)))
    (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))))

When I looked at the above function and stepped through it in the OP's
scenario, what I saw was that the 2nd condition of 'cond' doesn't
fire, because the default-value of show-paren-mode is t nowadays.  So
I concluded that this code relies on the mode being globally off by
default, and attempted to fix the condition that turns the mode on
locally even though it is on globally.

The predicate used by the timer requires either a match of the buffer
(which doesn't happen in this case) or that the local value of
show-paren-mode is non-nil.  Setting the local value non-nil is the
job of the mode function, isn't it?  So I tried to get the mode
function do its job in this scenario.

What Dmitry's patch does, and why it is supposed to fix this, I simply
don't understand, perhaps for the same reason that I misinterpret what
the mode function does.




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.