1

I have emacs / sbcl / slime working.

I'm going through a tutorial and hit the following example:

CL-USER> (load "hello.lisp")
; Loading /home/peter/my-lisp-programs/hello.lisp

The author doesn't specify how or where he set things up to default the load location to his example.

I've tried creating the EMACSLOADPATH environment variable and have tried a setq for load-path all with no positive results.

If I load a .lisp file using the entire path as in /home/bill/lisp/hello.lisp, it load and I can run it. Id like to know how and where to set the default to "~/lisp" so I can avoid an absolute path reference.

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
Bill Gradwohl
  • 385
  • 4
  • 18
  • 1
    By that example, it seems you're reading chapter 2 of "Practical Common Lisp" by Peter Seibel. Footnote 13 in that chapter says "...use the SLIME shortcut cd to change Lisp's idea of the current directory--type a comma and then cd when prompted for a command and then the name of the directory where hello.lisp was saved." – Joseph Thvedt Nov 02 '21 at 15:16

1 Answers1

1

Before the answer, EMACSLOADPATH (or load-path) isn't related to common-lisp or sbcl (which is a common-lisp implementation). It is an emacs related variable. The root of the confusion is understandable, as emacs is a tool build on its own variant of lisp, elisp, and you write elisp code to extend or configure emacs. Emacs tool has its own elisp engine that runs those elips commands. And then you start using emacs as an editor to write common-lisp code, using plugins like slime to make it easier to interact with sbcl interpreter (or any other slime compatible common-lisp interpreter, for that matter).

For the default load location of common-lisp, load function of sbcl uses *default-pathname-defaults* to form the pathname from the argument, and it is generally set to the current directory (by slime at least - check swank:set-default-directory).

However, if you want an approach similar to python's import, where the function uses a list of directories to search for, I believe there are two options to start with.

  1. Use quicklisp or asdf, as they are equivalent to python-import, but that probably means you define a 'system' (python: 'module') and use asdf:load-system. Here is an answer for this solution: example of using external libs in common-lisp
  2. Write a load function yourself, and search for a predefined list of directories for the file name, and form an absolute path then call cl:load with the absolute path you decide.
AlbusMPiroglu
  • 645
  • 3
  • 13