all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: jadamson@partners.org (Joel J. Adamson)
To: help-gnu-emacs@gnu.org
Subject: Re: global-set-key in text-mode
Date: Wed, 20 Feb 2008 13:24:03 -0500	[thread overview]
Message-ID: <87ve4j4h6k.fsf@W0053328.mgh.harvard.edu> (raw)
In-Reply-To: ade201d9-cf94-4dd9-b6e3-28715d254ffd@i12g2000prf.googlegroups.com

educkworth@loyola.edu 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	other threads:[~2008-02-20 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-20 16:53 global-set-key in text-mode educkworth
2008-02-20 18:24 ` Joel J. Adamson [this message]
2008-02-20 19:01   ` educkworth
2008-02-20 19:04     ` educkworth
2008-02-24  6:12       ` Dave Benjamin

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ve4j4h6k.fsf@W0053328.mgh.harvard.edu \
    --to=jadamson@partners.org \
    --cc=help-gnu-emacs@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.