unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: Can one define global-set-key to override mode-based keymap?
@ 2006-12-21 13:17 martin rudalics
  0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2006-12-21 13:17 UTC (permalink / raw)
  Cc: help-gnu-emacs

 >> Not really recommended:
 >>
 >> (defvar my-map (make-sparse-keymap)
 >>    "My keymap.")
 >>
 >> (defvar my-map-alist `((t . ,my-map))
 >>    "My keymap alist.")
 >>
 >> (add-to-ordered-list 'emulation-mode-map-alists 'my-map-alist 100)
 >>
 >> (define-key my-map [(control n)] 'other-window)
 >
 > I tried this and it works great so far. Why is it not recommended?

It might interact badly with other modes using this - like cua-mode.
If you use them, you should study their keymaps in order to avoid any
bad interactions.  Alternatively you could try `overriding-local-map'.

^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <mailman.551.1163488292.2155.help-gnu-emacs@gnu.org>]
* Re: Can one define global-set-key to override mode-based keymap?
@ 2006-11-14  6:46 martin rudalics
  0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2006-11-14  6:46 UTC (permalink / raw)
  Cc: help-gnu-emacs

Not really recommended:

(defvar my-map (make-sparse-keymap)
   "My keymap.")

(defvar my-map-alist `((t . ,my-map))
   "My keymap alist.")

(add-to-ordered-list 'emulation-mode-map-alists 'my-map-alist 100)

(define-key my-map [(control n)] 'other-window)

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Can one define global-set-key to override mode-based keymap?
@ 2006-11-13  2:19 Liu Fung Sin
  2006-11-13 16:25 ` Kevin Rodgers
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Liu Fung Sin @ 2006-11-13  2:19 UTC (permalink / raw)


Hi,

I like using the arrow keys to move around so I can free up Ctrl-F
Ctrl-B Ctrl-N and Ctrl-P and rebind them for some commands that I use
often.

For instance, I have

(global-set-key "\C-n" 'other-window)

in my .emacs

This works great until I invoke another major mode.

Like in dired, the dired mode map has C-n bound to dired-next-line.

C-n runs the command dired-next-line
   which is an interactive compiled Lisp function in `dired'.
(dired-next-line ARG)


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?

Thanks.
-- fungsin

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

end of thread, other threads:[~2006-12-21 13:17 UTC | newest]

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

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