2012-08-02 26 views
0

我正在運行Aquamacs + Slime,當我啓動Aquamacs時,我可以自動啓動Slime。但是,當我嘗試加載lisp文件後,我不斷收到各種錯誤,具體取決於我如何加載文件。這裏是我的preferences.elAquamacs + slime:在啓動時加載一個lisp文件

(setq inferior-lisp-program "~/ccl/dx86cl64" 
    slime-startup-animation nil) 
(require 'slime) 
(split-window-horizontally) 
(other-window 1) 
(slime) 
(eval-after-load "slime" 
    '(progn 
     (slime-compile-and-load-file "/Users/xxxxx/xxxxx/load-seq.lisp") 
)) 

我收到以下錯誤

error: Buffer *inferior-lisp* is not associated with a file. 

我試過其它功能,包括loadcompile-and-loadslime-load-file分別得到了以下錯誤...

Invalid read syntax: # 
Symbol's function definition is void: compile-and-load 
error: Not connected. 

lisp文件加載(並編譯)罰款,當我從泥漿REPL (load "/Users/xxxxx/xxxxx/load-seq.lisp")。看起來好像當我把它放在Preferences.el中時,即使我使用eval-after-load,它也不會等待粘液加載。

回答

5

您碰巧誤解了slime-compile-and-load-file函數的使用。它的文檔字符串說:

(slime-compile-and-load-file &optional POLICY)

編譯並加載緩衝的文件和亮點編譯器的筆記。

函數對已經與當前緩衝區關聯的文件進行操作,它期望編譯策略而不是文件名作爲其(可選)參數。所以,你的代碼應該是這樣的:

(slime) 
(add-hook 'slime-connected-hook 
      (lambda() 
      (find-file "/Users/xxxxx/xxxxx/load-seq.lisp") 
      (slime-compile-and-load-file))) 

其中slime-connected-hook包含的功能列表時,泥連接到一個Lisp服務器被調用。

但我不確定Emacs init文件是否可以加載這樣的非Emacs Lisp代碼。 CCL初始化文件將是一個更好的地方。請參閱CCL手冊中的2.4. Personal Customization with the Init File

此外,load函數用於執行Emacs Lisp代碼。 slime-load-file是一個正確的函數調用,但它恰好被稱爲太早(或在SLIME連接到Lisp服務器之前)。如果它已被添加到slime-connected-hook鉤子,它會起作用。其實,我想推薦slime-load-file超過slime-compile-and-load-file如果你沒有編譯當你啓動Emacs Lisp的代碼的一個有效的藉口(和再次你真的想這樣做,在Emacs):

(add-hook 'slime-connected-hook 
      (lambda() 
      (slime-load-file "/Users/xxxxx/xxxxx/load-seq.lisp"))) 

最後,沒有稱作compile-and-load的功能。

相關問題