In GNU Emacs, what is [C-tab]? Consider:
(version)
"GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600)
of 2010-05-08 on G41R2F1"
(defun key-binding-test ()
(interactive)
(insert " key-binding-test called "))
For a single letter control character, a character constant must be used in the vector:
(global-set-key [C-l] 'key-binding-test) ; does not work
(global-set-key [?\C-l] 'key-binding-test) ; works
?\C-l can be evaluated in the *scratch* buffer:
?\C-l
12
However to bind C-Tab:
(global-set-key [?\C-tab] 'key-binding-test) ;does not work
; Debugger entered--Lisp error: (invalid-read-syntax "?")
(global-set-key [C-tab] 'key-binding-test) ; works
When I try to evalulate C-tab 开发者_JAVA技巧though:
C-tab ; Debugger entered--Lisp error: (void-variable C-tab)
Comparing the evaluation of the vectors:
[?\C-l] ; input
[12] ; result
[C-tab] ; input
[C-tab] ; result
(aref [C-tab] 0) ; input
C-tab ; result, but C-tab can not be evaulated further.
[C-tab] is a vector, see the manual for vectors. In there you will find that a vector is considered constant for evaluation (i.e. it evaluates to itself).
So [C-tab] evaluates to [C-tab], a vector of one element, the symbol C-tab, which you can extract like so
(aref [C-tab] 0)
Added in response to the first comment.
Another vector is:
[some-symbol another (a list of things) 9]
it has length 4
(length [some-symbol another (a list of things) 9])
It contains two symbols some-symbol and another, a list (a list of things) and an integer 9.
C-tab is a symbol just like some-symbol and another in the examples above, they have no value unless their value cell is set to something.
Try (kbd "C-TAB"), e.g. (global-set-key (kbd "C-TAB") 'key-binding-test).
Keep in mind though that Tab itself is a control sequence (C-i), so it may not work depending on where you are. It definitely won't work on the terminal, for instance.
One thing you could try to see if emacs will even recognize C-TAB different from TAB is C-h k C-TAB. If the help shows you the help for just normal TAB, you're out of luck. Otherwise it'll say something like "<C-tab> is undefined".
加载中,请稍侯......
精彩评论