DrScheme in Emacs


Overview

Running Scheme inside of emacs is a conventient and efficient way to use the language. You get all the goodies that come with emacs as well as a nice interface to the Scheme interpreter.

Starting Emacs

The first thing you want to do is start emacs. See this page for more info on using emacs.

Editing your .emacs file

If you don't already have a .emacs file, create one. It should live in your home directory. You home directory is probably mapped to the Z: drives on the Windows machines in the lab. If you don't have one, create a file called ~/.emacs (yes, it starts with a ".", the ~ tells emacs to place it in your home directory) and put the following two lines in there (if you're using emacs on Windows in the lab):

(global-font-lock-mode)                                 ; syntax coloring
(setq scheme-program-name "d:/app/PLT/MzScheme.exe")    ; which scheme

Or if you're using emacs on one of the departmental unix boxes, the file should contain these lines (might be slightly different for different offerings of CSE341..):

(global-font-lock-mode)   
(setq scheme-program-name "/cse/courses/cse341/02wi/plt/bin/mzscheme")

(If you think the above stuff looks like Scheme, you're almost right. Emacs can be customized and extended via a language known as Emacs-Lisp, which is part of the Lisp family of languages.)

When you've done the above, quit and restart emacs. (Or just hit "eval-buffer" from the Emacs-Lisp menu.)

Opening, Editing Scheme Files

Now open a scheme file. If the file is named with the .scm extension, emacs should immediately enter scheme mode for that buffer. If it doesn't do this automatically, try M-x scheme-mode.

Now you can start the scheme interpreter by typing M-x run-scheme. This should start the scheme interpreter in a separate window. Use C-x 2 to split the window, and switch one of the buffers to your scheme file. You now have an edit pane and an interpreter pane.

There are really only two commands you need to learn to send information from the edit buffer to the interpreter:

  1. C-x C-e evaluates the last s-expression. This means that if the cursor is at the last paren of an definition in your file, it will evaluate that expression in the interpreter.
  2. C-c C-l loads a file. Once you tell it the file to load, it will remember this for future loads and you only need to hit return. This command is analagous to the "execute" command in DrScheme, with the exception that it does not restart the interpreter.


Comments to
cse341-webmaster@cs.washington.edu
Last modified: Mon Apr 30 18:20:43 PDT 2001