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

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

Re: Run `C-x C-e' on (self-insert-command 1) and (this-command-keys).


From: Michael Heerdegen
Subject: Re: Run `C-x C-e' on (self-insert-command 1) and (this-command-keys).
Date: Thu, 21 Oct 2021 16:28:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> (self-insert-command 1)^E
>
> But why doesn't it give the following:
>
> (self-insert-command 1)^X^E

This question is a bit like "I drove my car into a lake and it drowned -
why was it designed to do that?".  It is not a silly question, but most
drivers don't try and also don't ask.

Ok.  `self-insert-command' is a command to insert the character a key
corresponds to - "Insert the character you type." (from the docstring).
It operates on the level of single (key) events, not key sequences.

So instead of binding a complete key sequence Z h a o to
`self-insert-command', so that when you have finished typing those keys
Emacs would insert "Zhao", each of the individual letter keys are just
bound to `self-insert-command'.  The command is intended to be bound to
keys.

In that way this command kind of an exception.  For more see the
implementation: it just looks at the last event.

Michael.




reply via email to

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