【发布时间】:2013-11-24 22:10:06
【问题描述】:
这里有两个命令可以向前删除一个句子(不保存到 kill ring)。第一个基于 EmacsWiki Elisp Cookbook 中的示例,后者与前者类似,只是调用 save-excursion 的位置不同。
;; good with undo
(defun my-test-1 ()
(interactive)
(delete-region (point)
(save-excursion
(forward-sentence 1)
(point))))
;; bad with undo
(defun my-test-2 ()
(interactive)
(save-excursion
(delete-region (point)
(progn
(forward-sentence 1)
(point)))))
当我运行第一个命令然后撤消它时,point 会出现在正确的位置,而第二个命令则不是这样。为什么会出现这种差异?
【问题讨论】: