Re: On keybindings and the slow erosion of help's utility
Ihor Radchenko <[email protected]> Sat, 01 Aug 2026 16:17:09 +0000
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <8733wxak9f.fsf@localhost> |
Richard Stallman <[email protected]> writes: > Could someone say what this text intend to mean? > > - nil =E2=86=92 not applicable; try the next function > - =3D#'command=3D =E2=86=92 run this command interactively > - =3D#'keymap=3D =E2=86=92 return this keymap (Emacs enters it for furth= er lookup) > - =3D'keymap-variable=3D =E2=86=92 a symbol whose value is returned as a= keymap My idea is generalizing the key lookup to not only match the key sequences, but also run custom Elisp code that will determine which command should be executed. Consider someone pressing M-w. Normally, M-w is looked up in a keymap where the M-w can have a binding of nil, a command, another keymap, or a keymap symbol. If command, that command is executed. If nil, next keymap in the priority is looked up. If another keymap or symbol, that keymap is used to match subsequent input. What I suggest is allowing the binding to be a new element that will determine what should be done by running Elisp code. Now, on M-w, that Elisp code will run and return nil, a command, a keymap, or keymap variable symbol - the same elements as allowed in the keymaps already. This is the low-level structure. Further, I propose to have a helper macro keymap-dynamic-bind that will allow defining these new dynamic bindings in useful ways. I propose that each dynamic binding can be something akin abnormal hook, where users can define a set of conditions that will run one or another command depending on the current context. The elements of this abnormal hook are delegated the job of deciding the dynamic binding - nil, a command, a keymap, or keymap variable. Hope it is more clear. --=20 Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>