【问题标题】:emacs, how to invoke kill-region several times?emacs,如何多次调用kill-region?
【发布时间】:2013-05-14 09:06:50
【问题描述】:

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

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

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

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

  • 使用键盘 C-w,如何多次调用 kill-region 以连接被杀死的文本?因为典型的工作流程是 kill-region(C-w),然后移动光标,然后再次 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."

【问题讨论】:

  • 您能否链接您在文档中的何处找到信息?
  • 对我来说,它只有在键盘上重复 C-k 后才能工作。
  • 在kill-region函数的定义中。 (我正在阅读 lisp 介绍)

标签: emacs lisp


【解决方案1】:

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

任何调用此函数的命令都是“kill command”。 如果前面的命令也是 kill 命令, 这次杀死的文本附加到上次杀死的文本 进入杀戮圈。

这并不意味着kill-region 本身。它是说任何调用 kill-region 函数变成一个“kill 命令”(包括 kill-region 本身)。例如。 kill-linekill-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 但不是作为命令。这两个电话都发生了 在同一个命令循环中运行。

【讨论】:

  • 你的意思是当它在 lisp 中调用时被认为是一个函数,而在使用键盘调用时它被认为是一个命令?
  • 戴维:你应该关注 event_jr 的链接了解详情(或C-h i g (elisp) Command Loop RET
猜你喜欢
  • 2010-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-25
  • 1970-01-01
  • 2020-12-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多