[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: binding a key for keyword completion in all modes
From: |
Xah Lee |
Subject: |
Re: binding a key for keyword completion in all modes |
Date: |
Wed, 4 Mar 2009 14:18:46 -0800 (PST) |
User-agent: |
G2/1.0 |
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/
☄