unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "rgb" <rbielaws@i1.net>
Subject: Re: Can one define global-set-key to override mode-based keymap?
Date: 13 Nov 2006 08:52:43 -0800	[thread overview]
Message-ID: <1163436763.513029.250880@m73g2000cwd.googlegroups.com> (raw)
In-Reply-To: 1163384351.738042.95660@e3g2000cwe.googlegroups.com

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

  parent reply	other threads:[~2006-11-13 16:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-13  2:19 Can one define global-set-key to override mode-based keymap? Liu Fung Sin
2006-11-13 16:25 ` Kevin Rodgers
2006-11-13 16:52 ` rgb [this message]
     [not found] ` <mailman.501.1163435231.2155.help-gnu-emacs@gnu.org>
2006-11-13 17:01   ` rgb
2006-11-13 17:59     ` Kevin Rodgers
  -- strict thread matches above, loose matches on Subject: below --
2006-11-14  6:46 martin rudalics
     [not found] <mailman.551.1163488292.2155.help-gnu-emacs@gnu.org>
2006-12-18  7:31 ` Daniel Engeler
2006-12-21 13:17 martin rudalics

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=1163436763.513029.250880@m73g2000cwd.googlegroups.com \
    --to=rbielaws@i1.net \
    /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).