unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ivan Andrus <darthandrus@gmail.com>
To: Ivan Kanis <banana@kanis.fr>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	Emacs Development List <emacs-devel@gnu.org>
Subject: Re: Binding C-i breaks TAB bindings (was bug#13861)
Date: Mon, 4 Mar 2013 11:21:28 -0700	[thread overview]
Message-ID: <9A703259-6647-4787-B79B-96D3E3435407@gmail.com> (raw)
In-Reply-To: <871ubv6o7h.fsf@kanis.fr>

On Mar 4, 2013, at 10:59 AM, Ivan Kanis <banana@kanis.fr> 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	other threads:[~2013-03-04 18:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <rjobf0uxi4.fsf@fencepost.gnu.org>
     [not found] ` <87a9qklpoa.fsf@kanis.fr>
     [not found]   ` <handler.13861.D13861.1362336754560.notifdone@debbugs.gnu.org>
2013-03-04  7:01     ` Binding C-i breaks TAB bindings (was bug#13861) Ivan Kanis
2013-03-04 14:28       ` Stefan Monnier
2013-03-04 17:59         ` Ivan Kanis
2013-03-04 18:21           ` Ivan Andrus [this message]
2013-03-04 18:56           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9A703259-6647-4787-B79B-96D3E3435407@gmail.com \
    --to=darthandrus@gmail.com \
    --cc=banana@kanis.fr \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).