Change default save folder in LispBox

205 Views Asked by At

So I've finally decided to learn Lisp. I'm reading Practical Common Lisp and I'm using Lispbox (not the one the book recommends - it's no longer available, but it seems this is suitable nonetheless).

So far in my career I have managed to avoid wresting with emacs, but I guess that part of my life is over :-) Actually, I'm kind of excited - this is a brand new world.

When saving .lisp files, the out-of-the-box setup dumps these files into the lispbox-0.7 folder (which is also the LISPBOX_HOME env.var). My math teacher taught me, "If you don't know what you're doing, at least do it neatly." So I want to at least keep my work in a nice tidy folder. I can specify the full path on saving/loading. But can I tell (lispbox|emacs|whatever) to use a different folder by default?

If it matters: I will likely use the Windows version more often, but I also have a setup on Ubuntu.

I have looked at this and this and this. I tried adding these to the .emacs file (one at a time):

(setq default-directory "C:/Work/lisp/")    
(cd "C:/Work/lisp/")

To open the .emacs file I used C-x C-f~/.emacs

If I try changing the LispBox shortcut's "Start in" property, it fails to load at all.

M-xcd c:/work/lisp does work, but I have to do it every time I launch LispBox

What I'm doing in the meantime: I've created a separate lisp folder beside the lispbox-0.7 folder. That way I can prepend ../lisp/ before any filename. This isn't so bad, especially with the tab auto-complete.

3

There are 3 best solutions below

0
On BEST ANSWER

Found it!

The reason modifying .emacs wasn't working is because of the lispbox.bat file. It has this line:

%EMACS% --no-init-file --no-site-file --eval=%TO_EVAL%

So took out the two "no" parameters, leaving this...

%EMACS% --eval=%TO_EVAL%

...and it worked.

This worried me, though. Why would the default not want to load the .emacs file? I guess once I understand all of this better I'll have an answer. Until then, I restored the above, the changed this line...

set TO_EVAL="(progn (load \"lispbox\") (slime))"

...to this...

set TO_EVAL="(progn (load \"lispbox\") (slime) (cd \"C:/work/lisp/\"))"

Now I'm happy.

4
On

I know nothing about Lisp Box, and not all of what you describe is clear to me. But here goes.

It sounds like you are looking for a way to make c:/work/lisp the default directory when you start Emacs. For that, using an MS Windows shortcut, putting that folder in the Start in field does indeed accomplish that. But you speak of a LispBox shortcut's Start in. If by that you just mean an Emacs shortcut, then it should work.

But of course you need to use Windows syntax for the folder - not c:/work/lisp, but c:\work\lisp.

Is that what the problem was?

The Windows shortcut is a Windows thing. Emacs is different: it accepts / as a folder separator.


Tip: If that solves your problem, you might also want to start Emacs in Dired mode on that same folder, that is, if that folder is the one you will use a lot. To do that, add that folder at the end of the command line - again, using Windows syntax, but between double-quotes:

c:\your\path\to\runemacs.exe "c:\work\lisp"
0
On

Try starting lispbox.bat from the directory you want to save files to. For example, from the OS command prompt:

cd c:\work\lisp
path-to-bat-file\lispbox.bat

You can also cd to c:\work\lisp in listbox.bat before it executes Emacs. For Linux it looks like this in lispbox.sh:

#!/bin/bash
if [ "${0:0:2}" = "./" ]; then
    export LISPBOX_HOME=`pwd`/../../..
else
    export LISPBOX_HOME=`dirname $0`/../../..
fi
cd ~/work/lisp
export SBCL_HOME=${LISPBOX_HOME}/sbcl-1.0.42/lib/sbcl
exec ${LISPBOX_HOME}/Emacs.app/Contents/MacOS/Emacs --no-init-file --no-site-file --eval='(progn (load "lispbox") (slime))'