From: Futu Ranon on
I am running CL on Windows and Mac and have a configuration file that I'd
like to share between them. I want to do something like the following:
http://paste.lisp.org/display/96300

I am using cygwin on Windows so I want to use that as the user's home-dir.

1. Is this the correct way to make use of CL pathnames? I switched from
the use of strings so this still feels foreign.
2. Is there a way to go about the two asdf:*central-registry* updates I do
at the end of the let*? As far as I understand it, the asdf package is not
yet loaded so I cannot push on to *central-registry* inside that let*
binding. Is that correct? Do I have recourse other than to roughly
duplicate the let* in order to do the asd file search and pushnew?

Thank you.
From: Pascal J. Bourguignon on
"Futu Ranon" <futuranon(a)gmail.com> writes:

> I am running CL on Windows and Mac and have a configuration file that
> I'd like to share between them. I want to do something like the
> following:
> http://paste.lisp.org/display/96300
>
> I am using cygwin on Windows so I want to use that as the user's home-dir.
>
> 1. Is this the correct way to make use of CL pathnames? I switched
> from the use of strings so this still feels foreign.
> 2. Is there a way to go about the two asdf:*central-registry* updates
> I do at the end of the let*? As far as I understand it, the asdf
> package is not yet loaded so I cannot push on to *central-registry*
> inside that let* binding. Is that correct? Do I have recourse other
> than to roughly duplicate the let* in order to do the asd file search
> and pushnew?


What about (user-homedir-pathname)?

$ for h in galatea hubble galle ; do ssh -n $h clisp -ansi -norc -q -E iso-8859-1 -x "'(progn (ext:run-program \"uname\" :arguments (quote (\"-a\"))) (princ (user-homedir-pathname)) (terpri) (finish-output) (ext:quit))'" ; done 2>/dev/null
Darwin galatea.lan.informatimago.com 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
/Users/pjb/
Linux hubble 2.6.31-gentoo-r6-c8-bt-wc-sa #5 SMP PREEMPT Fri Jan 29 15:24:25 CET 2010 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ AuthenticAMD GNU/Linux
/home/pjb/
CYGWIN_NT-5.1 galle 1.7.1(0.218/5/3) 2009-12-07 11:48 i686 Cygwin
/home/pjb/


For maximum portability, I would use merge-pathnames and make-pathname
as:

(merge-pathnames
(make-pathname :host (pathname-host home-dir)
:device (pathname-device home-dir)
:directory '(:relative "LISP" "LISPY-ALL")
:case :common)
home-dir
nil)

but notice that not all implementations map case the same way.
The only way to access the same physical pathname with different
implementations is to use logical pathname translations.

Have a look at LOAD-LOGICAL-PATHNAME-TRANSLATIONS.


Notably, it is much easier to use logical pathnames than to merging
(physical) pathnames.

Basically, you would just do:

