[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: swapping the bindings of TAB and M-i ?
From: |
Daniel Jensen |
Subject: |
Re: swapping the bindings of TAB and M-i ? |
Date: |
Fri, 18 May 2007 10:49:35 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.99 (gnu/linux) |
poppyer <poppyer@gmail.com> 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.