From: Jeffery Zhang
Subject: How do I automatically load files at Lisp startup
Date: 
Message-ID: <e2nd9h$gsu$1@ruby.cit.cornell.edu>
Suppose I wrote a macro and saved it in ~/macro.lisp and I would like 
to load this file (macro) into the lisp environment everytime I start 
lisp. How would I do this?

-Jeffery

From: Rob Warnock
Subject: Re: How do I automatically load files at Lisp startup
Date: 
Message-ID: <EqudnZgE7ZO519LZnZ2dnUVZ_s6dnZ2d@speakeasy.net>
Jeffery Zhang  <····@cornell.edu> wrote:
+---------------
| Suppose I wrote a macro and saved it in ~/macro.lisp and I would like 
| to load this file (macro) into the lisp environment everytime I start 
| lisp. How would I do this?
+---------------

It depends on the implementation [and what follows is oversimplified],
but almost all of them provide some sort of "rc" initialization file
you can put in your home directory that will be automatically loaded
on startup, e.g.:

    CMUCL:	~/.cmucl-init
    SBCL:	~/.sbclrc
    CLISP:	~/.clisprc

Then in that file you can put a (LOAD "home:macro.lisp")
[or however your implementation represents a path to $HOME/].


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Tayssir John Gabbour
Subject: Re: How do I automatically load files at Lisp startup
Date: 
Message-ID: <1146047970.142041.40280@g10g2000cwb.googlegroups.com>
Rob Warnock wrote:
> Jeffery Zhang  <····@cornell.edu> wrote:
> +---------------
> | Suppose I wrote a macro and saved it in ~/macro.lisp and I would like
> | to load this file (macro) into the lisp environment everytime I start
> | lisp. How would I do this?
> +---------------
>
> It depends on the implementation [and what follows is oversimplified],
> but almost all of them provide some sort of "rc" initialization file
> you can put in your home directory that will be automatically loaded
> on startup, e.g.:
>
>     CMUCL:	~/.cmucl-init
>     SBCL:	~/.sbclrc
>     CLISP:	~/.clisprc
>
> Then in that file you can put a (LOAD "home:macro.lisp")
> [or however your implementation represents a path to $HOME/].

Slime users might use ~/.swank.lisp

LispBox users might wish to read the section on enabling their
.swank.lisp files:
http://www.cliki.net/LispBox
From: Pascal Bourguignon
Subject: Re: How do I automatically load files at Lisp startup
Date: 
Message-ID: <87r73kpqqt.fsf@thalassa.informatimago.com>
····@rpw3.org (Rob Warnock) writes:

> Jeffery Zhang  <····@cornell.edu> wrote:
> +---------------
> | Suppose I wrote a macro and saved it in ~/macro.lisp and I would like 
> | to load this file (macro) into the lisp environment everytime I start 
> | lisp. How would I do this?
> +---------------
>
> It depends on the implementation [and what follows is oversimplified],
> but almost all of them provide some sort of "rc" initialization file
> you can put in your home directory that will be automatically loaded
> on startup, e.g.:
>
>     CMUCL:	~/.cmucl-init
>     SBCL:	~/.sbclrc
>     CLISP:	~/.clisprc
>
> Then in that file you can put a (LOAD "home:macro.lisp")
> [or however your implementation represents a path to $HOME/].

There is a standard way to get at the HOME:

      (COMMON-LISP:USER-HOMEDIR-PATHNAME)



This should work in all Common Lisp implementations:

(LOAD (MERGE-PATHNAMES (MAKE-PATHNAME :NAME "MACRO" :TYPE "LISP" :CASE :COMMON)
                       (USER-HOMEDIR-PATHNAME)))

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

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: Rob Warnock
Subject: Re: How do I automatically load files at Lisp startup
Date: 
Message-ID: <PfqdnZKMTrsZuc3ZRVn-pA@speakeasy.net>
Pascal Bourguignon  <···@informatimago.com> wrote:
+---------------
| ····@rpw3.org (Rob Warnock) writes:
| > Then in that file you can put a (LOAD "home:macro.lisp")
| > [or however your implementation represents a path to $HOME/].
| 
| There is a standard way to get at the HOME:
|   (COMMON-LISP:USER-HOMEDIR-PATHNAME)
+---------------

Ah, yezzz... Thanks! I'd forgotten about that.

+---------------
| This should work in all Common Lisp implementations:
|   (LOAD (MERGE-PATHNAMES
|          (MAKE-PATHNAME :NAME "MACRO" :TYPE "LISP" :CASE :COMMON)
|          (USER-HOMEDIR-PATHNAME)))
+---------------

Indeed.


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Pascal Costanza
Subject: Re: How do I automatically load files at Lisp startup
Date: 
Message-ID: <4b8ua4F107o87U1@individual.net>
Jeffery Zhang wrote:
> Suppose I wrote a macro and saved it in ~/macro.lisp and I would like to 
> load this file (macro) into the lisp environment everytime I start lisp. 
> How would I do this?

You basically have two options:

- Most Common Lisp implementations provide a way to define a startup 
script that is executed whenever Lisp is started. You can simply add 
(load ...) forms in that startup script. I am only aware of one that 
doesn't do this, it's ECL. However, a variation of this approach is to 
start it with a command to load a give lisp file, for example ecl -load 
init.lisp. This is also supported by several CL implementations.

- The other variation is to start Lisp, load the libraries you want, and 
then save an image that you can use in subsequent Lisp sessions. An 
image is a representation of all the code that is loaded and all the 
memory that is occupied. So by reloading an image you basically get the 
same state of the system you had when you saved the image, including 
live objects (to a certain degree, at least).

These two approaches are implementation-dependent, so you have to check 
the documentation of your respective Common Lisp implementation to see 
how this works in detail. The free trial editions of commercial 
implementation typically come with restrictions in this area. A simple 
workaround is to load an init.lisp manually, or use the scripting 
capabilities of the hosting operating system to cheat.


Pascal

-- 
3rd European Lisp Workshop
July 3-4 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/
From: Juanjo
Subject: Re: How do I automatically load files at Lisp startup
Date: 
Message-ID: <1146058783.953032.252960@i39g2000cwa.googlegroups.com>
Pascal Costanza schrieb:

> Jeffery Zhang wrote:
> > Suppose I wrote a macro and saved it in ~/macro.lisp and I would like to
> > load this file (macro) into the lisp environment everytime I start lisp.
> > How would I do this?
>
> - Most Common Lisp implementations provide a way to define a startup
> script that is executed whenever Lisp is started. You can simply add
> (load ...) forms in that startup script. I am only aware of one that
> doesn't do this, it's ECL. However, a variation of this approach is to
> start it with a command to load a give lisp file, for example ecl -load
> init.lisp. This is also supported by several CL implementations.

In any recent version of ECL you can use ~/.eclrc

···@mpq3p59:~$ cat ~/.eclrc
(print "HELLO")
···@mpq3p59:~$ ecl

"HELLO" ECL (Embeddable Common-Lisp) 0.9h
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  Broken at EVAL.