From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: Can one define global-set-key to override mode-based keymap? Date: 13 Nov 2006 08:52:43 -0800 Organization: http://groups.google.com Message-ID: <1163436763.513029.250880@m73g2000cwd.googlegroups.com> References: <1163384351.738042.95660@e3g2000cwe.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1163439669 28000 80.91.229.2 (13 Nov 2006 17:41:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 13 Nov 2006 17:41:09 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 13 18:41:07 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GjfnM-0005NG-4O for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Nov 2006 18:40:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GjfnI-0005QT-Pt for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Nov 2006 12:40:28 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!m73g2000cwd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 22 Original-NNTP-Posting-Host: 168.208.215.220 Original-X-Trace: posting.google.com 1163436769 13961 127.0.0.1 (13 Nov 2006 16:52:49 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 13 Nov 2006 16:52:49 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: m73g2000cwd.googlegroups.com; posting-host=168.208.215.220; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:143065 Original-To: help-gnu-emacs@gnu.org 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:38683 Archived-At: > 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)