2013-04-08 94 views
2

當我在緩衝區按下C-c c以下代碼時,Emacs以Invalid function: (select-current-line)抱怨。爲什麼?Emacs抱怨無效功能?

(defun select-current-line() 
    "Select the current line" 
    (interactive) 
    (end-of-line) ; move to end of line 
    (set-mark (line-beginning-position))) 

(defun my-isend() 
    (interactive) 

    (if (and transient-mark-mode mark-active) 
     (isend-send) 

    ((select-current-line) 
    (isend-send))) 
) 

(global-set-key (kbd "C-c c") 'my-isend) 

並不重要,但對於那些有興趣isend-send在這裏定義。

+0

只是出於好奇,你爲什麼要這樣做?調用沒有活動區域的isend-send已經發送了當前行,所以我不明白你想要實現哪種行爲。無論如何,請隨時在[github]上打開功能請求(https://github.com/ffevotte/isend-mode.el)... – Francesco 2013-04-08 14:03:44

回答

10

你缺少一個progn形式語句組合到一起:

(defun my-isend() 
    (interactive) 

    (if (and transient-mark-mode mark-active) 
     (isend-send) 

    (progn 
     (select-current-line) 
     (isend-send)))) 

沒有progn形式,((select-current-line) (isend-send))被解釋爲適用於呼叫isend-send不帶參數的結果(select-current-line)功能。但(select-current-line)不是有效的函數名稱。在其他LISP中,如果select-current-line的返回值本身是一個函數,那麼這樣的結構可能是有效的,然後將其應用於(isend-send)。但是這不是Emacs LISP的情況,這不會做你想達到的目的......