unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Clearing keybindings when redefining a minor mode map
@ 2010-12-27  7:19 Leo Alekseyev
  0 siblings, 0 replies; 3+ messages in thread
From: Leo Alekseyev @ 2010-12-27  7:19 UTC (permalink / raw)
  To: help-gnu-emacs

Greetings all,

Suppose I have a keybinding that is shared by two minor modes (mode A
and mode B).  I want to accomplish the following: if both modes A and B are
active, then the keybinding should only invoke mode A's command.

My original approach was to insert code in mode B's commands that checks if
mode A is active, and if so, it creates a new keymap for mode B, with
conflicts removed.  Unfortunately, even though the new map is created
properly, it
doesn't remove the old keybindings that are in conflict with mode A.  Is
there an easy way to clear those keybindings?

--Leo



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Clearing keybindings when redefining a minor mode map
       [not found] <mailman.6.1293434384.29764.help-gnu-emacs@gnu.org>
@ 2010-12-27 13:58 ` Elena
  2010-12-28  2:57 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Elena @ 2010-12-27 13:58 UTC (permalink / raw)
  To: help-gnu-emacs

On Dec 27, 7:19 am, Leo Alekseyev <dnqu...@gmail.com> wrote:
> Greetings all,
>
> Suppose I have a keybinding that is shared by two minor modes (mode A
> and mode B).  I want to accomplish the following: if both modes A and B are
> active, then the keybinding should only invoke mode A's command.
>
> My original approach was to insert code in mode B's commands that checks if
> mode A is active, and if so, it creates a new keymap for mode B, with
> conflicts removed.  Unfortunately, even though the new map is created
> properly, it
> doesn't remove the old keybindings that are in conflict with mode A.  Is
> there an easy way to clear those keybindings?
>
> --Leo

Maybe you could put some code in mode B's hook to disable mode A if
enabled already and then enable it?  This way you would be ensuring
mode A always gets enabled after mode B, thus shadowing mode B's map.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Clearing keybindings when redefining a minor mode map
       [not found] <mailman.6.1293434384.29764.help-gnu-emacs@gnu.org>
  2010-12-27 13:58 ` Clearing keybindings when redefining a minor mode map Elena
@ 2010-12-28  2:57 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2010-12-28  2:57 UTC (permalink / raw)
  To: help-gnu-emacs

> Suppose I have a keybinding that is shared by two minor modes (mode A
> and mode B).  I want to accomplish the following: if both modes A and B are
> active, then the keybinding should only invoke mode A's command.

Then you need to make sure that mode A's keymap appears before mode B's
in minor-mode-map-alist.  You might be able to do that by loading mode
B first, or else by adding a check somewhere to see which one's first
and reorder them when needed.


        Stefan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-28  2:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.6.1293434384.29764.help-gnu-emacs@gnu.org>
2010-12-27 13:58 ` Clearing keybindings when redefining a minor mode map Elena
2010-12-28  2:57 ` Stefan Monnier
2010-12-27  7:19 Leo Alekseyev

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