(dolist (host '("LISPY" "SLIME" "CUSTOM-ASDF" "DEV"))
(load-logical-pathname-translations host))

(dolist (file '(#P"LISPY:ASDF.LISP"
#P"LISPY:ASDF-CONFIG.LISP"
#P"SLIME:SWANK-LOADER.LISP"))
(load (compile-file file)))

(define-modify-macro appendf (&rest args) append "Append onto list")
(appendf asdf:*central-registry* (directory #P"CUSTOM-ASDF:*.ASD"))
(appendf asdf:*central-registry* (directory #P"DEV:*.ASD"))

(asdf:oos 'asdf:load-op 'some-lib)
(some-lib:do-something)


For each implementation and on each system, you would edit a logical
pathname translation file (the format may change from implementation to
another, and of course the paths may change too).

--
__Pascal Bourguignon__
From: Pascal J. Bourguignon on
"Futu Ranon" <futuranon(a)gmail.com> writes:

> I am running CL on Windows and Mac and have a configuration file that
> I'd like to share between them. I want to do something like the
> following:
> http://paste.lisp.org/display/96300
>
> I am using cygwin on Windows so I want to use that as the user's home-dir.
>
> 1. Is this the correct way to make use of CL pathnames? I switched
> from the use of strings so this still feels foreign.
> 2. Is there a way to go about the two asdf:*central-registry* updates
> I do at the end of the let*? As far as I understand it, the asdf
> package is not yet loaded so I cannot push on to *central-registry*
> inside that let* binding. Is that correct? Do I have recourse other
> than to roughly duplicate the let* in order to do the asd file search
> and pushnew?


What about (user-homedir-pathname)?

$ for h in galatea hubble galle ; do ssh -n $h clisp -ansi -norc -q -E iso-8859-1 -x "'(progn (ext:run-program \"uname\" :arguments (quote (\"-a\"))) (princ (user-homedir-pathname)) (terpri) (finish-output) (ext:quit))'" ; done 2>/dev/null
Darwin galatea.lan.informatimago.com 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
/Users/pjb/
Linux hubble 2.6.31-gentoo-r6-c8-bt-wc-sa #5 SMP PREEMPT Fri Jan 29 15:24:25 CET 2010 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ AuthenticAMD GNU/Linux
/home/pjb/
CYGWIN_NT-5.1 galle 1.7.1(0.218/5/3) 2009-12-07 11:48 i686 Cygwin
/home/pjb/


For maximum portability, I would use merge-pathnames and make-pathname
as:

(merge-pathnames
(make-pathname :host (pathname-host home-dir)
:device (pathname-device home-dir)
:directory '(:relative "LISP" "LISPY-ALL")
:case :common)
home-dir
nil)

but notice that not all implementations map case the same way.
The only way to access the same physical pathname with different
implementations is to use logical pathname translations.

Have a look at LOAD-LOGICAL-PATHNAME-TRANSLATIONS.


Notably, it is much easier to use logical pathnames than to merging
(physical) pathnames.

Basically, you would just do:

(dolist (host '("LISPY" "SLIME" "CUSTOM-ASDF" "DEV"))
(load-logical-pathname-translations host))

(dolist (file '(#P"LISPY:ASDF.LISP"
#P"LISPY:ASDF-CONFIG.LISP"
#P"SLIME:SWANK-LOADER.LISP"))
(load (compile-file file)))

(define-modify-macro appendf (&rest args) append "Append onto list")
(appendf asdf:*central-registry* (directory #P"CUSTOM-ASDF:*.ASD"))
(appendf asdf:*central-registry* (directory #P"DEV:*.ASD"))

(asdf:oos 'asdf:load-op 'some-lib)
(some-lib:do-something)


For each implementation and on each system, you would edit a logical
pathname translation file (the format may change from implementation to
another, and of course the paths may change too).

--
__Pascal Bourguignon__
From: Futu Ranon on
On Fri, 12 Mar 2010 17:49:49 -0500, Pascal J. Bourguignon
<pjb(a)informatimago.com> wrote:

> What about (user-homedir-pathname)?

On LispWorks Pro (my primary development environment for Windows right
now), this yields
#P"C:/Documents and Settings/USERNAME/"

On cygwin-installed CLISP, I get the same result as you. I suppose the
branch is still required, but for #+(and WIN32 LISPWORKS) instead.

I will take another swing at configuring this using the rest of your
recommendations.

Thank you very much.
From: Pascal J. Bourguignon on
"Futu Ranon" <futuranon(a)gmail.com> writes:

> On Fri, 12 Mar 2010 17:49:49 -0500, Pascal J. Bourguignon
> <pjb(a)informatimago.com> wrote:
>
>> What about (user-homedir-pathname)?
>
> On LispWorks Pro (my primary development environment for Windows right
> now), this yields
> #P"C:/Documents and Settings/USERNAME/"

This means that LispWorks doesn't work in cygwin, but in MS-Windows. ;-)

In that case, indeed, you don't want user-homedir-pathname, but a
specific directory that happens to be your cygwin home dir.

A loaded logical pathname translation may be the simpliest way to deal
with it portably.


> On cygwin-installed CLISP, I get the same result as you. I suppose the
> branch is still required, but for #+(and WIN32 LISPWORKS) instead.
>
> I will take another swing at configuring this using the rest of your
> recommendations.
>
> Thank you very much.

--
__Pascal Bourguignon__