From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: poppyer Newsgroups: gmane.emacs.help Subject: Re: swapping the bindings of TAB and M-i ? Date: 17 May 2007 13:33:15 +0100 Organization: University Of Oxford, England Message-ID: References: <87k5v7bvov.fsf@orme.bigwalter.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1179410164 20144 80.91.229.12 (17 May 2007 13:56:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 17 May 2007 13:56:04 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 17 15:56:03 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 1HogSW-0004MD-EG for geh-help-gnu-emacs@m.gmane.org; Thu, 17 May 2007 15:56:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hogac-0000oc-ER for geh-help-gnu-emacs@m.gmane.org; Thu, 17 May 2007 10:04:22 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news.albasani.net!dedekind.zen.co.uk!zen.net.uk!demorgan.zen.co.uk!peernews.mcc.ac.uk!feed4.jnfs.ja.net!jnfs.ja.net!feeds.news.ox.ac.uk!news.ox.ac.uk!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 27 Original-NNTP-Posting-Host: clpc78.comlab.ox.ac.uk Original-X-Trace: frank-exchange-of-views.oucs.ox.ac.uk 1179405195 12262 163.1.27.212 (17 May 2007 12:33:15 GMT) Original-X-Complaints-To: newsmaster@ox.ac.uk Original-NNTP-Posting-Date: Thu, 17 May 2007 12:33:15 +0000 (UTC) User-Agent: Emacs Gnus Original-Xref: shelby.stanford.edu gnu.emacs.help:148493 X-Mailman-Approved-At: Thu, 17 May 2007 09:56:46 -0400 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:44087 Archived-At: 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. daniel@bigwalter.net (Daniel Jensen) writes: > poppyer writes: > > > I would like to swap TAB and M-i, i.e. > > use TAB to do tab-to-tab-stop; and M-i to indent codes. > > However, the "indent" of current TAB binding is mode-specific. > > Is there any easy way to do such kind of swap without re-bind the keys > > mode by mode? > > 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 --