From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: daniel@bigwalter.net (Daniel Jensen) Newsgroups: gmane.emacs.help Subject: Re: swapping the bindings of TAB and M-i ? Date: Fri, 18 May 2007 10:49:35 +0200 Message-ID: <874pmaikio.fsf@orme.bigwalter.net> References: <87k5v7bvov.fsf@orme.bigwalter.net> Reply-To: indiscipline@gmail.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1179480739 11745 80.91.229.12 (18 May 2007 09:32:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 May 2007 09:32:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 18 11:32:18 2007 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 1Hoyop-0004gL-L3 for geh-help-gnu-emacs@m.gmane.org; Fri, 18 May 2007 11:32:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hoyx0-0005mv-Ht for geh-help-gnu-emacs@m.gmane.org; Fri, 18 May 2007 05:40:42 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-X-Trace: individual.net JCeGuL+0WYuglZjl9+hYoQBi8HYVm9r3O0omTbhR+aSoMwg0HP X-Face: SNGmwsN&0DaHhS0!*%\@y"Wc^).,<; VsqY#}K/NJ:A Z6_>Md7x$Z9C1%BAu41M'12-8(f2{H*8OsnYv,K+y.szl1K>}{uC/>2?; k[KUiD=$}@z>odk|7Tk7i $A|{j7LhTt!:SdVp5Z, kKA247}--"-QLedxCbw|#&bh=R]Rd)kx{q+T'fG)9ayG`+\@g'3vx1Fd3bl -`3}Guvr!A"Z);"$|]CXW>YR5m"<[L User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.99 (gnu/linux) Cancel-Lock: sha1:k65z4uDE+i6/ZtNnmzZdvMOq73c= Original-Xref: shelby.stanford.edu gnu.emacs.help:148540 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:44132 Archived-At: poppyer writes: > daniel@bigwalter.net (Daniel Jensen) writes: > >> You can add the following function to the hooks for the major modes you >> want to change. There are ways to do this for every mode, but you >> probably don't want to do that. >> >> (defun swap-indent-bindings () >> (let ((tab-binding (key-binding "\C-i"))) >> (local-set-key "\C-i" (key-binding "\M-i")) >> (local-set-key "\M-i" tab-binding))) >> >> (add-hook 'text-mode-hook 'swap-indent-bindings) ; and so on > > Thanks daniel, that is exactly what I want. > > However, is there something like any-major-mode-hook? That would be a > perfect solution adding to this. There is no such hook. It might be possible to create a global minor mode to do it, or to use keyboard translations, but I haven't tried to do that. The quickest solution that comes to mind is to put an advice on use-local-map: (defadvice use-local-map (after swap-bindings-in-local-map activate) (swap-indent-bindings)) I wouldn't do this. It's really ugly and it messes with modes that use TAB for something unrelated to text indenting. I suggest you stick with explicitly changing the modes that you want to change.