unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Best practice for overriding keybinding of a minor mode?
@ 2009-09-25  7:57 Stefan Kamphausen
  2009-09-25  8:08 ` Pascal J. Bourguignon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stefan Kamphausen @ 2009-09-25  7:57 UTC (permalink / raw)
  To: help-gnu-emacs

Dear all,

whenever you use a minor mode it may come with its own set of
keybinding.  Just as an example take the keymap of the fine
flyspell-mode.  It binds C-. and C-, which I find particularly annoying
since I got those bound to some personal functions globally for years.  

Now, my question is: what is the best/most effective/easiest/suggested
way to remove those bindings?  Shall I re-create that keymap after
loading flyspell?  Or override those binding explicitly in all hooks
where I enable flyspell (mainly nxml and message-mode, that is)?

How would you do this?

Kind regards,
Stefan
-- 
Stefan Kamphausen --- http://www.skamphausen.de
a blessed +42 regexp of confusion (weapon in hand)
You hit. The format string crumbles and turns to dust.


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

* Re: Best practice for overriding keybinding of a minor mode?
  2009-09-25  7:57 Best practice for overriding keybinding of a minor mode? Stefan Kamphausen
@ 2009-09-25  8:08 ` Pascal J. Bourguignon
  2009-09-25 19:30   ` Tassilo Horn
  2009-09-28 21:54 ` Samuel Wales
       [not found] ` <mailman.7668.1254174883.2239.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 7+ messages in thread
From: Pascal J. Bourguignon @ 2009-09-25  8:08 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Kamphausen <skampi@gmx.net> writes:

> Dear all,
>
> whenever you use a minor mode it may come with its own set of
> keybinding.  Just as an example take the keymap of the fine
> flyspell-mode.  It binds C-. and C-, which I find particularly annoying
> since I got those bound to some personal functions globally for years.  
>
> Now, my question is: what is the best/most effective/easiest/suggested
> way to remove those bindings?  Shall I re-create that keymap after
> loading flyspell?  Or override those binding explicitly in all hooks
> where I enable flyspell (mainly nxml and message-mode, that is)?
>
> How would you do this?

There should be a hook run when the minor mode is activated.  You can
put there a function to reinstall your bindings.

In the case of flyspell-mode there is no hook, so you would have to
define an advice on flyspell-mode itself.


-- 
__Pascal Bourguignon__


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

* Re: Best practice for overriding keybinding of a minor mode?
  2009-09-25  8:08 ` Pascal J. Bourguignon
@ 2009-09-25 19:30   ` Tassilo Horn
  0 siblings, 0 replies; 7+ messages in thread
From: Tassilo Horn @ 2009-09-25 19:30 UTC (permalink / raw)
  To: help-gnu-emacs

pjb@informatimago.com (Pascal J. Bourguignon) writes:

Hi!

> In the case of flyspell-mode there is no hook, so you would have to
> define an advice on flyspell-mode itself.

Or simply add your bindings to the mode-map.

--8<---------------cut here---------------start------------->8---
;; Unset the default keys
(define-key flyspell-mode-map (kbd "C-.") nil)
(define-key flyspell-mode-map (kbd "C-,") nil)
;; Add the commands to new keys
(define-key flyspell-mode-map (kbd "C-c f .")
            'flyspell-goto-next-error)
(define-key flyspell-mode-map (kbd "C-c f ,")
            'flyspell-auto-correct-word)
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo





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

* Re: Best practice for overriding keybinding of a minor mode?
  2009-09-25  7:57 Best practice for overriding keybinding of a minor mode? Stefan Kamphausen
  2009-09-25  8:08 ` Pascal J. Bourguignon
@ 2009-09-28 21:54 ` Samuel Wales
       [not found] ` <mailman.7668.1254174883.2239.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Samuel Wales @ 2009-09-28 21:54 UTC (permalink / raw)
  To: Stefan Kamphausen; +Cc: help-gnu-emacs

local-unset-key

-- 
Myalgic encephalomyelitis causes death (Jason et al. 2006)
and severe suffering.  Conflicts of interest are destroying
research.  What people "know" is wrong.  Silence = death.
http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm




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

* Re: Best practice for overriding keybinding of a minor mode?
       [not found] ` <mailman.7668.1254174883.2239.help-gnu-emacs@gnu.org>
@ 2009-09-30 19:09   ` jpkotta
  2009-09-30 21:42     ` Andreas Politz
       [not found]     ` <mailman.7802.1254346989.2239.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 7+ messages in thread
