From: mark carroll
Subject: Changing current directory
Date: 
Message-ID: <7proll$iqn$1@news.cis.ohio-state.edu>
How do I change the current directory, for relative pathnames
for subsequent invocations of 'load' and the like?

This should be easy IMO, but so far I'm drawing a blank...

-- Mark

From: Barry Margolin
Subject: Re: Changing current directory
Date: 
Message-ID: <c7ew3.352$m84.6235@burlma1-snr2>
In article <············@news.cis.ohio-state.edu>,
mark carroll <·······@cis.ohio-state.edu> wrote:
>How do I change the current directory, for relative pathnames
>for subsequent invocations of 'load' and the like?
>
>This should be easy IMO, but so far I'm drawing a blank...

Common Lisp doesn't have a notion of "current directory", although most
implementations on OS'es that have such a notion provide an extension that
lets you query/change it.

Common Lisp has the variable *DEFAULT-PATHNAME-DEFAULTS*, which is a
pathname that is merged into pathnames that the user enters.  It serves a
purpose similar to that of the current directory.  If this is a relative
pathname (as I suspect many systems initialize it to) then the OS's current
directory will be applied after merging.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Steve Gonedes
Subject: Re: Changing current directory
Date: 
Message-ID: <m27lmljow3.fsf@KludgeUnix.com>
·······@cis.ohio-state.edu (mark carroll) writes:

< How do I change the current directory, for relative pathnames
< for subsequent invocations of 'load' and the like?
< 
< This should be easy IMO, but so far I'm drawing a blank...
< 
< -- Mark

(defun default-directory ()
  #+cmu (default-directory)
  #+clisp (lisp:default-directory)
  #+excl (excl:current-directory)
  #+gcl (truename "."))

#+clisp (defsetf default-directory lisp:cd)
#+excl (defsetf default-directory excl:chdir)
#+gcl (defsetf default-directory si:chdir)
#+lww (defsetf default-directory change-directory) ; forget what package

Also in acl you can use `:cd <dirname>', and :pwd at the toplevel.
From: Mark Carroll
Subject: Re: Changing current directory
Date: 
Message-ID: <LEz*uHk8n@news.chiark.greenend.org.uk>
Wonderful! Thank you very much indeed. (-:

-- Mark
From: Marco Antoniotti
Subject: Re: Changing current directory
Date: 
Message-ID: <lwogfx2ko8.fsf@copernico.parades.rm.cnr.it>
Steve Gonedes <········@worldnet.att.net> writes:

> ·······@cis.ohio-state.edu (mark carroll) writes:
> 
> < How do I change the current directory, for relative pathnames
> < for subsequent invocations of 'load' and the like?
> < 
> < This should be easy IMO, but so far I'm drawing a blank...
> < 
> < -- Mark
> 
> (defun default-directory ()
>   #+cmu (default-directory)

    #+:cmu (ext:default-directory) ; More "correct".  I UNUSE the EXT package.


>   #+clisp (lisp:default-directory)
>   #+excl (excl:current-directory)
>   #+gcl (truename "."))
> 
> #+clisp (defsetf default-directory lisp:cd)
> #+excl (defsetf default-directory excl:chdir)
> #+gcl (defsetf default-directory si:chdir)
> #+lww (defsetf default-directory change-directory) ; forget what package
> 
> Also in acl you can use `:cd <dirname>', and :pwd at the toplevel.
> 


I would also call the function CURRENT-DIRECTORY instead of
DEFAULT-DIRECTORY.

Finally, what about

	#+:mcl

?

Cheers

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Kent M Pitman
Subject: Re: Changing current directory
Date: 
Message-ID: <sfwhflpj7ep.fsf@world.std.com>
Marco Antoniotti <·······@copernico.parades.rm.cnr.it> writes:

> 
> Steve Gonedes <········@worldnet.att.net> writes:
> 
> >   #+cmu (default-directory)
> 
>     #+:cmu (ext:default-directory) ; More "correct".  I UNUSE the EXT package.

By the way, #+:cmu is not supposed to be needed, unless you know something
about cmu bugs that I don't.  #+cmu is sufficient.
#+ and #- bind *package* to the keyword package by default while
reading the read-time conditional expression.
There could, of course, be implementations that force you to violate this
because they don't read the conditional in the right package.  But one
should not use baroque notation where it is not needed, IMO.
From: Marco Antoniotti
Subject: Re: Changing current directory
Date: 
Message-ID: <lwr9ksjmq6.fsf@copernico.parades.rm.cnr.it>
Kent M Pitman <······@world.std.com> writes:

> Marco Antoniotti <·······@copernico.parades.rm.cnr.it> writes:
> 
> > 
> > Steve Gonedes <········@worldnet.att.net> writes:
> > 
> > >   #+cmu (default-directory)
> > 
> >     #+:cmu (ext:default-directory) ; More "correct".  I UNUSE the EXT package.
> 
> By the way, #+:cmu is not supposed to be needed, unless you know something
> about cmu bugs that I don't.  #+cmu is sufficient.
> #+ and #- bind *package* to the keyword package by default while
> reading the read-time conditional expression.

That is very interesting. I should read the read time conditional spec
more carefully.

> There could, of course, be implementations that force you to violate this
> because they don't read the conditional in the right package.  But one
> should not use baroque notation where it is not needed, IMO.

It is just a matter of habit.  After all you get a keyword
syntax when printing the value of *FEATURE* while being in
COMMON-LISP-USER.  The admittedly more baroque version is definitively
"safer".  (Give that you should use read-time conditionals in a very
limited fashion).

Cheers


-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Kent M Pitman
Subject: Re: Changing current directory
Date: 
Message-ID: <sfwiu63rbsi.fsf@world.std.com>
Marco Antoniotti <·······@copernico.parades.rm.cnr.it> writes:

> The admittedly more baroque version is definitively
> "safer".

I claim not, since you really can never use this at all without going
to the actual implementation in question and looking on its feature
list to see what is there.  (And sometimes going to all other implementations
you plan to to make sure the feature is NOT there.  The CCL feature is
notorious in this regard, Harlequin having used it for Cambridge Common
Lisp and the Mac having used to for Coral Common Lisp (not sure of the
spelling).)  Once you've verified  that it works in the relevant 
implementation, it's not like that implementation's going to change.  
I guess if it failed to work in that implementation, you'd imagine they
might fix it--but if it works right, you wouldn't hope they'd break it.
So I think the safety issue is not as much as it might seem at first glance.

> (Give that you should use read-time conditionals in a very
> limited fashion).

More limited than you're thinking, I'm guessing.
From: R. Matthew Emerson
Subject: Re: Changing current directory
Date: 
Message-ID: <87aergnaq5.fsf@nightfly.apk.net>
Marco Antoniotti <·······@copernico.parades.rm.cnr.it> writes:

> Steve Gonedes <········@worldnet.att.net> writes:
> 
> > (defun default-directory ()
> >   #+cmu (default-directory)
> >   #+clisp (lisp:default-directory)
> >   #+excl (excl:current-directory)
> >   #+gcl (truename "."))
> > 
> > #+clisp (defsetf default-directory lisp:cd)
> > #+excl (defsetf default-directory excl:chdir)
> > #+gcl (defsetf default-directory si:chdir)
> > #+lww (defsetf default-directory change-directory) ; forget what package

> Finally, what about
> 
> 	#+:mcl
> 

MCL uses the following:

For default-directory: (ccl:mac-default-directory)
To set default directory: (ccl:set-mac-default-directory pathname)

One weird thing to watch out for is that desk accessories and
background processes can change the mac-default-directory out from
under you.

-matt