编写lisp emacs的键绑定,并且不能指定< delete>字符 [英] writing lisp emacs key binding and cannot specify the <delete> character

查看:138
本文介绍了编写lisp emacs的键绑定,并且不能指定< delete>字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我将默认的M-del键绑定到反向杀死字映射到扫描匹配括号,重置不起作用,所以我试图在lisp中设置全局密钥绑定。所以我在〜/ .emacs.d / init.el中写了lisp命令:

For some reason I got the default M-del key binding for backward-kill-word mapped to a scan for matching brackets and resetting is not working, so I am trying to set the global key binding in lisp. So I wrote in ~/.emacs.d/init.el the lisp commands:

(global-set-key(kbdMh)'backward-kill-单词)

(global-set-key (kbd "M-h") 'backward-kill-word)

(global-set-key(kbdM- <\delete>)'reverse-kill-word)

(global-set-key (kbd "M-<\delete>") ‘backward-kill-word)

我用Cx Ce尝试了他们,他们都给出了反向杀死字输出,但只有第一个绑定键的功能Mh,另一个被忽略,M-del仍然尝试奇怪扫描动作。删除键在其他地方的emacs中起作用,所以看起来像delete并没有被映射到lisp中的物理键(反斜杠在这个文本中只出现在这个单词被注释掉的地方)。任何想法要使用什么关键字或特殊字符?
Best。

I tried them with C-x C-e and they both give the 'backward-kill-word output but only the first key-binding works "M-h", the other is ignored and M-del still trying the strange scanning action. The delete key works in emacs elsewhere, so it seems like "delete" is not being mapped to the physical key in lisp (and the backslash is there to show in this text only as the word was being commented out). Any idea what keyword to use or special character? Best.

(我查找可能已经覆盖此命令的库,但找不到它们)

(I looked for libraries that may have overrided this command but I cannot find them)

推荐答案

在某些系统上, delete 键定义为 Cd 。这通过GNU Emacs< 23和 local-function-key-map 上的 function-key-map (我已经在Debian和Ubuntu 10.04上观察到这种行为在X.)这种翻译的目的是隔离从终端复杂代码模式的人:想要影子删除命令的模式只需要重新绑定 Cd ,不知道是否应该重新绑定 delete (是删除还是删除权限?)或 deletechar 或其他东西。

On some systems, the delete key is defined as an alias to C-d. This is done through function-key-map on GNU Emacs <23 and local-function-key-map on GNU Emacs 23. (I've observed this behavior on Debian and Ubuntu 10.04 under X.) The purpose of such translations is to isolate people who code modes from the terminal intricacies: a mode that wants to shadow the delete command only needs to rebind C-d and not wonder if it should rebind delete (is that a delete left or delete right?) or deletechar or something else.

如果有删除的全局或本地绑定,它将这个翻译影印到 Cd 。但是,如果您按 ESC删除,如果 ESC删除没有全局或本地绑定,则第二个键为翻译成 Cd 。这个翻译优先于 ESC删除作为 M-delete 的解释。所以 ESC删除相当于 CMd

If there is a global or local binding for delete, it shadows this translation to C-d. However, if you press ESC delete, if there is no global or local binding for ESC delete, the second key is translated to C-d. This translation has precedence over the interpretation of ESC delete as M-delete. So ESC delete becomes equivalent to C-M-d.

可能是Emacs中的错误: ESC delete 的效果应与 M-delete 相同,并且没有理由为什么 ESC删除将运行 down-list ,这与删除无关。

This is arguably a bug in Emacs: the effect of ESC delete should be the same as M-delete, and there is no reason why ESC delete would run down-list which has nothing to do with deletion.

有几个可能的修复;我不知道哪个是最好的。应该与任何版本的Emacs配合使用的是

There are several possible fixes; I don't know which is best. One that should work with any version of Emacs is

(global-set-key [?\e delete] 'backward-kill-word)

这篇关于编写lisp emacs的键绑定,并且不能指定&lt; delete&gt;字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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