Delete a word without adding it to the kill-ring in Emacs

故事扮演 提交于 2019-11-30 08:46:44

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))))

Then you can bind M-Backspace to backward-delete-word in minibuffer-local-map:

(define-key minibuffer-local-map [M-backspace] 'backward-delete-word)
Drew

See a discussion of this topic at help-gnu-emacs@gnu.org: http://lists.gnu.org/archive/html/help-gnu-emacs/2011-10/msg00277.html

The discussion boils down to this short solution:

(add-hook 'minibuffer-setup-hook'
          (lambda ()
            (make-local-variable 'kill-ring)))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!