[slime-devel] Is there a good way to handle multiple "current directories"?

Tamas Papp tkpapp at gmail.com
Mon Nov 21 09:38:09 UTC 2011


On Sun, 20 Nov 2011 09:54:55 -0800, Jeffrey Cunningham wrote:

> I keep running into to this rather trivial but annoying problem while
> working in slime. Emacs is running (of course), and god only knows what
> directory I was in when I started it up days ago. I am often working on
> more than one project, or I will be looking for some piece of data in a
> folder other than what Slime considers the "current directory" (which I
> usually determine by M-x d and looking to see where it's at). Whatever
> the case, if I want to run a few lines of code that access a different
> directory than the "current" one, I end up doing various ad hoc things,
> like figuring out the relative path between where it is and where I want
> it to be, or just typing out a fully-qualified pathname.
> 
> Is there a way to do this more easily?
> 
> I know that if I put something like
> 
> (defparameter *i-am-here*
>    (make-pathname :name nil :type nil :version nil :defaults
> (parse-namestring *load-truename*)))
> 
> in a file located in the directory I'm looking at, that the parameter
> will be set correctly when the file is loaded. But that begs the
> question, since I have to know where that file is to load it.
> 
> What I'd like to be able to do would be something like this:
> 
> (with-open-file (fs (merge-pathnames "data.file"
> (directory-of-file-buffer)) :direction :input)
>    ;; do stuff
> )
> 
> How do other people handle this situation?

Hi Jeffrey,

I usually make an ASD file to load my project (BTW, it is really easy
to do a skeleton with Quickproject), and then use
asdf:system-relative-pathname.  It is documented here:
http://common-lisp.net/project/asdf/asdf/Miscellaneous-additional-functionality.html

HTH,

Tamas





More information about the slime-devel mailing list