我如何调整这个elisp功能来区分C-d& DEL? [英] How can I tweak this elisp function to distinguish between C-d & DEL?
本文介绍了我如何调整这个elisp功能来区分C-d& DEL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我当前的功能(从网站盲目复制)
(defun tweakemacs-delete-one-line )
删除当前行
(交互式)
(行首)
(kill-line)
(kill-line))
(global-set-key(kbdCd)'tweakemacs-delete-one-line)
<这里有两个怪癖,我想摆脱。 1)这实际上将DEL重新绑定到同一个函数。我希望我的DEL保持删除一个字符。 2)需要一个条件,如果该行只是一个换行符,它不会被双击。
解决方案
区分这两个,使用键的首选向量语法:
(global-set-key [delete]'foo)
(global-set-key [(control d)]'bar)
事情,听起来好像你想要
(setq kill-whole-line t)
或者只是想使用函数 kill-whole-line
p>
Here's my current function (blindly copy-pasted from a website)
(defun tweakemacs-delete-one-line ()
"Delete current line."
(interactive)
(beginning-of-line)
(kill-line)
(kill-line))
(global-set-key (kbd "C-d") 'tweakemacs-delete-one-line)
There are two quirks here that I want to get rid of. 1) This actually rebinds DEL to the same function. I want my DEL to remain "delete one character". 2) There needs to be a condition where it will not double-kill if the line is only a newline character.
解决方案
To distinguish those two, use the preferred vector syntax for keys:
(global-set-key [delete] 'foo)
(global-set-key [(control d)] 'bar)
As for the second thing, it sounds as if you either want
(setq kill-whole-line t)
or just want to use the function kill-entire-line
instead.
这篇关于我如何调整这个elisp功能来区分C-d& DEL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文