bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71337: 30.0.50; `electric-pair-mode' and custom keybinding


From: Stephen Berman
Subject: bug#71337: 30.0.50; `electric-pair-mode' and custom keybinding
Date: Tue, 04 Jun 2024 12:09:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]