unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: binding a key for keyword completion in all modes
Date: Wed, 4 Mar 2009 14:18:46 -0800 (PST)	[thread overview]
Message-ID: <238ec42a-c6ee-4661-9b11-6e3b1ca58a35@u18g2000pro.googlegroups.com> (raw)
In-Reply-To: dc46e91e-a59f-45cd-b3a8-e7d9865e418a@41g2000yqf.googlegroups.com

On Mar 4, 4:04 am, TomSW <tom.weissm...@gmail.com> wrote:
> > M-t runs the command #[nil "\300\301\302!!\207" [call-interactively
> > key-binding [134217737]] 3 nil nil]
> >   which is an interactive compiled Lisp function.
> > It is bound to M-t.
> > (anonymous)
>
> > Is there a more robust solution?
>
> Yes. If Alt-Tab is bound, it will be bound to an interactive command,
> which you can bind Ctrl-Tab to directly:
>
> (let ((binding (or (key-binding (kbd "<M-tab>"))
>                         (key-binding (kbd "M-TAB")))))
>               (when binding
>                 (local-set-key (kbd "<C-tab>") binding)))))
>
> This will give better results with describe-key.

Thanks. This does not seems to solve it though still.

if i have

(local-set-key (kbd "<C-tab>") (or (key-binding (kbd "<M-tab>"))
                                (key-binding (kbd "M-TAB"))))

then the key is changed for local buffer. If i use global-set-key,
then it's wrong because a specifical completion command name is used
for all. e.g. I get ispell-complete-word for all.

just to make message more clear and independent of the thread, what i
wanted is to set Ctrl+Tab for command completion that works in all
major modes, and avoding adding a custome hook to each and every mode.

Right now i adopted this implementation.

; keyword completion, because Alt+Tab is used by OS
(global-set-key (kbd "M-t") 'call-command-completion)

(defun call-keyword-completion ()
  "Call the function with keyboard shortcut M-TAB."
  (interactive)
  (call-interactively (key-binding (kbd "M-TAB")))
)

  Xah
∑ http://xahlee.org/

  reply	other threads:[~2009-03-04 22:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-26  2:20 binding a key for keyword completion in all modes Xah Lee
2009-02-26  3:01 ` David Golden
2009-02-26  8:13 ` Tassilo Horn
     [not found]   ` <87skm012ln.fsf@mundaneum.com>
     [not found]     ` <87r61j62k0.fsf@thinkpad.tsdh.de>
     [not found]       ` <58e57903-4b47-443c-b84d-e41662071482@e36g2000prg.googlegroups.com>
     [not found]         ` <87ocwkavg0.fsf@thinkpad.tsdh.de>
2009-03-03 23:35           ` Xah Lee
2009-03-04 12:04             ` TomSW
2009-03-04 22:18               ` Xah Lee [this message]
2009-03-04 23:17                 ` TomSW
2009-02-26 19:58 ` Marc Tfardy

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=238ec42a-c6ee-4661-9b11-6e3b1ca58a35@u18g2000pro.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).