From: Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: arash@gnu.org, 71337@debbugs.gnu.org, joaotavora@gmail.com,
monnier@iro.umontreal.ca
Subject: bug#71337: 30.0.50; `electric-pair-mode' and custom keybinding
Date: Tue, 04 Jun 2024 12:09:09 +0200 [thread overview]
Message-ID: <87ikyp10l6.fsf@gmx.net> (raw)
In-Reply-To: <81C90874-2077-4358-A611-BDC94B98287E@gnu.org> (Eli Zaretskii's message of "Tue, 04 Jun 2024 12:24:59 +0300")
On Tue, 04 Jun 2024 12:24:59 +0300 Eli Zaretskii <eliz@gnu.org> wrote:
> On June 4, 2024 11:08:51 AM GMT+03:00, "João Távora" <joaotavora@gmail.com> wrote:
>> On Tue, Jun 4, 2024 at 8:37 AM João Távora <joaotavora@gmail.com> wrote:
>>
>> I've had a look. it looks like the problems is e-p-mode's assumption
>> that last-command-event is the thing to be inserted. The fact that
>> it isn't here (somehow an innocent 92 is now a monstrous 8388643),
>> triggers the problem (8388643 isn't a representation of a character,
>> apparently).
>>
>> But according to the docstring of post-self-insert-hook,
>> the assumption seems sane, and I probably coded for it.
>>
>> post-self-insert-hook is a variable defined in `src/cmds.c'.
>>
>> ...
>>
>> The hook can access the inserted character via `last-command-event'.
>> ...
>>
>> I don't think the patch is fully correct. I think Stefan is the right
>> person to call here. I've had an even briefer look at cmds.c and I
>> don't understand how that hook's promise is honoured.
>
>
> It looks like Arash made the mistake of being the first one, ever, of invoking
> self-insert-command from Lisp with 2nd arg non-nil, and turning on
> electric-pair-mode on top of that. When self-insert-command is called with 2
> args, it uses the 2nd arg as the character to insert, but it does NOT
> overwrite last-command-event with that character. So post-self-insert-hook
> sees the wrong event and rightfully barfs.
>
> Which means the patch proposed by Stephen is not TRT, because it means
> electric-pair-mode will ignore the inserted backslashes.
My patch should only make electric-pair-mode ignore key sequences which
don't satisfy characterp, e.g. "s-#" or "C-#". I just tested my patch
after giving ?\ open parenthesis syntax, binding it to "C-#" and
enabling electric-pair-mode, and what I see is that typing `C-#' inserts
a "\" while typing `\' insert "\\". Is this not the desired behavior?
(Of course, that doesn't means a lower-level change isn't preferable.)
Steve Berman
next prev parent reply other threads:[~2024-06-04 10:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-03 12:40 bug#71337: 30.0.50; `electric-pair-mode' and custom keybinding Arash Esbati
2024-06-03 13:50 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 5:53 ` Arash Esbati
2024-06-04 7:30 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 7:37 ` João Távora
2024-06-04 8:08 ` João Távora
2024-06-04 8:18 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 14:52 ` Eli Zaretskii
2024-06-04 9:24 ` Eli Zaretskii
2024-06-04 10:09 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-06-04 10:49 ` João Távora
2024-06-04 11:04 ` Eli Zaretskii
2024-06-04 14:56 ` Eli Zaretskii
2024-06-04 15:43 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 12:33 ` Arash Esbati
2024-06-04 13:36 ` João Távora
2024-06-04 14:09 ` Arash Esbati
2024-06-04 14:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-15 8:10 ` Eli Zaretskii
2024-06-16 10:42 ` Arash Esbati
2024-06-04 8:09 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ikyp10l6.fsf@gmx.net \
--to=bug-gnu-emacs@gnu.org \
--cc=71337@debbugs.gnu.org \
--cc=arash@gnu.org \
--cc=eliz@gnu.org \
--cc=joaotavora@gmail.com \
--cc=monnier@iro.umontreal.ca \
--cc=stephen.berman@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).