Subject: bug#74423: Low level key events

From: Cecilio Pardo <[email-masked]>
Date: Tue, 19 Nov 2024 21:05:06 +0100

On 19/11/2024 17:43, Stefan Monnier wrote:

>> +         ((functionp func) (funcall func))
>> +         ((eq 'hyper func)
>> +          (message "H-...")
>> +          (let ((r (read-event)))
>> +            (setq unread-command-events
>> +                  (list (event-apply-modifier
>> +                         r 'hyper 24 "H-"))))))))))
> 
> Move that code to a function, so you can get rid of this `hyper`
> special case.  BTW, any reason why you couldn't use
> `event-apply-hyper-modifier`?

No, no reason. I will change that.

> I think the list of low-level keys handled here should not be hard-coded.
> IOW, maybe `enable-low-level-keys` should not be a boolean but
> a list/map/table indicating which keys to handle.

I was sending the keys for which I have an immediate use case. Using a 
list looks got, adding some special symbols to choose groups, such as 
"all modifier keys".

> So, IIUC you might generate 2 low-level events for a single key press?
> Why?

We want to allow to detect modifier keys, regardless of the key that is 
used. For example, when you press Shift_L we generate an event for 
'lshift and other (of different type) for the modifier 'shift.

> Other note: in the distant past (back around Emacs-21) I seem to
> remember Gerd making changes to the event structure so as to avoid
> allocating Lisp objects for this code.  I think it was related to
> problems due to running this low-level event-handler code from within
> a C signal handler, which is a practice was have since stopped, luckily,
> but maybe there are still good reasons to try and avoid involving
> allocating objects into the Lisp heap in this low-level code.

I will look into this.

Thanks for your comments!