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

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

Re: global-set-key in text-mode


From: Joel J. Adamson
Subject: Re: global-set-key in text-mode
Date: Wed, 20 Feb 2008 13:24:03 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

address@hidden writes:

> I have the following key binding in my .emacs file
>
> (global-set-key "\M-s" 'save-buffer)

Notice the word "global" at the beginning of the function
`global-set-key'.  This means that it gets overridden by special modes.
The mode is buffer-local, meaning that if you switch to another major
mode, the binding is still there.  What you want to do is redefine it
for text mode: there's a great explanation of how to fix keybindings
that inadvertently get reset by major modes in Chapter 11, section
"Customizing Existing Modes" of _Learning GNU Emacs_ from O'Reilly.

Here's a summary:

(add-hook 'text-mode-hook
          '(lambda ()
                   (define-key text-mode-map "\M-s" 'save-buffer)))


Try "M-x describe-mode" for a listing of keybindings.  "\M-x where-is"
also tells you the keybinding of any command.

HTH,
Joel
-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109


reply via email to

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