GNU bug report logs -
#38406
27.0.50; post-self-insert-hook does not hold its contract in cc-mode derived modes
Previous Next
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 #35 received at 38406 <at> debbugs.gnu.org (full text, mbox):
Hello, Eli.
On Sun, Dec 01, 2019 at 22:47:01 +0200, Eli Zaretskii wrote:
> > Date: Sun, 1 Dec 2019 19:27:09 +0000
> > Cc: yyoncho <at> gmail.com, 38406 <at> debbugs.gnu.org
> > From: Alan Mackenzie <acm <at> muc.de>
> > post-self-insert-hook's functions, unusually amongs hooks, interfere
> > with its triggering event. This contrasts with, say,
> > after-change-functions, where the functions don't insert into or
> > delete from the buffer, or pre-redisplay-functions, where the
> > functions don't try to prevent a particular window getting
> > displayed.
> You'd be surprised to know what some of those hooks do. Everything
> you say they don't, and then some.
Any chance you could name one (or even two), thus letting me see for
myself?
> There's nothing we can do to prevent people from shooting themselves
> in the foot or hanging themselves with the rope we provided.
In the case of post-self-insert-hook, the damaging functions are part of
Emacs itself, not crazy user-written code.
> And if you think you are the only one who needs to harden your code to
> let people do the craziest things with these hooks, please don't think
> so: you are definitely not alone.
OK.
> But breaking a hook's contract as a means to teach people not to shoot
> themselves in the foot is not right. If the uses are legitimate, they
> should be able to do them; if they aren't, let them cope with the
> consequences.
> > So to call this hook at the end of c-electric-brace would mean having to
> > filter the hook first (at the very least, to remove
> > electric-pair-post-self-insert-function), which just seems very hackish
> > and unsatisfactory.
> It doesn't seem too hackish to me, and as a nice bonus we will have
> post-self-insert-hook act as per its contract again.
> So could you please do that? TIA.
OK, I'll do that. It's not a nice thing to do, but we're kind of
lacking nice things in this situation. Give me a few days, please - I'm
a touch busy in RL at the moment.
Additionally, how about reversing the encouragement in the Elisp manual
to put buffer changing functions onto post-self-insert-hook?
--
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.