gpt4 book ai didi

emacs - 删除(不杀死)emacs 中的一行。外部剪贴板未附加到杀伤环

转载 作者:行者123 更新时间:2023-12-04 13:34:12 25 4
gpt4 key购买 nike

很多时候,我发现自己需要粘贴一条从任何地方到 emacs 的 minibuffer 的路径。为了快速清除迷你缓冲区,我导航到开头并执行 C-k(杀戮线)。

这有效地用我刚刚在迷你缓冲区中杀死的临时路径覆盖了我在系统剪贴板中的任何路径。使用 M-y 导航杀伤环不会带来我在系统剪贴板中的路径。

有没有办法删除当前行而不杀死它(即删除它并将其添加到终止环)?

到目前为止,我正在标记该行并按下 delete 并激活 delete-selection-mote。我想要一个类似于 C-k 的一键解决方案。

最佳答案

从 Emacs 23.2 开始,您可以设置 save-interprogram-paste-before-kill到一个非零值(帽子提示 Tyler )将剪贴板选择复制到杀伤环上,以便可以通过 C-y M-y 获得:

(setq save-interprogram-paste-before-kill t)

如果您使用的是较旧的 Emacs,以下建议具有相同的功能:
(defadvice kill-new (before kill-new-push-xselection-on-kill-ring activate)
"Before putting new kill onto the kill-ring, add the clipboard/external selection to the kill ring"
(let ((have-paste (and interprogram-paste-function
(funcall interprogram-paste-function))))
(when have-paste (push have-paste kill-ring))))

而且,你可以做这样的事情(可怕的键绑定(bind),自定义以适应)从前面删除该行:
(define-key minibuffer-local-map (kbd "C-S-d") 'delete-line)
(defun delete-line (&optional arg)
(interactive "P")
;; taken from kill-line
(delete-region (point)
;; It is better to move point to the other end of the kill
;; before killing. That way, in a read-only buffer, point
;; moves across the text that is copied to the kill ring.
;; The choice has no effect on undo now that undo records
;; the value of point from before the command was run.
(progn
(if arg
(forward-visible-line (prefix-numeric-value arg))
(if (eobp)
(signal 'end-of-buffer nil))
(let ((end
(save-excursion
(end-of-visible-line) (point))))
(if (or (save-excursion
;; If trailing whitespace is visible,
;; don't treat it as nothing.
(unless show-trailing-whitespace
(skip-chars-forward " \t" end))
(= (point) end))
(and kill-whole-line (bolp)))
(forward-visible-line 1)
(goto-char end))))
(point))))

关于emacs - 删除(不杀死)emacs 中的一行。外部剪贴板未附加到杀伤环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8422405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com