2012-01-30 99 views
4

好像改变缓冲以任何方式激活标志的问题,从激活的标记停止defun定义:Emacs的:在一个交互式命令

(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)) 

我喜欢的方式来解决这个问题,但只是一个解释也很好。

回答

7

事实证明,所有的编辑命令都设置了vardeactivate-mark这只是在命令完成后才做的。

为了避免这种情况,你必须包装缓冲,改变功能于一身let语句来,防止全球deactivate-mark VAR的变化。

(let (deactivate-mark) 
    (...)) 

我花了在这个问题上一个小时,因为我只是在手册中跳过停用标志,认为它是功能的描述。当然,正如我已经知道的那样,但现在已经学会了:emacs lisp对函数和变量有不同的命名空间。