我运行的是Aquamacs + Slime,当我启动Aquamacs时,我能够自动启动Slime。然而,之后当我尝试加载一个lisp文件时,根据我尝试加载该文件的方式,我一直收到各种错误。这是我的preferences.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")
)) 我得到以下错误
error: Buffer *inferior-lisp* is not associated with a file.我尝试过其他函数,包括load、compile-and-load和slime-load-file,分别得到以下错误...
Invalid read syntax: #
Symbol's function definition is void: compile-and-load
error: Not connected.当我从slime REPL执行(load "/Users/xxxxx/xxxxx/load-seq.lisp")时,lisp文件加载(和编译)得很好。虽然我使用的是eval-after-load,但似乎当我把它放到Preferences.el中时,它并不等待粘液加载。
发布于 2012-08-11 02:36:57
您碰巧误解了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包含当SLIME连接到Lisp服务器时要调用的函数的列表。
但是我不确定Emacs init文件是否是加载这种非Emacs Lisp代码的正确位置。CCL init文件将是一个更好的地方。请参阅CCL手册中的2.4. Personal Customization with the Init File。
此外,load函数用于执行Emacs Lisp代码。slime-load-file是一个可以调用的正确函数,但它恰好被调用得太早了(或者在SLIME连接到Lisp服务器之前)。如果它被添加到slime-connected-hook钩子中,它就可以工作了。实际上,如果您没有正当理由在每次启动Emacs时编译Lisp代码,我建议您使用slime-load-file而不是slime-compile-and-load-file (同样,您确实想在Emacs中这样做):
(add-hook 'slime-connected-hook
(lambda ()
(slime-load-file "/Users/xxxxx/xxxxx/load-seq.lisp")))最后,没有名为compile-and-load的函数。
https://stackoverflow.com/questions/11785890
复制相似问题