From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Attach a map to another
Date: Sat, 19 Feb 2022 13:29:56 -0500 [thread overview]
Message-ID: <jwvfsoevhvr.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 20220219130737.esdd2kou35avl75e@Ergus
> 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
next prev parent reply other threads:[~2022-02-19 18:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220219130737.esdd2kou35avl75e.ref@Ergus>
2022-02-19 13:07 ` Attach a map to another Ergus
2022-02-19 18:29 ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
2022-02-19 19:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-02-20 11:10 ` Ergus via Users list for the GNU Emacs text editor
2022-02-20 14:54 ` Stefan Monnier
2022-02-20 11:07 ` Ergus
2022-02-20 14:52 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvfsoevhvr.fsf-monnier+emacs@gnu.org \
--to=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).