[英]Emacs - How to change kill to delete?
I only want Cw and Mw to modify the kill-ring, along with the system's clipboard [ Cc (copy), Cx (cut)]. 我只希望Cw和Mw以及系统的剪贴板[ Cc (副本), Cx (剪切)]一起修改kill-ring。
I use Md and M-DEL often, but I do not want to yank and then cycle through My every time. 我经常使用Md和M-DEL ,但是我不想每次拉动然后循环通过My 。
I was looking at the emacs manual but it does not answer my question. 我在看emacs手册,但没有回答我的问题。
Example: I want to bind Md "kill-word" to "delete-word", but "delete-word" does not exist. 示例:我想将Md “ kill-word”绑定到“ delete-word”,但是“ delete-word”不存在。 How do I make it so?
我该怎么做? Any help would be appreciated.
任何帮助,将不胜感激。
I think you want to use delete-region
instead of kill-region
so the text isn't saved in the kill-ring, eg. 我想您想使用
delete-region
而不是kill-region
这样文本就不会保存在kill-ring中。 something along the lines of 类似于
(defun my-delete-word (start)
(interactive "d")
(backward-word)
(delete-region (point) start))
From EmacsWiki https://www.emacswiki.org/emacs/BackwardDeleteWord 从EmacsWiki https://www.emacswiki.org/emacs/BackwardDeleteWord
(defun delete-word (arg)
"Delete characters forward until encountering the end of a word.
With argument, do this that many times."
(interactive "p")
(if (use-region-p)
(delete-region (region-beginning) (region-end))
(delete-region (point) (progn (forward-word arg) (point)))))
(defun backward-delete-word (arg)
"Delete characters backward until encountering the end of a word.
With argument, do this that many times."
(interactive "p")
(delete-word (- arg)))
(global-set-key (read-kbd-macro "<M-DEL>") 'backward-delete-word)
I made a macro to change any kill command into a delete command. 我做了一个宏,将任何kill命令更改为delete命令。
(defmacro delete-instead-of-kill (&rest body)
"Replaces `kill-region' with `delete-region' in BODY."
`(cl-letf (((symbol-function 'kill-region)
(lambda (beg end &optional region)
;; FIXME: account for region arg
(delete-region beg end))))
,@body))
(defun delete-word (&optional arg)
"Like `kill-word', but deletes instead of killing."
(interactive "p")
(delete-instead-of-kill (kill-word arg)))
I use a similar macro for copying. 我使用类似的宏进行复制。
(defmacro copy-instead-of-kill (&rest body)
"Replaces `kill-region' with `kill-ring-save' in BODY."
`(cl-letf (((symbol-function 'kill-region)
(lambda (beg end &optional region)
(kill-ring-save beg end region)
(setq this-command 'kill-region))))
,@body))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.