Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set SBCL's current directory using slime?

In the past, i use the following script to start SBCL:

breakchars="(){}[],^%$#@\"\";:''|\\"
cd /media/E/work

exec rlwrap --remember -c -b "$breakchars"  -f "$HOME"/.sbcl_completions  sbcl --noinform --userinit "$HOME"/.sbclrc "$@"

Now when using slime in emacs, i doonot know how to set SBCL's current directory ?

Any suggestion is appreciated!

like image 312
z_axis Avatar asked Feb 23 '12 23:02

z_axis


2 Answers

SLIME starts the Lisp system with the current directory taken from the directory where the file associated with the current buffer is. Typically you would open a file where you want SLIME to start first.

If you want to change the current directory a running Lisp then the best way is to use ,cd shortcut. This assumes you have a proper slime-repl set up, since current Slime installations are very minimal by default. See contributed packages, you probably want at least slime-fancy metapackage.

like image 108
Ramarren Avatar answered Dec 27 '22 10:12

Ramarren


Why do you need to change the current directory from SLIME? I assume it's not because you want to visit a Lisp source file from the system you're currently writing, but because you want write code that reads or writes a file that contains data.

If so, it's probably better to try local-projects in Quicklisp. Together with quickproject, it allows you to easily create systems, which you can then load using (ql:quickload 'my-system) or even (require 'my-system).

If you need to refer to a data file located relative to the root of system my-system (just using the name from the last paragraph to keep examples consistent), you could use asdf:system-relative-pathname. For instance, (asdf:system-relative-pathname 'my-system "files/data.txt").

Sure, deployment is a completely different business. My solution is to look at how the running executable was called to determine if the code is deployed or in development. If in development, I use asdf:system-relative-pathname. If deployed, I determine the path of the files based on the path of the executable (my 'build script' copies these files next to the executables when building the project).

Since I started using this approach, my need for cd-ing in SBCL dropped to zero. cd-ing around wasn't hard, but it's nice to have less things to worry about.

like image 24
Miron Brezuleanu Avatar answered Dec 27 '22 10:12

Miron Brezuleanu