emacs-devel
[Top][All Lists]
Advanced

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

Re: master 3b41141708: Expose the name of an event's input device to Lis


From: Po Lu
Subject: Re: master 3b41141708: Expose the name of an event's input device to Lisp
Date: Sun, 10 Apr 2022 19:15:08 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux)

Po Lu <luangruo@yahoo.com> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> The low-level code which generates Lispy events can, of course, use
>> some Lisp data structures, including user-defined data structures.
>
> [...]
>
>> Yes, but what does the "class" part in "class mouse" signify?  Why not
>> just "mouse"?
>
> Sure, that would work too.  I will start working on the feature along
> those lines.
>
> Thanks.

I found out that only having an alist-of-items doesn't really work.  For
example, there is no sensible behavior if two packages bind different
function keys to the same device or device class.

So the new design I've been toying with involves two functions,
`register-device-function-key' and `delete-device-function-key'.

`register-device-function-key' takes a device or device class, and a
recommended function key.  If no function key was previously registered
for that device, it associates the function key with the device.
Otherwise, it returns the function key that was previously registered.
Either way, it increments the reference counter of that device or device
class.

`delete-device-function-key' the device or device class, subtracts from
its reference counter.  If there are no references left, it deletes the
function key from the alist.

The benefit is that multiple pieces of code can reliably bind to the
same device or class, but binding then becomes weird.  I have to call
this when pixel-scroll-precision is being activated.

  (define-key pixel-scroll-precision-mode-map
    (vector (register-device-function-key
             'mouse 'coarse-mouse)
            'wheel-down)
    #'pixel-scroll-precision-interpolate)

And when the minor mode is deactivated, I have to call

  (delete-device-function-key 'mouse)

then remove the previous binding from pixel-scroll-precision-mode-map.

What do you think? Is that a reasonable design?


reply via email to

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