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: Stefan Monnier
Subject: Re: Attach a map to another
Date: Sat, 19 Feb 2022 13:29:56 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> 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




reply via email to

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