I've seen questions here about moving the cursor from window to window with C-x o
and M-- C-x o
. Fine.
I want to map that to C-TAB
and C-S-TAB
.
This is what I added to my .emacs:
(global-set-key [C-tab] 'other-window)
(global-set-key [C-S-tab] '(other-window -1))
C-tab
works, but not C-S-tab
.
The minibuffer tells me:
Wrong type argument: commandp, (other-window -1)
I tried without the parenthesis around other-window, but that wouldn't work either.
In short, I'm not sure how to pass optional arguments to functions in my .emacs.
Help, please?
Edit to add version: (emacs 22.3.1 on windows)
(global-set-key [C-S-tab]
(lambda ()
(interactive)
(other-window -1)))
EDIT: Added in (interactive)
, per Gauthier and Peter Hart.
I'm on my mobile phone and i don't recall the exact key sequence but you can find it in my init.el file or by C-h k C-S-TAB so emacs tel you "<the key sequence your looking for> is not bind to anything" or something alike. http://pablo.rauzy.name/init.el.html :-)
EDIT: So i'm now on my computer, here is the simple way to do this :
(global-set-key [C-tab] 'next-buffer)
(global-set-key [C-S-iso-lefttab] 'previous-buffer)
To elaborate on Matthew's answer a bit, I recently wrote a little helper macro for situations like this:
(defmacro global-set-key* (keys &rest body)
`(global-set-key ,keys (lambda () (interactive) ,@body))
That way I can write things like:
(global-set-key* [(shift control n)] (next-line) (scroll-up 1))
(global-set-key* [(shift control p)] (previous-line) (scroll-down 1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With