emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] master 5b5f441: read_key_sequence: correct the handlin


From: Stefan Monnier
Subject: Re: [Emacs-diffs] master 5b5f441: read_key_sequence: correct the handling of raw_keybuf in recursive calls
Date: Mon, 20 Nov 2017 16:43:52 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> But this `read_char` is within read_key_sequence: this read_key_sequence
>> may have been called from anywhere, ....
> read_key_sequence is static in keyboard.c, and is called from precisely
> three places: command_loop_1, read_key_sequence_vs, and
> read_menu_command.

Right: the middle one corresponds to `read-key-sequence` which can be
called from "anywhere" (i.e. Elisp).

>> .... so after we exit it (non-locally), we may end up running
>> arbitrary Elisp code before we return to command_loop_1, can't we?
> Is it possible to exit non-locally from read_char (or one of its called
> subroutines)?

`read_char` will run timers and process filters.
See for example `read-key` which calls `read-key-sequence` with a timer
that makes it exit by throwing `read-key` as soon as one key is detected.

> You have a point, here.  Perhaps it would be better to get storage from
> the Emacs heap rather than using the stack.

I like using the stack, here, actually.

Maybe another option is to make raw_keybuf local to read_key_sequence,
and to *copy* it into the global raw_keybuf_buffer just before exiting.


        Stefan


PS: Of course, even better would be to provide another way to get what
`this-single-command-raw-keys` returns, so we don't need to use a global
variable for it.  E.g. have `read-key-sequence` return both the key
sequence and the raw key sequence.  But we'd still have to support
`this-single-command-raw-keys` for the foreseeable future anyway.




reply via email to

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