如何在不更改TAB的情况下将命令绑定到C-i? [英] How do I bind a command to C-i without changing TAB?

查看:91
本文介绍了如何在不更改TAB的情况下将命令绑定到C-i?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在emacs中,我想绑定命令到C-i。所以我把(全局设置键\Ci'forward-word)



emacs文件。这是有效的,除了现在,TAB键也必须前进。



如何在不更改TAB的情况下将命令绑定到Ci?

解决方案

简而言之,这应该可以解决你的问题:

 (setq local-function- key-map(delq'(kp-tab。[9])local-function-key-map))
(global-set-key(kbdCi)'forward-word)

更长的版本:



从emacs的lisp文档href =http://www.gnu.org/software/emacs/elisp/html_node/Function-Keys.html =noreferrer>功能键:


在ASCII中,Ci和< TAB>是相同的
字符。如果终端可以
区分它们,Emacs
通过将前者表示为
,将整数9表示为Lisp
程序,后者表示为
符号标签。



大多数情况下,
区分两者并不有用。所以通常
local-function-key-map(参见
Translation Keymaps)设置为将
标签映射到9.因此,
的键绑定字符代码9(字符Ci)
也适用于选项卡。同样对于此组中的
其他符号。
函数read-char同样将
这些事件转换为字符。


所以,一旦你做了以下你可以看到键绑定的区别:

 (setq local-function-key-map(delq'(kp-标签。[9])local-function-key-map))

;;这是C-i
(全局设置密钥(kbdC-i)(lambda()(交互)(消息C-i)))
;;这是< tab>键
(全局设置键(kbd< tab>)(lambda()(交互式)(消息< tab>)))
/ pre>

注意,每个模式设置不同的 TAB 绑定,因此您可能需要对每个模式进行自定义。



版本相关性



以上内容适用于Emacs 23.1。从新闻文件:


功能键序列现在使用`local-function-key-map'映射,
a新变量。这个继承自全局变量function-key-map,
,不再直接使用。


在版本22及更早版本中,您可以使用变量 function-key-map 获得相同的效果。我测试了这个,发现它与Emacs 21一起使用。

 (setq local-function-key-map(delq'(kp tab。[9])function-key-map))
(global-set-key(kbdCi)'forward-word)


In emacs, I want to bind a command to C-i. So I put (global-set-key "\C-i" 'forward-word)

in my .emacs file. This works, except now the TAB key is bound to 'forward-word as well.

How do I bind a command to C-i without changing TAB?

解决方案

In short, this should solve the problem for you:

(setq local-function-key-map (delq '(kp-tab . [9]) local-function-key-map))
(global-set-key (kbd "C-i") 'forward-word)

Longer version:

From the emacs lisp documentation on function keys:

In ASCII, C-i and <TAB> are the same character. If the terminal can distinguish between them, Emacs conveys the distinction to Lisp programs by representing the former as the integer 9, and the latter as the symbol tab.

Most of the time, it's not useful to distinguish the two. So normally local-function-key-map (see Translation Keymaps) is set up to map tab into 9. Thus, a key binding for character code 9 (the character C-i) also applies to tab. Likewise for the other symbols in this group. The function read-char likewise converts these events into characters.

So, once you do the following, you can see the difference in the key bindings:

(setq local-function-key-map (delq '(kp-tab . [9]) local-function-key-map))

;; this is C-i
(global-set-key (kbd "C-i") (lambda () (interactive) (message "C-i"))) 
;; this is <tab> key
(global-set-key (kbd "<tab>") (lambda () (interactive) (message "<tab>")))

Note, each mode sets up the various TAB bindings differently, so you may need to do customization per mode that you care about.

Version Dependency:

The above works for Emacs 23.1. From the NEWS file:

Function key sequences are now mapped using `local-function-key-map', a new variable. This inherits from the global variable function-key-map, which is not used directly any more.

Which means, in versions 22 and earlier, you can get the same effect by using the variable function-key-map. I tested this and found it to work with Emacs 21.

(setq local-function-key-map (delq '(kp-tab . [9]) function-key-map))
(global-set-key (kbd "C-i") 'forward-word)

这篇关于如何在不更改TAB的情况下将命令绑定到C-i?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