3

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

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

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

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

  • 使用键盘 Cw,如何多次调用 kill-region 以便连接被杀死的文本?因为典型的工作流程是 kill-region(Cw),然后是 move-cursor,然后是 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."
4

1 回答 1

4

文档指的是命令,而不是函数。命令是启动命令循环的函数。

任何调用此函数的命令都是“kill command”。如果前一个命令也是一个 kill 命令,则本次被杀死的文本会附加到上次被杀死的文本以在 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 "

我期望的是,由于我使用了 kill-region 2 次,因此被杀死的文本应该在 kill-ring 中连接为一个。

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

于 2013-05-14T10:14:21.097 回答