Re: During (load), get the directory in which the .lisp file resides



On Feb 17, 2:40 pm, Pascal Bourguignon <p...@xxxxxxxxxxxxxxxxx> wrote:
joubert....@xxxxxxxxx writes:
E.g., Someone calls my file like this:

(load "/home/ublang/projects/gofer.lisp")

Then, within gofer.lisp, how do I determine the directory it is stored
in (not the OS notion of 'current directory')?

(pathname-directory *load-pathname*)

Or perhaps preferably:

(make-pathname :name nil :type nil :version nil
:defaults *load-pathname*)

if what you want is a pathname...

Of course, depending on what you want to do with the directory
pathname, you could as well just keep *load-pathname* and make or
merge pathnames with it.

--
__Pascal Bourguignon__ http://www.informatimago.com/

READ THIS BEFORE OPENING PACKAGE: According to certain suggested
versions of the Grand Unified Theory, the primary particles
constituting this product may decay to nothingness within the next
four hundred million years.

Great; thanks for your input, Pascal.

I'm now doing this:

(load (make-pathname :name "config" :type "lisp"
:directory (pathname-directory *load-pathname*)))

and it works beautifully. When this file gets loaded it now correctly
resolves and loads "config.lisp".

Cheers
Joubert


.