unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ergus <spacibba@aol.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>,
	Stefan Monnier via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>,
	help-gnu-emacs@gnu.org
Subject: Re: Attach a map to another
Date: Sun, 20 Feb 2022 12:07:13 +0100	[thread overview]
Message-ID: <CB9DAD36-2356-404D-8750-B5A47D810074@aol.com> (raw)
In-Reply-To: <jwvfsoevhvr.fsf-monnier+emacs@gnu.org>

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.



  parent reply	other threads:[~2022-02-20 11:07 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
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 [this message]
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=CB9DAD36-2356-404D-8750-B5A47D810074@aol.com \
    --to=spacibba@aol.com \
    --cc=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).