首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Aquamacs+slime:启动时加载lisp文件

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

Stack Overflow用户
提问于 2012-08-03 05:14:51
回答 1查看 1.1K关注 0票数 0

我运行的是Aquamacs + Slime,当我启动Aquamacs时,我能够自动启动Slime。然而,之后当我尝试加载一个lisp文件时,根据我尝试加载该文件的方式,我一直收到各种错误。这是我的preferences.el

代码语言:javascript
复制
(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")
 )) 

我得到以下错误

代码语言:javascript
复制
error: Buffer *inferior-lisp* is not associated with a file.

我尝试过其他函数,包括loadcompile-and-loadslime-load-file,分别得到以下错误...

代码语言:javascript
复制
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中时,它并不等待粘液加载。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-11 02:36:57

您碰巧误解了slime-compile-and-load-file函数的用法。它的文档字符串是:

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

编译并加载缓冲区的文件,并突出显示编译器注释。

该函数对一个已经与当前缓冲区关联的文件进行操作,它需要一个编译策略作为它的(可选)参数,而不是一个文件名。所以你的代码应该是这样的:

代码语言:javascript
复制
(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中这样做):

代码语言:javascript
复制
(add-hook 'slime-connected-hook
          (lambda ()
            (slime-load-file "/Users/xxxxx/xxxxx/load-seq.lisp")))

最后,没有名为compile-and-load的函数。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11785890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档