Aquamacs + slime:在启动时加载lisp文件

Wan*_*Phd 0 emacs aquamacs slime

我正在运行Aquamacs + Slime,当我启动Aquamacs时,我可以自动启动Slime.但是,当我尝试加载lisp文件后,我会不断收到各种错误,具体取决于我是如何尝试加载文件的.这是我的偏好.el

(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")
 )) 
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

error: Buffer *inferior-lisp* is not associated with a file.
Run Code Online (Sandbox Code Playgroud)

我尝试了其他功能,包括load compile-and-loadslime-load-file分别得到以下错误......

Invalid read syntax: #
Symbol's function definition is void: compile-and-load
error: Not connected.
Run Code Online (Sandbox Code Playgroud)

当我(load "/Users/xxxxx/xxxxx/load-seq.lisp")使用粘液REPL 时,lisp文件加载(并编译)很好.看起来当我把它放在Preferences.el中时,即使我正在使用它也不会等待粘液加载eval-after-load.

dki*_*kim 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)))
Run Code Online (Sandbox Code Playgroud)

其中slime-connected-hook包含SLIME连接到Lisp服务器时要调用的函数列表.

但是我不确定Emacs init文件是否是加载这种非Emacs Lisp代码的正确位置.CCL init文件是一个更好的地方.参见2.4.使用 CCL手册中的Init文件进行个人自定义.

此外,该load函数用于执行Emacs Lisp代码.slime-load-file是一个正确的调用函数,但它恰好被调用得太早(或者在SLIME连接到Lisp服务器之前).如果将它添加到slime-connected-hook钩子中它会起作用.其实,我想推荐slime-load-fileslime-compile-and-load-file,如果你没有编译每次启动Emacs的(和再次你真的想这样做,在Emacs)的Lisp代码有效的借口:

(add-hook 'slime-connected-hook
          (lambda ()
            (slime-load-file "/Users/xxxxx/xxxxx/load-seq.lisp")))
Run Code Online (Sandbox Code Playgroud)

最后,没有调用函数compile-and-load.