2012-08-13 80 views
-1

我想寫一個小腳本,當有人跟我說話的時候通知我。所以我需要寫一個函數來接收我認爲是兩個字符串,nick和msg,這樣我就可以掛鉤了。但是我的測試功能失敗了。我已經測試了growl-notify和格式s-expresions,它們工作正常,但是我無法通過測試工作。我不知道它爲什麼失敗。任何指針?Elisp幫助。爲什麼下面的代碼片斷失敗?

(defun growl-notify (&key message) 
    "Use growl for notifications" 
    (start-process "growlnotify" "growlnotifications" "growlnotify" "-m " message)) 

(defun test (nick msg) 
    (growlnotify :message (format "%s: %s" nick msg))) 

(test "Ppop" "something") 

它給出了以下回溯,希望它有幫助。

Debugger entered--Lisp error: (void-function growlnotify) 
    (growlnotify :message (format "%s: %s" nick msg)) 
    test("oi" "poi") 
    eval((test "oi" "poi") nil) 
    eval-last-sexp-1(t) 
    eval-last-sexp(t) 
    eval-print-last-sexp() 
    call-interactively(eval-print-last-sexp nil nil) 
    recursive-edit() 
    debug(error (wrong-number-of-arguments (lambda (&key message) "Use growl for notifications" (start-process "growlnotify" "growlnotifications" "growlnotify" "-m " message)) 3)) 
+0

s/Pop/oi /和s/something/poi/ – PuercoPop 2012-08-13 06:53:46

+2

您調用函數'growl-notify',但試圖將其作爲'growlnotify'調用。 – tripleee 2012-08-13 07:14:08

+0

Thanks @tripleee:$ – PuercoPop 2012-08-13 16:09:41

回答

1

該錯誤消息是Debugger entered--Lisp error: (void-function growlnotify),它告訴你growlnotify沒有被定義爲的函數。

如果你看看你的代碼,你會發現你定義它是這樣的:​​,它定義了一個函數growl-notify。一個簡單的錯字。