help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can one define global-set-key to override mode-based keymap?


From: rgb
Subject: Re: Can one define global-set-key to override mode-based keymap?
Date: 13 Nov 2006 08:52:43 -0800
User-agent: G2/1.0

> Is there a way to define a key as special using global-set-key (or
> otherwise) so that no other modes can override my .emacs setting?

The simple answer is no (afaik).
If you want to override mode specific keys you need to do it in a mode
hook using local-set-key.
Some people recommend this syntax (define-key X-key-map 'fcn) where X
is the mode name rather than local-set-key.  Both have their advantages
& dissadvantages.
Either way, modes often override the global key because, for example
moving to the next line in this particular buffer involves doing other
things besides moving point.  There is no guarantee that the mode
writer put that functionality on the arrow key (for example) and so
that functionality may need to be moved by you before you override the
mode's key definition.   Meaning you may need to do something like this

(local-set-key [down] (lookup-key (current-local-map) [?\C-n]))

before you do this

(local-set-key [?\C-n] 'my-custom-fcn)



reply via email to

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