From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jadamson@partners.org (Joel J. Adamson) Newsgroups: gmane.emacs.help Subject: Re: global-set-key in text-mode Date: Wed, 20 Feb 2008 13:24:03 -0500 Organization: I need to put my ORGANIZATION here. Message-ID: <87ve4j4h6k.fsf@W0053328.mgh.harvard.edu> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1203532848 20330 80.91.229.12 (20 Feb 2008 18:40:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 Feb 2008 18:40:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 20 19:41:13 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JRtsP-0000m3-Bp for geh-help-gnu-emacs@m.gmane.org; Wed, 20 Feb 2008 19:41:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRtru-0004fe-EM for geh-help-gnu-emacs@m.gmane.org; Wed, 20 Feb 2008 13:40:34 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news.glorb.com!newspeer1.asbnva01.us.to.verio.net!news.harvard.edu!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: w0053328.mgh.harvard.edu Original-X-Trace: plato.harvard.edu 1203532035 15032 132.183.29.121 (20 Feb 2008 18:27:15 GMT) Original-X-Complaints-To: news@plato.harvard.edu Original-NNTP-Posting-Date: Wed, 20 Feb 2008 18:27:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:OH8mwnfl0Qkj3qgyDBRio9J5tRQ= Original-Xref: shelby.stanford.edu gnu.emacs.help:156341 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:51704 Archived-At: 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