From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Cecilio Pardo <cpardo@imayhem.com>
Cc: luangruo@yahoo.com, 74423@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
Subject: bug#74423: Low level key events
Date: Fri, 03 Jan 2025 23:55:49 -0500 [thread overview]
Message-ID: <jwvpll3jlft.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <e8833e75-c05f-43e2-81b4-464b9236211d@imayhem.com> (Cecilio Pardo's message of "Thu, 2 Jan 2025 16:42:34 +0100")
> In this new version I changed the way events are handled.
> Now llk-handle generates input events to be used with normal
> keymaps, instead of running a command. The function llk-bind
> activates event generation for a key and a combination of
> events press, release, double, triple.
I really like what I see. As I think I mentioned, I had made a related
effort in local patches, but I couldn't figure out back then how to make
the low-level events useful.
I wouldn't be surprised if such low-level events remain limited in their
use, but I suspect that some specific uses of them could become very
popular.
I haven't seen many opinions of late on your code (other than my
own), sadly. I think we need some more reviewers here.
> You suggested to auto generate the keysym table, but we
> would still need a table to relate the Windows keys to the X
> equivalent.
I don't doubt some part has to be done manually, but I think we should
strive to make it via code as much as possible.
E.g. on each platform we should try to provide a programmatic way to map
the integer key to/from a meaningful system-specific string or symbol
(at least, to the extent that the underlying system provides such
a functionality).
Mapping between those symbols in different systems will likely be (at
least partly) manual, inevitably, but I'm hoping this can be
significantly smaller (especially I'm hoping we can "align" the
system-specific symbols such that many are already identical between the
different systems).
Finally it's not 100% indispensable to have unified symbols that work
identically on all systems: users could also just use the system-specific
names. They'd need a mapping between them only for code/configuration
that is used with different systems. So it's only really important when
those names start to be used in libraries.
> +@cindex @code{low-level-key} event
> +@item (low-level-key @var{is-key-press} @var{key} @var{modifier} @var{time} @var{frame})
> +This event is sent on the physical press or release of keys, only on
> +systems where it is supported, currently X, MS-Windows and PGTK, and
> +only if the variable @code{enable-low-level-key-events} has a
> +non-@code{nil} value. See its documentation for the values to use, that
> +can activate the events for all or some keys.
> +
> +@var{is-key-press} is @code{t} for a key press, @code{nil} for a key
> +release. @var{time} is the event's time in milliseconds, as reported by
> +the underlying platform, and should only be used to measure time
> +intervals between events of this same kind.
[ This made me wonder if those timestamps can be compared between
events coming from different X11 servers. ]
> @var{frame} is the frame +receiving the event.
Any chance this could be changed to a window?
[ What does it even mean?
Usually we associate keyboard events with the `window-point` of the
currently selected window (and they don't come with the information
attached), whereas we associated mouse events with the
position of the mouse cursor.
But when I do `down-meta down-mouse-1 up-mouse-1 up-meta` to generate
a `M-mouse-1` event, the events on the `meta` key end up associated
with the position of the mouse cursor even tho they come from
the keyboard. ]
> @var{modifier} is @code{nil} if the key is not a
> +modifier key, @code{t} if it is, but it is unknown which one, or one of
> +@code{shift}, @code{control}, @code{meta}, @code{alt}, @code{super},
> +@code{hyper}.
In the docstring you mention that PGTK can't distinguish modifiers.
It would be useful here to mention here also the kinds of reasons why we
might get just `t`: can it happen for some keys and not others, or is it
the case for all the events of a given kind of terminal?
> Loading @file{low-level-key.el} sets a handler
> +that can generate normal input events for key press, release and multi
> +tap. See the function @code{llk-bind}.
Any other ELisp code could do a similar task, tho. So, I'd probably
present it a bit differently, like:
Because generating these events for all keys would interfere with
normal keyboard input, they are by default filtered out by a binding in
`special-event-map`.
@file{low-level-key.el} is a package that lets you configure
which of those events to turn into normal input events. It is also
able to recognize some specific patterns such a (multi) taps.
[ BTW, you might like to explain what is a (multi) tap here, as well. ]
> +(cl-defstruct (low-level-key (:type list))
I recommend you add `(:constructor nil)` and `(:copier nil)` so the
macro doesn't auto-define `make-low-level-key` and
`copy-low-level-key` functions.
> +(defvar llk-bindings nil
> + "List of bindings for low level key events (press/release/tap).
> +Use the `llk-bind' function to add bindings. See its documentation for
> +a description of the binding information.")
[ Seeing how it's used, I suggest you use a hash-table instead of
a list. ]
> +EVENTS are symbols that activate one event. Possible values are `press',
> +`release', `double' and `triple'.
Any reason why there isn't an option to emit an event for a single
press+release?
> + (llk-bind xk-shift-l \\='double)
> +
> +will generate the event `double-xk-shift-l', than can be bound to a
> +command with:
AFAICT the event will be named `double-key-xk-shift-l`.
Did I miss something?
[ I like this "key-" in the event name, FWIW, so I suggest to keep the
code but fix the doc rather than the reverse. Tho, if we can drop
the `xk-`, I'd be happier yet.
Maybe the generated event names should have "llk-" in them
instead of "key-". ]
> +(defun describe-low-level-key ()
> + "Wait for key press and describe the low-level key event it generates."
> + (interactive)
> + (define-key special-event-map [low-level-key] 'llk--describe))
This is brittle. I don't really have a better suggestion, sadly, but it
deserves a comment.
> +(setq llk-bindings nil)
Why?
Also the file lacks the usual end of file marker (and the call to `provide`).
I'll try and take a look at the C code later.
Stefan
next prev parent reply other threads:[~2025-01-04 4:55 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 23:15 Physical keyboard events Cecilio Pardo
2024-10-29 13:40 ` Eli Zaretskii
2024-10-29 15:07 ` Cecilio Pardo
2024-10-29 15:38 ` Peter Feigl
2024-10-29 17:54 ` Cecilio Pardo
2024-10-29 23:41 ` James Thomas
2024-10-29 16:44 ` Eli Zaretskii
2024-10-29 16:55 ` Yuri Khan
2024-10-29 17:46 ` Eli Zaretskii
2024-10-30 2:56 ` Max Nikulin
2024-10-30 6:28 ` Yuri Khan
2024-10-30 6:39 ` Peter Feigl
2024-10-30 15:27 ` Eli Zaretskii
2024-10-30 17:13 ` Yuri Khan
2024-10-30 17:37 ` Eli Zaretskii
2024-10-30 19:26 ` Dov Grobgeld
2024-10-30 19:36 ` Juri Linkov
2024-10-30 19:55 ` Eli Zaretskii
2024-10-31 6:13 ` Yuri Khan
2024-10-30 15:21 ` Eli Zaretskii
2024-10-30 16:59 ` Max Nikulin
2024-10-29 17:56 ` Cecilio Pardo
2024-10-29 17:52 ` Cecilio Pardo
2024-10-29 17:13 ` Alan Mackenzie
2024-10-29 18:20 ` Cecilio Pardo
2024-10-29 19:31 ` Alan Mackenzie
2024-10-29 21:45 ` Cecilio Pardo
2024-10-30 6:02 ` Yuri Khan
2024-10-30 15:23 ` Eli Zaretskii
2024-10-30 16:51 ` Yuri Khan
2024-10-30 17:25 ` Eli Zaretskii
2024-10-30 3:27 ` Eli Zaretskii
2024-11-03 23:44 ` Cecilio Pardo
2024-11-04 0:21 ` Po Lu
2024-11-04 8:03 ` Cecilio Pardo
2024-11-04 9:35 ` Po Lu
2024-11-04 11:11 ` Cecilio Pardo
2024-11-04 11:49 ` Po Lu
2024-11-04 11:59 ` Cecilio Pardo
2024-11-04 13:29 ` Eli Zaretskii
2024-11-04 13:46 ` Cecilio Pardo
2024-11-04 13:54 ` Po Lu
2024-11-04 13:24 ` Eli Zaretskii
2024-11-04 14:09 ` Po Lu
2024-11-04 16:46 ` Eli Zaretskii
2024-11-05 1:31 ` Po Lu
2024-11-05 7:15 ` Cecilio Pardo
2024-11-05 9:03 ` Po Lu
2024-11-05 9:20 ` Cecilio Pardo
2024-11-05 12:21 ` Po Lu
2024-11-05 13:30 ` Eli Zaretskii
2024-11-05 14:27 ` Cecilio Pardo
2024-11-06 0:10 ` Po Lu
2024-11-06 12:49 ` Po Lu
2024-11-06 13:31 ` Eli Zaretskii
2024-11-07 0:25 ` Po Lu
2024-11-07 6:41 ` Eli Zaretskii
2024-11-07 14:36 ` Po Lu
2024-11-07 15:47 ` Eli Zaretskii
2024-11-07 16:58 ` Cecilio Pardo
2024-11-08 0:36 ` Po Lu
2024-11-05 13:13 ` Eli Zaretskii
2024-11-04 13:18 ` Eli Zaretskii
2024-11-04 14:37 ` Po Lu
2024-11-04 16:49 ` Eli Zaretskii
2024-11-05 1:03 ` Po Lu
2024-11-05 7:09 ` Cecilio Pardo
2024-11-05 13:06 ` Eli Zaretskii
2024-11-04 12:27 ` Eli Zaretskii
2024-11-04 13:09 ` Po Lu
2024-11-04 13:33 ` Eli Zaretskii
2024-11-16 8:42 ` Cecilio Pardo
2024-11-17 0:05 ` Po Lu
2024-11-18 20:35 ` bug#74423: Low level key events Cecilio Pardo
2024-11-18 23:49 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-23 12:08 ` Cecilio Pardo
2024-11-19 15:29 ` Eli Zaretskii
2024-11-19 16:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19 20:05 ` Cecilio Pardo
2024-11-20 4:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-02 16:54 ` Cecilio Pardo
2024-12-04 20:01 ` Eli Zaretskii
2024-12-04 21:25 ` Cecilio Pardo
2024-12-05 5:41 ` Eli Zaretskii
2024-12-06 1:01 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-07 21:52 ` Cecilio Pardo
2024-12-13 22:55 ` Cecilio Pardo
2024-12-14 1:16 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-14 9:26 ` Cecilio Pardo
2024-12-14 11:14 ` Eli Zaretskii
2024-12-18 10:59 ` Cecilio Pardo
2024-12-22 4:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-26 10:16 ` Cecilio Pardo
2024-12-26 14:54 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-02 15:42 ` Cecilio Pardo
2025-01-04 4:55 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-18 20:38 ` Physical keyboard events Cecilio Pardo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvpll3jlft.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=74423@debbugs.gnu.org \
--cc=cpardo@imayhem.com \
--cc=eliz@gnu.org \
--cc=luangruo@yahoo.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.