質問

I'm running Aquamacs + Slime and I'm able to start Slime automatically when I start Aquamacs. However, when I try to load a lisp file after that I keep getting various errors depending on how I'm trying to load the file. Here's my 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")
 )) 

I get the following error

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

I've tried other functions including load compile-and-load and slime-load-file and got the following errors respectively...

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

The lisp file loads (and compiles) fine when I do (load "/Users/xxxxx/xxxxx/load-seq.lisp") from the slime REPL. It seems like when I put it in Preferences.el, it does not wait for slime to load even though I'm using eval-after-load.

役に立ちましたか?

解決

You happened to misunderstand the use of the slime-compile-and-load-file function. Its docstring says:

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

Compile and load the buffer's file and highlight compiler notes.

The function operates on a file which is already associated with the current buffer, and it expects a compiling policy, not a filename, as its (optional) argument. So your code should have been like this:

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

where slime-connected-hook contains a list of functions to be called when SLIME connects to a Lisp server.

But I'm not sure if the Emacs init file is a right place to load such a non-Emacs Lisp code. The CCL init file would be a better place to do it. Refer to 2.4. Personal Customization with the Init File in the CCL manual.

Additionally, the load function is for executing a Emacs Lisp code. slime-load-file is a right function to call, but it happened to be called too early (or before SLIME connects to a Lisp server). It would have worked if it had been added to the slime-connected-hook hook. Actually, I'd like to recommend slime-load-file over slime-compile-and-load-file if you don't have a valid excuse for compiling the Lisp code whenever you start Emacs (and again you really want to do it in Emacs):

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

Finally, there is no function called compile-and-load.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top