emacs-devel
[Top][All Lists]
Advanced

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

Re: Suggested experimental test


From: Stefan Monnier
Subject: Re: Suggested experimental test
Date: Fri, 26 Mar 2021 20:02:34 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Perhaps we could instead do something with key-translation-map (or one of
> its friends) that works on existing keymaps?
>
> The use of 'menu-item' allows us to filter based on whether the key is first
> in the sequence:
>
> (define-key key-translation-map (kbd "<menu>") (kbd "C-c"))
> (define-key key-translation-map (kbd "C-c")
>   `(menu-item "" ,(kbd "<C-c-translated>")
>               :filter my--head-of-sequence-p))
> (global-set-key (kbd "<C-c-translated>") 'kill-ring-save)

While we can use such tricks, I think what we really want is to
abstract the keymap API such that we can provide keymaps whose elements
are computed dynamically.

There'd need to be at least 2 methods: `lookup-key`, and `map-keymap`,
and adding `where-is` would probably allow better behaviors (but could
introduce other problems given the way where-is currently works).

One application is to create a keymap (on function-key-map) that remaps
all the events of the form "modifiers + mouse-4" to "same-modifiers +
scroll-up".

Another would be a keymap that binds the same keys as some other keymap
except it requires some additional modifier or it removes a modifier, or
it capitalizes all the letters, or it transcribes all the cyrillic
letters to their "equivalent" ASCII, ...
We can already perform similar remappings via `key-translation-map` or
`function-key-map`, but these apply everywhere whereas if we could do them
inside a normal "key binding" keymap then it could be made to apply only
to bindings with a particular prefix.



        Stefan




reply via email to

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