【问题标题】:Aquamacs+slime: Loading a lisp file at startupAquamacs+slime:在启动时加载一个 lisp 文件
【发布时间】:2012-08-02 21:14:50
【问题描述】:

我正在运行 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")
 )) 

我收到以下错误

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.

当我从 slime REPL 执行 (load "/Users/xxxxx/xxxxx/load-seq.lisp") 时,lisp 文件可以正常加载(和编译)。好像当我把它放在 Preferences.el 中时,即使我使用的是eval-after-load,它也不会等待粘液加载。

【问题讨论】:

    标签: emacs slime aquamacs


    【解决方案1】:

    你碰巧误解了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 初始化文件是否是加载此类非 Emacs Lisp 代码的正确位置。 CCL 初始化文件将是一个更好的地方。参考CCL手册中的2.4. Personal Customization with the Init File

    此外,load 函数用于执行 Emacs Lisp 代码。 slime-load-file 是一个正确的函数调用,但它碰巧被调用得太早(或者在 SLIME 连接到 Lisp 服务器之前)。如果它被添加到slime-connected-hook 钩子中,它就会起作用。实际上,如果您在启动 Emacs 时没有正当理由编译 Lisp 代码(而且您真的想在 Emacs 中这样做),我更愿意推荐 slime-load-file 而不是 slime-compile-and-load-file

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-07
      • 1970-01-01
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 2019-02-06
      相关资源
      最近更新 更多