help-gnu-emacs
[Top][All Lists]
Advanced

[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: Thu, 17 May 2007 12:17:52 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.99 (gnu/linux)

poppyer <poppyer2001@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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]