From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: key binding only when in a given minor mode and a given major mode? Date: Mon, 14 Aug 2006 00:43:40 +0200 Organization: Organization?!? Message-ID: <85irkwxnmr.fsf@lola.goethe.zz> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1155512435 14767 80.91.229.2 (13 Aug 2006 23:40:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 13 Aug 2006 23:40:35 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 14 01:40:34 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 1GCPZC-0000Cm-Qr for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Aug 2006 01:40:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GCPZC-0002zg-9D for geh-help-gnu-emacs@m.gmane.org; Sun, 13 Aug 2006 19:40:26 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:JFmTYJ1HULDu+WhzgpPlODn7Fwg= Original-Lines: 40 Original-NNTP-Posting-Date: 14 Aug 2006 00:43:53 CEST Original-NNTP-Posting-Host: 47fd30ee.newsspool3.arcor-online.net Original-X-Trace: DXC=YBYfGeH:3hM78PK[oJ2ng@McF=Q^Z^V3H4Fo<]lROoRA4nDHegD_]REG; ^a8_59FYL1_LiI6ENVaM3>5MOK` 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:36675 Archived-At: "Drew Adams" writes: > I have a minor mode that binds some keys in its minor-mode map. In some > cases, these shadow global bindings. When the mode is turned off, the > minor-mode bindings are no longer in effect. > > That works fine, but what happens when the binding I want to shadow is not a > global binding but a major-mode binding? What's a good way to create a > binding that will only be effective when in both a particular major mode and > a particular minor mode? When not in that minor mode, but still in the major > mode, I want the major-mode binding to be in effect, and when not in that > major mode, I want the global binding to be in effect. > > For example, suppose I want to bind `g' in Info (major) mode to command > `foo-cmd' if and only if minor mode `foo' is turned on. I don't want to > affect global bindings or bindings in other modes. Turning `foo' off while > in Info should remove the binding of `g' to command `foo-cmd'. Turning `foo' > on or off while not in Info should have no effect on the binding of `g'. > > All I can think of are these possibilities: > > 1. Bind the key in the minor-mode map to another command, `maybe-foo-cmd', > which tests the major mode and either calls `foo-cmd' or uses the global > binding of the key. > > 2. Bind the key in the major-mode map to another command, `maybe-foo-cmd', > which tests the minor mode and either calls `foo-cmd' or uses the major-mode > binding of the key. > > #2 seems preferable, but I wonder if there isn't a better way to accomplish > this, without the intermediary of another command like `maybe-foo-cmd'. I > looked through the Elisp manual, but I didn't notice anything that might be > pertinent here. It looks like `minor-mode-overriding-map-alist' would be > almost what I need, but it does the opposite: it lets a major mode override > minor-mode maps. Well, so let your major mode override an empty minor-mode map. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum