GNU bug report logs - #38406
27.0.50; post-self-insert-hook does not hold its contract in cc-mode derived modes

Previous Next

Package: emacs;

Reported by: yyoncho <yyoncho <at> gmail.com>

Date: Wed, 27 Nov 2019 20:01:01 UTC

Severity: normal

Found in version 27.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #77 received at 38406 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yyoncho <at> gmail.com, 38406 <at> debbugs.gnu.org
Subject: Re: bug#38406: 27.0.50; post-self-insert-hook does not hold its
 contract in cc-mode derived modes
Date: Fri, 6 Dec 2019 22:24:59 +0000
Hello, Eli.

On Fri, Dec 06, 2019 at 20:48:26 +0200, Eli Zaretskii wrote:
> > Date: Fri, 6 Dec 2019 18:28:42 +0000
> > Cc: yyoncho <at> gmail.com, 38406 <at> debbugs.gnu.org
> > From: Alan Mackenzie <acm <at> muc.de>

> > > There might be a misunderstanding on my part here.  Could you please
> > > explain how come electric-pair-post-self-insert-function is called
> > > twice if it isn't removed from the hook? where's the second (or the
> > > first) call?

> > The first call is an explicit call from c-electric-brace to
> > electric-pair-post-self-insert-function.  Depending on the changes to the
> > buffer this call causes (amongst other things), differing electric
> > actions are performed by c-electric-brace.  This call is itself a
> > workaround, there being no purpose designed function for this purpose in
> > elec-pair.el.

> > The second call happens when c-electric-brace run-hook's
> > post-self-insert-hook - _if_ electric-pair-post-self-insert-function
> > hasn't been filtered out of that hook.

> If you already call that particular function explicitly, then calling
> it one more time is indeed redundant.

No, it's not redundant.  It's positively harmful.

> But is this the case with all the other functions that you suggest to
> filter from post-self-insert-hook?

No.  They have individual reasons for being filtered out.  Don't forget
that this is a particularly sensitive hook, allowing hook functions to
interfere in an unsynchronised way with partially complete command
processing.

Let's go through them again:

  smie-blink-matching-open is inapplicable to CC Mode and just takes up
  processor cycles.

  electric-pair-post-self-insert-function we've already discussed.

  blink-paren-post-self-insert-function would do nothing anyhow, since
  blink-paren-function has been bound to nil - this is so that the actual
  blinking doesn't occur until the newly inserted brace is at its final
  position.

  electric-indent-post-self-insert-function is redundant and possibly
  harmful.

  electric-layout-post-self-insert-function is undocumented, thus likely
  to be harmful.  Its name suggests it is redundant.

  electric-quote-post-self-insert-function is undocumented, uncommented
  and obscure.  It is safer not to risk running it.

Given that the mechanism for filtering post-self-insert-hook is there,
why is there the resistance to filtering out redundant and effect-free
functions?

And how come functions without meaningful doc strings are allowed onto
Emacs hooks?

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 5 years and 168 days ago.

Previous Next


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