[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes
From: |
Stefan Monnier |
Subject: |
bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes |
Date: |
Mon, 21 Feb 2022 16:22:23 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
>> Recently I have seen that many packages have a pattern where a global
>> minor mode adds a set of keybindings to another (like isearch or
>> minibuffer). The issue comes when they want to disable the mode, because
>> sometimes they need to iterate or loop over, and then emacs looses the
>> previous binding unless they also adds more code to remember it when set
>> and then bring it back when unset.
> I'm not sure I understand the use case. Isn't the way to do this just
> to have my-mode add itself to isearch-mode-hook, and then have my-mode
> have a minor mode keymap with the prefix it uses?
I think the use case is basically any minor mode which currently uses
`define-key` in its body to modify some other package's keymap.
> I don't think there's any general mechanism that's possible for this.
> Any package may mogrify any variable (destructively or not), and only
> the package can know what it has to do to bring things back to normal
> when the package is switched off.
I think we should provide an API to do that meaningfully. I.e. instead
of having a minor mode just bluntly set a variable, associate with each
global var a pair (VAL . FUNS) of a base value and a list of functions,
where the effective value (the one that should be stored in the
`symbol-value`, barring intervention from code that disregards the new
API) is (FUN1 (FUN2 (... VAL))).
The minor mode can then add/remove a function from the list, and just as
is the case with `add-hook`, `add-function`, etc... it will correctly
handle the case where the additions/removals are not nested.
Stefan
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Ergus, 2022/02/20
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Lars Ingebrigtsen, 2022/02/20
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Ergus, 2022/02/20
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Ergus, 2022/02/20
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes,
Stefan Monnier <=
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Lars Ingebrigtsen, 2022/02/22
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Stefan Monnier, 2022/02/22
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Lars Ingebrigtsen, 2022/02/22
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Stefan Monnier, 2022/02/22
- bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Lars Ingebrigtsen, 2022/02/23
bug#54074: [External] : bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Drew Adams, 2022/02/20
bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes, Juri Linkov, 2022/02/21