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

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

Re: Attach a map to another


From: Ergus
Subject: Re: Attach a map to another
Date: Sun, 20 Feb 2022 12:07:13 +0100

Thanks Stefan... Good to know... Do you think it worth doing this a feature 
request?? I think that many packages will benefit from it... Because I have 
seen many of then dealing with this issue in different manners and not all of 
them succesfull.
Maybe the new keymap package may include something in keymap-set....


Best and thanks,
Ergus




On February 19, 2022 7:29:56 PM GMT+01:00, Stefan Monnier via Users list for 
the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>> I think that having a keymap entry in another one makes the trick
>> according to the documentation:
>> (keymap
>>  (keymap
>>     (26 . extra-functions))
>>  (24 . normal-functions))
>
>Yes, it's the low-level representation used for
>multi-keymap inheritance.
>
>> but I am wondering if there is an api to do that more conveniently??
>
>The only API available which uses that is `make-composed-keymap`.
>
>[ Well, there's also `lookup-key` since multiple inheritance can appear
>  naturally in some cases as the result of looking up bindings in
>  keymaps with single inheritance.  Fixing those corner cases was
>  actually the original motivation for introducing support for multiple
>  inheritance.  ]
>
>> (define-minor-mode my-mode
>>    :keymap 'my-mode-keymap
>>    (if my-mode
>>        (keymap-set isearch-mode-map <something> my-mode-isearch-map)
>>      (keymap-unset isearch-mode-map <something>)))
>
>This code isn't right, but I see what you mean, and indeed, that's
>a good use case.
>
>We sadly don't yet have good functions for that, so you have to get
>dirty and do it by hand, with something like:
>
>    (define-minor-mode my-mode
>      (if my-mode
>          (cl-pushnew my-mode-map (cdr isearch-mode-map))
>        (delq my-mode-map isearch-mode-map)))
>
>
>-- Stefan
>
>

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


reply via email to

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