删除一个单词而不将其添加到 Emacs 中的 kill-ring [英] Delete a word without adding it to the kill-ring in Emacs
问题描述
在使用 minibuffer (C-x C-f) 切换文件时,我经常使用 M-Backspace 删除路径中的单词.Emacs 会自动将我删除的内容放入 kill ring.这可能很烦人,因为有时我要移动到另一个文件来粘贴某些内容,而我最终会粘贴文件路径的一部分.我知道有一些变通方法,其他代码仍在终止环等中,但我只想禁用此功能.
When switching files using the minibuffer (C-x C-f), I often use M-Backspace to delete words in the path. Emacs automatically places what I delete into the kill ring. This can be annoying, as sometime I am moving to another file to paste something, and I end up pasting part of the file path. I know there are workarounds, and the other code is still in the kill ring, etc, but I would just like to disable this functionality.
推荐答案
Emacs 没有 backward-delete-word
功能,但定义一个很容易:
Emacs doesn't have a backward-delete-word
function, but it's easy enough to define one:
(defun backward-delete-word (arg)
"Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (backward-word arg) (point))))
然后就可以在minibuffer-local-map
中将M-Backspace绑定到backward-delete-word
:
Then you can bind M-Backspace to backward-delete-word
in minibuffer-local-map
:
(define-key minibuffer-local-map [M-backspace] 'backward-delete-word)
这篇关于删除一个单词而不将其添加到 Emacs 中的 kill-ring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!