Emacs and Lisp

Unless you like pain or are very attached to your current editor, Emacs should be your choice for developing in Lisp. While you do not strictly need a .emacs file, it is where you perform all your user-specific custimizations.

Feel free to take a look at ~vandurme/.emacs*, it is a jumble of files that overlap and may very well confuse. ~vandurme/.emacs is of course the file that I actually use, which itself loads some files in: ~vandurme/.emacs.d/ .

SLIME is the super duper Lisp editing mode that makes a lot of things much easier and more pleasant. If you are an emacs novice that just wants slime to work then add the following line to the top of your ~/.emacs file:

(load "/usr/grads/share/emacs/site-lisp/slime/dot-emacs")

Alternatively, I have been lately poking at a "starter"/example file for use within the department. It has the same few lines as the slime dot-emacs file, as well as other tidbits. Note that as it says in the file, this is not strictly intended to be loaded as-is; I expect most people will want to cut and paste select portions. Lots of comments included:

(load "/usr/grads/share/emacs/site-lisp/dot-emacs")

The first lisp file you load you may need to perform M-x slime, which means holding down either Alt or Escape, then hitting the letter 'x'. A prompt will appear at the bottom of the editor (in the minibuffer) where you type "slime" and hit enter.

Once slime is running, I suggest hitting C-x 3, which will split the current frame in half horizontally (C-x 2 does so vertically). Most people like making emacs somewhat fullscreen, editing on one side and iteratively testing/debugging on the other.

Perhaps one of the most useful SLIME commands is slime-eval-defun, which is bound to C-M-x. Rather than reloading your lisp file everytime you make a single change, far more efficient is to get in the habit of using this handy command.

Practice Session

We use % to represent a shell prompt.

Load emacs. The -q tells emacs to not load any custimization files, such as ~/.emacs. We do this here just to make sure nothing gets in your way of loading slime for this practice session. I would not expect you to ever use -q as part of normal emacs use. The flag -l tells emacs to load the following file.
% emacs -q -l /usr/grads/share/emacs/site-lisp/dot-emacs

Load slime in emacs, split frame.
M-x slime
C-x 3

Load an example lisp file in emacs. Look through the contents and see if you can figure out what is going on.
C-x C-f /u/vandurme/every-other-line.lisp

Making sure your cursor is within the function block, run slime-eval-defun.

From the lisp prompt and without finishing with hitting enter, type:
(every-other-line

If you hit the space key after the function name, you should see in the mini-buffer an argument signature, this is a nice benefit of using slime. If you were to just type (every-ot and then tab, it should auto-complete.

Now try running the function:
(every-other-line "/u/vandurme/every-other-line.lisp")

Now try looking up documentation on the function:
(documentation 'function 'every-other-line)

Examples of useful SLIME commands

slime-hyperspec-lookup loads documentation for symbols defined in the Common Lisp Hyperspec (which should include just about all functions and variables you should ever be using for homework assignments). I use this command a lot.

slime-inspect : from a lisp prompt, enter (setf foo (make-hash-table)), then try inspecting foo.

slime-interrupt C-c C-c, this stops whatever is currently running and should place you in the debugging view.

Various shortcuts exist.