GNU bug report logs - #79047
Add some multi-character pairs to some major modes.

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Sat, 19 Jul 2025 02:05:02 UTC

Severity: normal

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

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 79047 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, jm <at> pub.pink, eg642616 <at> gmail.com
Subject: bug#79047: Add some multi-character pairs to some major modes.
Date: Thu, 24 Jul 2025 13:02:13 -0400
> As a workaround, I bind post-self-insert-hook to nil around the call to
> self-insert-command, this being the only way I know to get predictable
> functionality from self-insert-command.

"predictable functionality" and `self-insert-command` don't get along
very well, I'm afraid (e.g. because of `auto-fill-chars` and abbrev
expansion).

Part of the problem is fundamental, I think: when several forms of
electricity want to affect the same key, there is inevitably some
delicate issues that require them to cooperate to some extent.
It's hard to make them work together peacefully *and* modularily at the
same time.

> The error here is that post-self-insert-hook is invoked from the middle
> of the command using self-insert-function, rather than after its end.
> One way of fixing this would be to put
> electric-pair-post-self-insert-function on post-command-hook instead.

That tends to move the problem: it would be your code which risks
breaking the others, rather than other way around.

I don't have a solution which I would call "good", but the best we have
so far is to get rid of the `c-electric-paren` command and turn it into
a hook added to `post-self-insert-hook` instead.  This will let you use
the DEPTH argument of `add-hook` to control when it is run w.r.t to the
other hooks.

That's what the other `electric-FOO-mode` do to cohabit.


        Stefan





This bug report was last modified 1 day ago.

Previous Next


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