LISP Program Development at UNCG

CSC 339 - Spring 2001


How to run LISP from Unix shell
(Unix dialogue shown in green, what I typed into Lisp shown in red, what Lisp printed shown in black)

To start LISP from shell:

> gcl
GCL (GNU Common Lisp) Version(2.2.2) Wed Jul 15 10:02:58 EDT 1998
Licensed under GNU Public Library License
Contains Enhancements by W. Schelter

>(+ 1 2) ;; I typed this - lisp printed the next line
3

To exit lisp: type control-d

To load a file in the working directory named ex1.lisp into lisp:
>(load "ex1.lisp")
Loading ex1.lisp
Finished loading ex1.lisp
T
;; Now you can use the code that was in ex1.lisp

To create a log file of the session:
>(dribble "mylog")

Starts dribbling to mylog (2000/3/28, 17:32:17).
NIL
>(+ 1 1) ;; try something - it will be recorded in the log
2

To see what is in the log,
   exit LISP and look at mylog; it would look like this:

   Starts dribbling to mylog (2000/3/28, 17:32:17).
    NIL>
    (+ 1 1)
    2

To turn off the log while still running LISP:
>(dribble)


How to run LISP from emacs editor

a. Start emacs from Unix shell:

>emacs mylisp

b. Once in emacs, enter lisp code:

(+ (+ 2 2)
    (+ 3 2))

To run the lisp code, put the cursor at the ending right parenthesis and
type control-x control-e. Note that emacs will help you balance your parentheses!
The result of running the code will appear at the bottom of the emacs
window (in the command area).

To define and run functions, enter the function definition:

(defun multiply-by-seven (number)
"Multiply NUMBER by seven."
(* 7 number))

Then, put the cursor at the ending right parenthesis and type control-x control-e.

Then, enter the function call:

(multiply-by-seven 3)

Then put the cursor at the ending right parenthesis and type control-x control-e.

c. To save the contents of the file, type control-x control-s.
d. To exit emacs, type control-x control-c.
e. To edit the file in emacs (a few of the things you can do):
- To add text, type it where you want it to go
- To delete text, you can use the backspace
- To move around the page, use the arrow keys
- To search for a string, type control-S, then enter the
string to search for in the command area at the bottom
- To cancel a command, type control-g

f.  For more information on emacs see the following documentation:

Run a Program
http://www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_12.html

Install a Function Definition
http://www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_43.html

Programming in Emacs Lisp
http://www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_toc.html

GNU Emacs
http://hoth.stsci.edu/man/man1/emacs.html

GNU Emacs Manual
http://www.cs.utah.edu/dept/old/texinfo/emacs18/emacs_toc.html


Miscellaneous

1.  vi editor:  This editor has a lisp mode with automatic parenthesis matching.  To start it, get into command
     mode and type :set lisp, or use the -l switch on the command line when you start vi (vi -l).