From: jpkotta @ 2009-09-30 19:09 UTC (permalink / raw)
  To: help-gnu-emacs

On Sep 28, 4:54 pm, Samuel Wales <samolog...@gmail.com> wrote:
> local-unset-key
>
> --
> Myalgic encephalomyelitis causes death (Jason et al. 2006)
> and severe suffering.  Conflicts of interest are destroying
> research.  What people "know" is wrong.  Silence = death.http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm

I hope I'm not hijacking this thread, but I want to do the same thing
for ido.  I recently started using it and I don't like how C-
<backspace> works when completing files and directories.  I tried to
set the keybind via local-set-key, define-key (on ido-competion-map),
and local-unset-key; I used these methods after loading ido and in ido-
setup-hook.  Nothing worked.  Then I looked at ido.el and saw that it
does [remap backward-kill-word], which is what I have C-<backspace>
bound to globally.  After reading the manual, it seems like there is
no way to recover a remapped command.  Is this true or am I
overlooking something?  Is ido being heavy-handed here, and should not
be using remap?

Thanks,

jpkotta


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

* Re: Best practice for overriding keybinding of a minor mode?
  2009-09-30 19:09   ` jpkotta
@ 2009-09-30 21:42     ` Andreas Politz
       [not found]     ` <mailman.7802.1254346989.2239.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Politz @ 2009-09-30 21:42 UTC (permalink / raw)
  To: help-gnu-emacs

jpkotta <jpkotta@gmail.com> writes:

> On Sep 28, 4:54 pm, Samuel Wales <samolog...@gmail.com> wrote:
>> local-unset-key
>>
>> --
>> Myalgic encephalomyelitis causes death (Jason et al. 2006)
>> and severe suffering.  Conflicts of interest are destroying
>> research.  What people "know" is wrong.  Silence = death.http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm
[...]
> After reading the manual, it seems like there is
> no way to recover a remapped command.  Is this true or am I
> overlooking something?  Is ido being heavy-handed here, and should not
> be using remap?
>
(define-key keymap [remap command-name] nil)

or

(define-key keymap [remap command-name] command-name)

Both seem to do the trick.

-ap

> Thanks,
>
> jpkotta





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

* Re: Best practice for overriding keybinding of a minor mode?
       [not found]     ` <mailman.7802.1254346989.2239.help-gnu-emacs@gnu.org>
@ 2009-10-01 15:45       ` jpkotta
  0 siblings, 0 replies; 7+ messages in thread
From: jpkotta @ 2009-10-01 15:45 UTC (permalink / raw)
  To: help-gnu-emacs

On Sep 30, 4:42 pm, Andreas Politz <poli...@fh-trier.de> wrote:
> jpkotta <jpko...@gmail.com> writes:
> > On Sep 28, 4:54 pm, Samuel Wales <samolog...@gmail.com> wrote:
> >> local-unset-key
>
> >> --
> >> Myalgic encephalomyelitis causes death (Jason et al. 2006)
> >> and severe suffering.  Conflicts of interest are destroying
> >> research.  What people "know" is wrong.  Silence = death.http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm
> [...]
> > After reading the manual, it seems like there is
> > no way to recover a remapped command.  Is this true or am I
> > overlooking something?  Is ido being heavy-handed here, and should not
> > be using remap?
>
> (define-key keymap [remap command-name] nil)
>
> or
>
> (define-key keymap [remap command-name] command-name)
>
> Both seem to do the trick.
>

Thanks, I needed to remap to nil _and_ redefine the key.


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

end of thread, other threads:[~2009-10-01 15:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-25  7:57 Best practice for overriding keybinding of a minor mode? Stefan Kamphausen
2009-09-25  8:08 ` Pascal J. Bourguignon
2009-09-25 19:30   ` Tassilo Horn
2009-09-28 21:54 ` Samuel Wales
     [not found] ` <mailman.7668.1254174883.2239.help-gnu-emacs@gnu.org>
2009-09-30 19:09   ` jpkotta
2009-09-30 21:42     ` Andreas Politz
     [not found]     ` <mailman.7802.1254346989.2239.help-gnu-emacs@gnu.org>
2009-10-01 15:45       ` jpkotta

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