似乎以任何方式改变缓冲区,阻止 defun 激活标记:
(defun mark-five-next ()
"Marks the next five chars as expected"
(interactive)
(push-mark (+ 5 (point)) t t))
(defun insert-an-a-then-mark-five-next ()
"Does not mark the next five chars"
(interactive)
(insert "a")
(push-mark (+ 5 (point)) t t))
我更喜欢一种方法来解决它,但只是一个解释也很好。
最佳答案
事实证明,所有编辑命令都设置了 var deactivate-mark
在命令完成后执行此操作。
为避免这种行为,您必须将缓冲区更改函数包装在 let
中。 -statement,防止全局变化deactivate-mark
变种
(let (deactivate-mark)
(...))
我在这个问题上花了一个多小时,因为我刚刚跳过停用标记在手册中,以为是对功能的描述。当然,正如我已经知道的,但现在已经正确了解:emacs lisp 为函数和变量提供了不同的命名空间。
关于Emacs:在交互式命令中激活标记的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9069514/