emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding C-i breaks TAB bindings (was bug#13861)


From: Ivan Andrus
Subject: Re: Binding C-i breaks TAB bindings (was bug#13861)
Date: Mon, 4 Mar 2013 11:21:28 -0700

On Mar 4, 2013, at 10:59 AM, Ivan Kanis <address@hidden> wrote:

> March, 04 at 9:28 Stefan wrote:
> 
>> In any case <tab> is not overridden.  It's just that you don't have any
>> binding for <tab> so function-key-map makes Emacs fallback on the
>> C-i binding.
> 
> OK, I think I finally understand.
> 
> C-h k TAB => TAB (translated from <tab>) runs the command ...
> 
> I missed the 'translated from' bit.
> 
> I am trying to free up C-i for my nefarious purpose. Does that mean I
> have to fix each mode I use to bind the <tab> key to the proper command?
> Is there a programmatic way?

The way I do it is by creating a minor-mode (called `gvol-mode'), and bind C-i 
to whatever I want.  Then I bind <tab> to the function below which turns off 
gvol-mode and finds the "best" keybinding and runs it.  It's not perfect, and 
you sometimes run into problems that are somewhat difficult to diagnose which I 
have worked around with the setq's.

HTH,
Ivan

(defun gvol-indent-for-tab-command ()
  "This is to fix `indent-for-tab-command' for `gvol-mode'.
It runs [tab] or C-i with `gvol-mode' nil because `gvol-mode'
binds C-i to a different command.  Ideally this should take into
account window system so that it can DTRT in a terminal (whatever
the right thing is)."
  (interactive)
  (let* ((gvol-mode nil)
         (command (or (key-binding [tab])
                      (key-binding "\C-i"))))
    ;; This is to satisfy `python-indent-line' which checks
    ;; `this-command' to cycle
    (setq this-command 'indent-for-tab-command)
    ;; Make people think this was called with C-i.  This allows
    ;; `self-insert-command' to work
    (setq last-command-event 9)
    (call-interactively command)))


reply via email to

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