Emacs will switch to C-TAB and CS-TAB

I saw here questions about moving the cursor from window to window using C-x oand M-- C-x o. Good.

I want to match this with C-TABand 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-TABworks, but not C-S-TAB.

Minibuffer tells me:

Wrong type argument: commandp, (other-window -1)

I tried without a bracket around another window, but that didn't work either.

In short, I'm not sure how to pass optional arguments to functions in my .emacs.

Help me please?

Edit to add version: (emacs 22.3.1 on windows)

+5
source share
3 answers
(global-set-key [C-S-tab] 
    (lambda ()
      (interactive)
      (other-window -1)))

EDIT: Added to (interactive), by Gauthier and Peter Hart.

+7
source

, , init.el Ch k CS-TAB, emacs tel you "< , > " - . http://pablo.rauzy.name/init.el.html: -)

EDIT: , , :

(global-set-key [C-tab] 'next-buffer)
(global-set-key [C-S-iso-lefttab] 'previous-buffer)
+5

To talk in detail about Matvey, I recently wrote a small helper macro for such situations:

(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))
+2
source

All Articles