gpt4 book ai didi

emacs,如何多次调用 kill-region?

转载 作者:太空宇宙 更新时间:2023-11-03 18:42:54 24 4
gpt4 key购买 nike

手册上说,如果你按顺序使用kill-region,你杀死的文本会在kill-ring中连成一个。
我只是很困惑这是如何工作的。所以我尝试在 scratch 缓冲区中对此进行评估:

(progn
(kill-region 1 5) ; this kills ";; T"
(kill-region 1 5)); this kills "his "

我期望的是,因为我使用了 kill-region 2 次,所以被杀死的文本应该在 kill-ring 中连接为一个。
但是当我使用 C-y 时,我只会得到“他的”。
所以我在这里有 2 个问题:

  • 在 lisp 中,如何多次调用 kill-region 以便将被杀死的文本连接起来?

  • 使用键盘 C-w,如何多次调用 kill-region 以便将被杀死的文本连接起来?因为典型的工作流程是 kill-region(C-w),然后移动光标,然后再次 kill-region。

这里是kill region的文档字符串。第二段和最后一段不矛盾吗?

"Kill (\"cut\") text between point and mark.
This deletes the text from the buffer and saves it in the kill ring.
The command \\[yank] can retrieve it from there.
\(If you want to save the region without killing it, use \\[kill-ring-save].)

If you want to append the killed region to the last killed text,
use \\[append-next-kill] before \\[kill-region].

If the buffer is read-only, Emacs will beep and refrain from deleting
the text, but put the text in the kill ring anyway. This means that
you can use the killing commands to copy text from a read-only buffer.

Lisp programs should use this function for killing text.
(To delete text, use `delete-region'.)
Supply two arguments, character positions indicating the stretch of text
to be killed.
Any command that calls this function is a \"kill command\".
If the previous command was also a kill command,
the text killed this time appends to the text killed last time
to make one entry in the kill ring."

最佳答案

文档指的是命令,而不是函数。命令是一个函数启动command loop .

Any command that calls this function is a \"kill command\". If the previous command was also a kill command, the text killed this time appends to the text killed last time to make one entry in the kill ring.

这并不意味着 kill-region 本身。它说的是调用的任何命令kill-region 函数变成了一个“kill 命令”(包括 kill-region本身)。例如。 kill-line kill-word

  • 在 lisp 中,如何多次调用 kill-region 以便杀死文本是串联的吗?

使用kill-append

(progn
(kill-region 1 5) ; this kills ";; T"
(kill-region 1 5)); this kills "his "

what I expect is that, since I use kill-region 2 times, the killed texts should be concatenated as one in the kill-ring.

您两次调用 kill-region 但不是作为命令。这两个电话都会发生在同一命令循环中运行。

关于emacs,如何多次调用 kill-region?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16539107/

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