bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Lars Ingebrigtsen
Subject: bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes
Date: Tue, 22 Feb 2022 14:22:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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.

But why do that instead of using a minor mode?  I think many cases where
packages do this, it's because the idea didn't really occur to the
people that did the implementation.

> 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))).

As Eli noted, isn't this kinda `add-variable-watcher'?  But:

> 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.

My feeling is that this would be both too complicated for most people
writing modes, and it would be really confusing for us people that have
to try to figure out what's actually going on, and finally, values in
Emacs Lisp are mutable, so it won't work reliably anyway.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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