[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: swapping the bindings of TAB and M-i ?
From: |
poppyer |
Subject: |
Re: swapping the bindings of TAB and M-i ? |
Date: |
17 May 2007 13:33:15 +0100 |
User-agent: |
Emacs Gnus |
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 <poppyer@gmail.com> 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
--