unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Run `C-x C-e' on (self-insert-command 1) and (this-command-keys).
@ 2021-10-21  6:22 Hongyi Zhao
  2021-10-21 14:28 ` Michael Heerdegen
  0 siblings, 1 reply; 3+ messages in thread
From: Hongyi Zhao @ 2021-10-21  6:22 UTC (permalink / raw)
  To: help-gnu-emacs

`C-x C-e (this-command-keys)' will give the following in *Messages* buffer:

"  ^X^E "

`C-x C-e (self-insert-command 1)' will give the following in-situ:

(self-insert-command 1)^E

But why doesn't it give the following:

(self-insert-command 1)^X^E

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Run `C-x C-e' on (self-insert-command 1) and (this-command-keys).
  2021-10-21  6:22 Run `C-x C-e' on (self-insert-command 1) and (this-command-keys) Hongyi Zhao
@ 2021-10-21 14:28 ` Michael Heerdegen
  2021-10-21 19:49   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Heerdegen @ 2021-10-21 14:28 UTC (permalink / raw)
  To: help-gnu-emacs

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.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Run `C-x C-e' on (self-insert-command 1) and (this-command-keys).
  2021-10-21 14:28 ` Michael Heerdegen
@ 2021-10-21 19:49   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 3+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-21 19:49 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

> 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.

If everyone did it it would be a problem but if one does it it
is an asset ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-21 19:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-21  6:22 Run `C-x C-e' on (self-insert-command 1) and (this-command-keys) Hongyi Zhao
2021-10-21 14:28 ` Michael Heerdegen
2021-10-21 19:49   ` Emanuel Berg via Users list for the GNU Emacs text editor

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).