2012-01-30 83 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對函數和變量有不同的命名空間。