2013-02-04 31 views
0

我在第一個練習部分(Emacs Lisp Intro)中,我沒有得到它; 3.12練習:在elisp中我如何從變量中提取值

編寫一個函數,測試當前值爲'fill-column'的 是否大於傳遞給函數的參數,如果是,則打印一條適當的消息。

我:

(defun is-fill-equal (number) 
    "Is fill-column greater than the argument passed to the function." 
    (interactive "p") 
(if (= fill-column number) 
    (message "They are equal.") 
    (message "They are not equal.")) 

無論我怎麼努力,我得到這個錯誤:

調試器中輸入 - Lisp的錯誤:(無效變量個數)

回答

3

你缺少一個括號最後。嘗試:

(defun is-fill-equal (number) 
    "Is fill-column greater than the argument passed to the function." 
    (interactive "p") 
    (if (= fill-column number) 
     (message "They are equal.") 
    (message "They are not equal."))) 

的原因錯誤消息是,你可能C-x e在函數定義的末尾。由於缺少一個括號,Emacs認爲您要評估的表達式爲(if (= fill-column number) ...),並且number在該上下文中未被綁定。

+0

謝謝。我嘗試了幾個變化,但不斷重複同樣的錯誤。 – elisporbust

+0

使用'show-paren-mode'可能對未來有所幫助;)。 – mbork