开发者

emacs switch window to C-TAB and C-S-TAB

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-tabworks, but not C-S-tab.

The minibuff开发者_如何学JAVAer 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))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