%% -*- LaTeX -*-

\chapter{Edwin, the Editor}
\label{edwin}

\vfill

Edwin is the computer program used for typing, editing, and testing Scheme
programs on the Chipmunks.  It is based on Emacs, another text editor,
originally designed and implemented in the 1970s by Richard M. Stallman at
MIT.  Edwin works almost exactly like GNU Emacs, the version of Emacs used on
Project Athena computers.  Unlike Emacs, however, Edwin is written in Scheme.

Edwin is a sophisticated text editing program.  This manual gives only a basic
introduction, but it explains everything you need to know about Edwin to do
6.001 problem sets.  Read through it once carefully before you try to use the
Chipmunks; use it as a reference manual thereafter.

\vfill

\newpage

\section{Buffers and Windows}

Use Edwin to work with as many separate chunks of text as you wish; each chunk
is kept in a {\it buffer}.  The text in a buffer may be a Scheme program,
English prose, a list of files, or anything else that you can type on the
keyboard.

Most buffers hold text you have loaded in from a file on disk, or text you
have typed but not yet saved as a file.  All buffers are erased as soon as you
log out, so you should make sure to save all buffers containing your work to
files on your floppy disk first.  The next time you use the Chipmunks, just
load your files from disk and you will be ready to continue working on them.

Some buffers are not used to edit files.  The {\tt *scheme*} buffer, for
example, is where you carry out all ``conversations'' with Scheme; in other
words, this is where you test Scheme programs you have written or changed.

Each buffer has one major mode, and maybe some minor modes.  {\it Major} modes
determine special Edwin behavior particular to the language you are using in
the buffer (e.g., Scheme or English).  {\it Minor} modes add special features
regardless of the language you are using in the buffer.

Edwin can display several buffers on the screen at once, each in a separate
{\it window}.  A window is a rectangular area of the screen set aside to
display all or part of a particular buffer.  Not every buffer will always be
visible at the same time; usually, there are one or two windows, but three or
more buffers.

\newpage
\section{The Edwin Screen}

The Edwin screen is divided into three types of rectangular areas.  They are:

\begin{description}

\item[Typein Window] The last line on the screen is the {\it typein window}.
Whenever Edwin needs to ask you a question, it shows the question in the
typein window.

\item[Edit Windows] Each area of white-on-black text above the typein window
is an {\it edit window}.  Each Edit Window displays all or part of a buffer,
for you to read or edit.

\item[Mode Lines] The black-on-white line of text at the bottom of each edit
window is a {\it mode line}.  Each mode line shows its buffer's name (usually
the same as the file name), major and minor modes, and other information.

\end{description}

Whenever Edwin is ready for you to type something, it displays the {\it
cursor}, a blinking underline, to show you where your typing will appear on
the screen.  If you type an ordinary character (letter, number, or
punctuation), it is inserted at the current cursor position and the cursor
moves past it.  If you type when the cursor appears in an Edit Window, your
typing is inserted into the corresponding buffer.

The {\it point} is an invisible marker between two adjacent characters in each
buffer.  The cursor always reflects the position of the point in the current
buffer; the point is between the character just left of the cursor and the
character above the cursor.  For example, if the screen shows:

{\tt The point is in this wo{\underline r}d.} \ ,

\noindent then the point is between the `o' and the `r' in ``word.''

Each mode line looks something like this:

\modeline{-----Edwin:\ STUDENT.SCM \hfill (Scheme)--57\%--------------}

\noindent
This mode line, for example, gives the name of the buffer, {\tt STUDENT.SCM};
that the buffer is configured in Scheme mode; and that the part of the buffer
visible on the screen is fifty-seven percent of the way through the whole
buffer.  Saying that the buffer is in Scheme mode means that, in addition to
ordinary Edwin features, there are special features to aid you in using
Scheme.

A mode line that contains two asterisks {\tt **} at the left, such as

\modeline{--**-Edwin:\ STUDENT.SCM \hfill (Scheme)--57\%--------------}	

\noindent
indicates that the buffer has been changed since the last time it was saved on
disk.

Certain buffers used by the system, such as buffers used for displaying
messages and lists of files, are {\it read-only}.  Edwin indicates this by two
percent signs {\tt \%\%}.  For example, the mode line

\modeline{--\%\%-Edwin:\ BEN: \hfill (Dired)--Top--------------}

\noindent
indicates that the {\tt BEN:} buffer is read-only---Edwin will not let you
change the contents of that buffer.  In addition, the word {\tt Top} indicates
that the top (beginning) of the buffer is visible in the window, and {\tt
Dired} indicates that the buffer is in ``directory edit'' mode (see
section~\ref{Dired}).

For a window in which you can type directly to Scheme (e.g., the {\tt
*scheme*} buffer), the mode line looks like this:

\modeline{--**-Edwin:\ *scheme* \hfill (Interaction)--All--------------}

\noindent
The word {\tt Interaction} means that the buffer is connected directly
with Scheme.  When you press \key{execute} in this buffer, Edwin will
send Scheme the expression before the cursor, and Scheme's result will
be printed in the buffer.

\newpage
\section{Commands}
\label{Commands}

Edwin acts very much like a typewriter when you type normal keys, like
letters, numbers, and punctuation.  However, to get Edwin to do anything
special, such as loading files, running a Scheme program, or switching to
another buffer, you must use special keys, like \key{ctrl} and the grey keys
across the top of the keyboard.  These keys issue {\it commands} to Edwin,
telling it what you want it to do.

There are two types of Edwin commands: commands available directly on the
special keys, and {\it extended commands}.  Extended commands are used by
pressing \key{extend} (\kkey{2}), followed by the name of the command.  All
commands are available this way, but the special keys are more convenient.
In fact, you will probably need to use only two extended comands: {\tt load
problem set} and {\tt logout}.

There are key diagrams mounted on the Chipmunk around the grey keys and the
floppy disk drives.  To use a command on one of these special keys, hold down
some combination of \key{shift} and \key{ctrl} (as indicated on the diagrams),
while pressing the special key.

When reading tables like the one below, remember that a hyphen ``-'' between
keys means that you should hold them down simultaneously.  For example, \ctrl
\key{$\leftarrow$} means ``hold \key{ctrl} down while pressing
\key{$\leftarrow$}.''  On the other hand, \extend {\tt load problem set} means
``press and release \key{extend}, then type `{\tt load problem set}' and press
\key{enter}.''

If you are familiar with Emacs, you will find that almost all of the
Edwin commands can be typed in the way they normally would be in
Emacs, as well as with the special keys at the top of the Chipmunk
keyboard.  For example, the {\tt abort} command can be typed either by
pressing the \key{abort} key (which is key \kkey{2}), or by typing
\ctrl{G}, as in ordinary Emacs.  The tables below list both versions
of the command.  Use whichever one you find most comfortable.  Emacs
``escape'' commands are typed with the aid of the \key{run} key at the
right of the keyboard.  For instance, to type what in Emacs would be
``escape-W'', you type \key{run} followed by \key{w}.  (Do not press
both keys simultaneously, as you would with \key{ctrl}.)\index{escape
commands}


Here are the special keys necessary for using Edwin commands:

\startkeytable

\describekey
  {Extended Command}
  {\extend (\kkey{2})}
  {\runkey{x} (Note: \key{run} is labeled \key{esc} on most computer
   keyboards.)}
  {Begin an extended command.  To use an extended command, press this key,
   then type the name of the command.  Finish by pressing \key{enter}.}

\describekey
 {ABORT}
 {\key{abort} (\kkey{1})}
 {\ctrl \key{g}}
 {Stop whatever operation Edwin is performing, or cancel a command you've
  already started typing.}

\describekey
 {Universal Argument}
 {\key{argument} (\kkey{8})}
 {\ctrl \key{u}}
 {Preceding any command (regular or extended), this key tells Edwin that you
  wish to give the command an {\it argument}.}
\finishkeytable

\subsection{Arguments Optional}

An argument to an Edwin command is analogous to a parameter in a Scheme
procedure.  However, arguments to Edwin commands are always optional; if no
argument is given, a default argument is automatically supplied to the
command.

Many Edwin commands accept optional numeric arguments, assuming an argument of
one if none is given.  Pressing \key{argument} first gives these commands an
argument of four.  For example, pressing \key{$\downarrow$} once moves the
cursor down one line; typing \key{argument} \key{$\downarrow$} moves the
cursor down four lines.  If you type \key{argument} several times
successively, Edwin will multiply the argument by four each time, so typing
\key{argument} \key{argument} \key{argument} \key{$\downarrow$} will move the
cursor down sixty-four ($4 \times 4 \times 4$) lines.  Typing a number after
\key{argument} makes that number the argument; typing \key{argument} {\tt 123}
\key{$\downarrow$} will move the cursor down 123 lines.

Some Edwin commands take optional character string arguments, so prefixing
them with \key{argument} will cause them to ask for a string argument.

If you are unsure about whether a command takes an argument, or what it means
for that command to take an argument, use the Edwin help function ``Describe
Function'' by pressing \key{help} (\shift \kkey{2}).  (See
section~\ref{Help}.)

\newpage
\subsection{Extended Commands}

To use an extended command, press the \extend key (\kkey{2}) followed by the
name of the command.  Your typing will appear at the bottom of the screen, in
the typein window.

You can abbreviate the command name as you type.  If you press the \key{space}
key while you're typing the command name, Edwin will look for all commands
whose names begin with what you've typed.  If there is a matching command,
Edwin will complete the word you are typing.  If there is more than one
matching command, Edwin will beep; press \key{?}, and Edwin will list all the
matching commands, then wait for you to finish typing the name of the command
you want.  If there is no matching command, Edwin will beep, then wait for you
to correct your mistake with the \key{back space} key.

When you've typed the full command name, press \key{enter}; Edwin will run
your command.

\section{Trouble}
\label{Trouble}

Because there are so many things you can do with Edwin, it is likely that you
will make a mistake using it once in a while --- yes, even you!

To stop whatever Edwin is doing, or to cancel a command before you've
completely typed it, press the grey \key{abort} key.  Pressing \key{abort} is
like screaming, ``Stop!'' at Edwin.

In fact, \key{abort} is also useful for stopping Scheme programs other than
Edwin.  For example, if you start {\tt (factorial 10000)}, but decide that it
will take too long to compute, typing \key{abort} will stop {\tt factorial}
and prepare Edwin to accept another command.

\newpage
\section{Getting Help}
\label{Help}

If you're ever confused about how to get Edwin to do something, or just want
to find out more about what it can do, press \key{help} (\shift \kkey{2})
followed by one of these letters:

{\smalltype
\begin{description}

\item[A] Apropos.\\  Type a word or words that describe what you want to
do, and Edwin will list all commands whose descriptions mention the words you
give.

\item[C] Describe Key Briefly.\\  Type a key (or sequence of keys), and Edwin
will give a brief description of what the key does.

\item[D] Describe Command.\\  Type the name of a command (usually an
extended command), and Edwin will tell you what the command does and how to
use it.

\item[I] Info, the documentation reader.\\  Info gives information on a
variety of topics, among them Edwin.  For help on using Info, press `h' once
you've started Info.

\item[K] Describe Key.\\  Type a key (or sequence of keys), and Edwin
will give a complete description of what the key does.

\item[L] Show Lossage.\\  Shows the last one hundred characters you
typed.

\item[M] Describe Mode.\\  Shows documentation for the current major
mode, including commands peculiar to it.

\item[T] Help with Tutorial.\\  Starts the Emacs learn-by-doing tutorial.
Edwin is sufficiently similar to Emacs that this tutorial may be useful to
you.

\item[V] Describe Variable.\\  Type an Edwin variable name\footnote{This
is good only for Edwin variables.  It is not useful for finding information on
Scheme variables.}, and Edwin will describe the purpose and use of the
variable.

\item[W] Where Is.\\  Type a command name (usually an extended command),
and Edwin will tell you what key (or key sequence) you can use to run the
command.  All Edwin commands have names, but not all are attached to keys, so
Edwin may tell you that the command ``... is not on any keys.''  In that case,
the only way to use the command is by invoking it as an extended command
(using the \extend key).
\end{description}
}

\newpage
\section{Typing}

Before you start typing, make sure you're ``in'' the buffer you want to
change.  If the buffer you want to change is in one of the windows on the
screen, and the cursor is in that buffer, then go ahead and type.  Otherwise,
press the grey \key{select buffer} key (\kkey{4}).  Edwin will ask you which
buffer to use; type its name (press \key{?} for a list of buffers) followed by
\key{enter}.  Edwin will display the buffer you've requested in a window,
placing the cursor in that window; you are now ``in'' the right buffer.  Now,
you are ready to type.

To insert text into the buffer, just type.  Edwin will insert characters
wherever the cursor appears.  Whatever you type is inserted {\it just before}
the cursor.  When you get to the end of a line, press the \key{enter} key,
just as you would on a normal typewriter, to get to the beginning of the next
line.

When you get to the bottom of the screen, Edwin automatically gives you more
space to work with.

Correct typing mistakes by pressing the \key{back space} key, just like on a
correcting typewriter.

\startkeytable

\describekey
 {Indent for Tab}
 {\key{tab}}
 {\key{tab}}
 {Indent the line.}

\describekey
 {Newline}
 {\key{enter}}
 {\ctrl \key{j}}
 {Insert a blank line before the point.}

\describekey
 {Open Line}
 {\key{ins ln}}
 {\ctrl \key{o}}
 {Insert a blank line after the point.}

\describekey
 {What Cursor Position}
 {\shift \kkey{9}}
 {\ctrl \key{x} \key{=}}
 {Display the current cursor position in the typein window.}

\describekey
 {Quoted Insert}
 {\shift \key{ins chr}}
 {\ctrl \key{q}}
 {Insert a special character at the current point, then move the point forward.}
\finishkeytable

\newpage
\section{Moving through a Buffer}

Use the arrow keys to move the cursor around in a buffer.  For the most part,
the arrow keys do exactly what you would expect:

\startkeytable

\describekey
 {Up Real Line}
 {\key{$\uparrow$}}
 {\ctrl \key{p}}
 {Move the cursor up one line.  Stay at the same horizontal position, if
 possible.}

\describekey
 {Down Real Line}
 {\key{$\downarrow$}}
 {\ctrl \key{n}}
 {Move the cursor down one line.  Stay at the same horizontal position, if
 possible.}

\describekey
 {Backward Character}
 {\key{$\leftarrow$}}
 {\ctrl \key{b}}
 {Move the cursor left one character.  If at the start of a line, move to the
 end of previous line.}

\describekey
 {Forward Character}
 {\key{$\rightarrow$}}
 {\ctrl \key{f}}
 {Move the cursor right one character.  If at the end of a line, move to the
  start of the next line.}

\describekey
 {Backward Word}
 {\shift \key{$\leftarrow$}}
 {\runkey{b}}
 {Move backward to the beginning of the previous word.}

\describekey
 {Forward Word}
 {\shift \key{$\rightarrow$}}
 {\runkey{f}}
 {Move forward to the end of the next word.}

\describekey
 {Beginning of Line}
 {\ctrl \key{$\leftarrow$}}
 {\ctrl \key{a}}
 {Move the cursor to the beginning of the line.}

\describekey
 {End of Line}
 {\ctrl \key{$\rightarrow$}}
 {\ctrl \key{e}}
 {Move the cursor to the end of the line.}

\describekey
 {Previous Screen}
 {\ctrl \key{$\uparrow$}}
 {\runkey{v}}
 {Scroll the text in the buffer downward to reveal the previous window-full of
  text.}

\describekey
 {Next Screen}
 {\ctrl \key{$\downarrow$}}
 {\ctrl \key{v}}
 {Scroll the text in the buffer upward to reveal the next window-full of text.}

\describekey
 {Goto Beginning}
 {\ctrl \shift \key{$\uparrow$}}
 {\runkey{<}}
 {Move to beginning of buffer.}

\describekey
 {Goto End}
 {\ctrl \shift \key{$\downarrow$}}
 {\runkey{>}}
 {Move to end of buffer.}
\finishkeytable

\newpage
\section{Correcting Simple Mistakes}

Use the following keys to correct simple mistakes:

\startkeytable

\describekey
 {Backward Delete Hacking Tabs}
 {\key{back space}}
 {\key{back space}}
 {Delete the character before the point, treating TAB characters as several
  SPACE characters.  If the point is at the beginning of a line, join the line
  to the end of the previous line.}

\describekey
 {Delete Character}
 {\key{del chr}}
 {\ctrl \key{d}}
 {Delete the character after the point.  If the point is at the end of a line,
 join the next line to the end of the current line.}

\describekey
 {Backward Delete Character}
 {\ctrl \key{del chr}}
 {}
 {Delete the character before the point, treating TAB characters as single
  units.  If the point is at the beginning of a line, join the line to the end
  of the previous line.}

\describekey
 {Kill Word}
 {\shift \key{clr$\rightarrow$end}}
 {\runkey{d}}
 {Kill characters forward from the point to the end of the nearest word.}

\describekey
 {Backward Kill Word}
 {\ctrl \shift \key{del chr}}
 {\runkey{back space}}
 {Kill characters backward from the point to the beginning of the nearest word.}

\describekey
 {Kill Line}
 {\key{clr$\rightarrow$end}}
 {\ctrl \key{k}}
 {Kill the characters following the point on the current line.}

\describekey
 {Transpose Characters}
 {\kkey{3}}
 {\ctrl \key{t}}
 {Interchange the two characters around the point.  If the point is at the end of
  the line, interchange the two characters preceding the point.}

\describekey
 {Transpose Words}
 {\shift \kkey{3}}
 {\runkey{t}}
 {Interchange the words around the point.}
\finishkeytable

\newpage
\section{Undo}

Edwin's {\it undo} feature is useful for correcting bigger mistakes, like
accidentally erasing an entire Scheme procedure, or inserting one paragraph in
the middle of another.  Edwin records all changes you have made to a buffer
since the last time you saved the buffer, up to a certain limit (several
thousand characters' worth).  Use the \key{undo} key (\ctrl
\key{clr$\rightarrow$end}) to undo the last change you made to the current
buffer.  If you press \key{undo} several times in a row, Edwin will undo
earlier and earlier changes.  Each time you press \key{undo}, Edwin will move
the point to the next-most-recent change, and undo it.

Sometimes, you may accidentally undo more changes then you want to.  When this
happens, issue some command that will not change the buffer (like
\key{$\leftarrow$}), then press \key{undo} to redo what you accidentally
undid.\footnote{How many undos would an undo undo if an undo could undo
undos?}

If you undo all the changes you made to the buffer since you last saved it,
further undoing will have no effect.  When all changes have been undone, the
two asterisks ({\tt **}) on the left side of the buffer's mode line will
disappear.  At this point, the buffer is exactly the same as it was the last
time you saved it.

\newpage
\section{The Region}

Each buffer has a {\it point}, a {\it mark}, and a {\it region}.

The cursor is just a reflection of the {\it point}, an invisible marker
between the character before the cursor and the character above the cursor in
each buffer.  Wherever the point moves, the cursor follows.

The mark is another invisible place marker in the buffer.  Most commands which
move the point any distance set the mark to the point before they move it.  To
set the mark manually, press \kkey{9}; the mark will be at the same position
as the point.

The region is the text between the point and the mark.  Many commands operate
on the region.  The most common use for the region is moving blocks of text
from one place in the buffer to another place, or to another buffer.
Section~\ref{Kills&Yanks} describes the most important commands for dealing
with regions.

To create a region, place the cursor at one end of the text and press
\kkey{9}, then move the cursor to the other end of the text.  The text between
the point and the mark is now considered the region.  Remember that if you
move the point (the cursor in that buffer), you change what is considered to
be the region.

\startkeytable

\describekey
 {Set/Pop Mark}
 {\key{set mark} (\kkey{9})}
 {\ctrl \shift \key{@}}
 {Set the mark at the current point.  When you need to mark off a {\it region}
  of text, use this command to mark the beginning of the region, and move the
  point (cursor) to the other end of the region.}

\describekey
 {Exchange Point and Mark}
 {\ctrl \kkey{9}}
 {\ctrl \key{x} \ctrl \key{x}}
 {Exchange point and mark; switch the positions of the point and the mark.
  This is useful for moving back and forth between two locations in a buffer.
  It is also useful for finding the mark's exact location in the buffer.}

\describekey
 {Mark Whole Buffer}
 {\ctrl \shift \kkey{9}}
 {\ctrl \key{x} \key{h}}
 {Mark the whole buffer as the region.  Put the point at the beginning of the
  buffer, and the mark at the end of the buffer.}
\finishkeytable

\newpage
\section{Kills and Yanks}
\label{Kills&Yanks}

Most commands which erase text from the buffer save it in an invisible place
called the {\it kill ring}, so that you can copy the text, move it, or get it
back if you decide not to erase it.  Edwin holds the last several blocks of
text saved or killed in any buffer in the kill ring.

To get the most recently saved\footnote{Here, ``saved'' does not mean ``saved
to disk;'' it only means ``stored away for future use.''} or killed text back
from the kill ring, place the point where you would like the text to appear,
then do a {\it yank} by pressing \key{recall}; Edwin will insert the text from
the kill ring just before the point.  To get the next-most-recently saved or
killed text, press \ctrl \key{recall}; Edwin will replace the yanked text with
the next-most-recently saved or killed text.  Continue pressing \ctrl
\key{recall} until the text you desire appears.

\startkeytable

\describekey
 {Kill Region}
 {\ctrl \shift \key{del ln}}
 {\ctrl \key{w}}
 {Kill the region and save it in the kill ring.}

\describekey
 {Copy Region}
 {\ctrl \shift \key{recall}}
 {\runkey{w}}
 {Save the region in the kill ring.}

\describekey
 {Un-Kill}
 {\key{recall}}
 {\ctrl \key{y}}
 {Insert the just-killed text at the point (yank the text from the kill ring.)}

\describekey
 {Un-Kill Pop}
 {\ctrl \key{recall}}
 {\runkey{y}}
 {Replace the just-yanked text with the text saved or killed just before it.}
\finishkeytable

\newpage
\section{Editing Scheme Programs}

Edwin has two major modes with special commands for editing Scheme
programs: {\it Scheme} mode and {\it Interaction} mode.  Editing
Scheme programs is done in Scheme-mode buffers, and interacting
directly with Scheme (i.e., running your programs) is done in an
Interaction-mode buffer (usually labeled {\tt *scheme*}).  The
essential difference is that Scheme's output is placed in the
interaction buffer.  Here are the special commands for editing Scheme
available in both Scheme-mode and Interaction-mode buffers:

\startkeytable

\describekey
 {Forward Sexp}
 {\ctrl \shift \key{$\rightarrow$}}
 {}
 {Move point forward across one balanced Scheme expression.}

\describekey
 {Backward Sexp}
 {\ctrl \shift \key{$\leftarrow$}}
 {}
 {Move point backward across one balanced Scheme expression.}

\describekey
 {Beginning of Definition}
 {\shift \key{$\uparrow$}}
 {}
 {Move point backward to previous beginning of a Scheme definition.}

\describekey
 {End of Definition}
 {\shift \key{$\downarrow$}}
 {}
 {Move point forward to next beginning of a Scheme definition.}

\describekey
 {Kill Sexp}
 {\ctrl \shift \key{clr$\rightarrow$end}}
 {}
 {Kill the next Scheme expression after the point.}

\describekey
 {Indent Sexp}
 {\ctrl \kkey{2}}
 {}
 {Indent each line of the Scheme expression starting just after the point.}

\describekey
 {Indent for Comment}
 {\key{ins chr}}
 {\runkey{;}}
 {Indent this line's comment to the comment column, or insert an empty
  comment.}

\describekey
 {Set Comment Column}
 {\ctrl \key{ins chr}}
 {\ctrl \key{x} \key{;}}
 {Set the comment column to be the current horizontal position of the point.
  If preceded by a numeric argument (see section~\ref{Commands}), set comment
  column at the column given by the argument.  Comments inserted using \key{ins
  chr} will appear at this horizontal position.}

\describekey
 {Delete Horizontal Space}
 {\ctrl \shift \kkey{3}}
 {\run \key{$\backslash$}}
 {Delete all spaces and TABs around the point, on the current line.}

\describekey
 {Transpose Sexps}
 {\ctrl \kkey{3}}
 {}
 {Interchange the Scheme expressions around the point.}
\finishkeytable

\newpage
\section{Scheme Interaction}

Before you can run a Scheme program you have typed in a Scheme-mode buffer,
you must send it to Scheme by {\it evaluating} it.  Every time you change your
program, you must be sure to evaluate all the parts which have changed, so
that the Scheme will know about them.

The Interaction-mode buffer is used for working directly with Scheme.
Whenever Scheme is ready for you to type something, it displays a prompt on
the left side of the last line in the Edwin Interaction-mode buffer:

\noindent
\begin{verbatim}
 ==> _
\end{verbatim}

\noindent At this point, anything you type will be taken by Edwin and sent
to Scheme, as soon as you press \key{execute}.  Scheme will accept what you
typed as a Scheme expression, evaluate it, and display the result on the lines
below.  Below the result, Scheme will display another prompt, signalling that
it is ready for you to type another Scheme expression.  For example,

\noindent
\begin{verbatim}
 ==> (factorial 10)
3628800

 ==> _
\end{verbatim}

Here are the special commands for evaluating Scheme expressions and
definitions, available in both Scheme-mode and Interaction-mode buffers:

\startkeytable

\describekey
 {6.001 Evaluate Expression}
 {\key{execute}}
 {}
 {Evaluate the expression preceding the point.}

\describekey
 {6.001 Evaluate Definition}
 {\ctrl \kkey{7}}
 {}
 {Evaluate the definition containing the point.}

\describekey
 {Evaluate Region}
 {\ctrl \shift \kkey{7}}
 {}
 {Evaluate the region.}

\describekey
 {6.001 Evaluate Buffer}
 {\shift \kkey{7}}
 {\run \key{o}}
 {Evaluate the entire buffer.}

\describekey
 {Scheme Interaction Buffer}
 {\key{scheme} (\kkey{7})}
 {}
 {Place the Interaction-mode buffer (usually {\tt *scheme*}) in the current
  window.  If there is no Interaction-mode buffer, create one and put it in
  the current window.}
\finishkeytable

\newpage
\section{Search}

Edwin has commands {\tt Incremental Search} and {\tt Reverse Search} for
searching through a buffer for occurrences of a particular pattern of text.

To search forwards from the point, press \kkey{5}; to search backwards from
the point, press \ctrl \kkey{5}.  Next, type the text you seek; your typing
will appear in the typein window.  As you type, Edwin will move the point
forward to the next occurrence of the text you have typed so far (the next
{\it match}).  If Edwin cannot find the text, it will display `{\tt Failing
I-Search}' or `{\tt Failing Reverse I-Search}' at the left side of the typein
window, depending on the direction of the search.

Correct the search text you are typing with \key{back space}.  As you press
this key, Edwin may move the point back to a previous match, because it always
looks for the first match after the point (or before the point, in reverse
search).

To search for the first match after the one at the point, press \kkey{5} or
\ctrl \kkey{5} again.  To change the direction of search, press \kkey{5} for
forward or \ctrl \kkey{5} for backward.

If you press \kkey{5} when a forward search has failed, Edwin will ``wrap
around'' the buffer, starting the search over at the beginning of the buffer.
If you press \ctrl \kkey{5} when a reverse search has failed, Edwin will start
the search over at the end of the buffer.

When you find the text you are looking for, press \key{run}.  This will stop
the search, leaving the point immediately after the matching text.

If you press \key{abort} during a search, Edwin will return the point to the
position where the search began, stopping the search.  You must press
\key{abort} twice to end a failing search.  The first time you press
\key{abort}, Edwin will move you to the previous match; the second time, Edwin
will cancel the search entirely, returning to the position where the search
began.

\startkeytable

\describekey
 {Incremental Search}
 {\kkey{5}}
 {\ctrl \key{s}}
 {Search forward incrementally.}

\describekey
 {Reverse Search}
 {\shift \kkey{5}}
 {\ctrl \key{r}}
 {Search backward incrementally.}
\finishkeytable

\section{Replace}

Not only can Edwin search a buffer for a particular pattern of text, it can
replace some or all instances of this text with another piece of text.  {\tt
Replace String} replaces all instances of the search text with the replacement
text; {\tt Query Replace} finds instances of the search text, stopping at each
match to ask you whether to replace it with the replacement text.

\startkeytable

\describekey
 {Replace String}
 {\ctrl \shift \kkey{5}}
 {}
 {Ask for two pieces of text.  Search through the buffer, beginning at the
  point, looking for occurrences of the first piece of text.  Wherever it's
  found, replace it with the second piece of text.}

\describekey
 {Query Replace}
 {\ctrl \kkey{5}}
 {\runkey{\%}}
 {Ask for two pieces of text.  Search through the buffer, beginning at the
  point, looking for occurrences of the first piece of text.  Wherever Edwin
  finds a match, ask whether to replace it with the second piece of text.}
\finishkeytable

To use {\tt Replace String}, press \ctrl \shift \kkey{5}.  First, Edwin will
ask you to type the search text in the typein window; press \key{enter} when
you have.  Next, Edwin will ask you to type the replacement text in the typein
window; again, press \key{enter} when you have.  Then, Edwin will search
forward from the point, replacing all instances of the search text with the
replacement text.

Be careful with {\tt Replace String}, because it can change your buffer in
unexpected ways --- it will do what you tell it to, not necessarily what you
want it to do.  It is a good idea to save your buffer to disk before using
this command.

\noindent
\begin{minipage}[t]{\linewidth}
Start {\tt Query Replace} exactly as you would {\tt Replace String}, supplying
search text and replacment text.  Edwin will stop at each match following the
point, asking you whether to replace it.  The following responses are
possible:

\noindent
{\smalltype
\begin{tabular}[l]{p{1in}p{4in}}

\key{space} & Replace this match, then search for the next. \\

\key{back space} & Search for the next match without replacing this one. \\

\key{run} & Stop the search, leaving the point at the latest match. \\

\key{$\cdot$} & Replace this match and stop the search. \\

\key{!} & Replace all remaining matches with no more questions. \\

\key{$\wedge$} & Move the point back to the previous match. \\

\end{tabular}
}
\end{minipage}

\newpage
\section{Buffers}

Use these commands to control Edwin's buffers:

\startkeytable

\describekey
 {Select Buffer}
 {\key{select buffer} (\kkey{4})}
 {\ctrl \key{x} \key{b}}
 {Ask for the name of another buffer, and place that buffer in the current
  window.  Edwin will suggest one buffer; accept the suggestion by pressing
  \key{enter}, or type the name of the one you really want to see instead.}

\describekey
 {Twiddle buffers}
 {\ctrl \kkey{4}}
 {}
 {Select the ``other'' buffer.  Same as typing \key{Select Buffer} \key{Enter}.}

\describekey
 {Kill Buffer}
 {\ctrl \shift \kkey{4}}
 {\ctrl \key{x} \key{k}}
 {Kill the current buffer; completely eliminate the current buffer and all the
  text in it.}

\describekey
 {List Buffers}
 {\shift \kkey{4}}
 {\ctrl \key{x} \ctrl \key{b}}
 {List all the existing buffers in a new buffer called {\tt *Buffer-List*}.}
\finishkeytable

The following keys have special functions in a {\tt *Buffer-List*} buffer
(created by the {\tt List Buffers} command, above):

\noindent
{\smalltype
\begin{tabular}[l]{p{1in}p{4in}}

\key{m} & Mark buffer on current line to be displayed. \\

\key{q} & Select buffer on current line. \\

\key{1} & Select buffer on current line in a full-screen window. \\

\key{2} & Select buffer on current line in one window, and the buffer
selected before it in another window. \\

\key{s} & Mark the buffer on the current line as a buffer to be
saved when you press \key{x} in the {\tt *Buffer-List*} buffer. \\

\key{d} & Mark the buffer on the current line to be killed when you
press \key{x} in the {\tt *Buffer-List*} buffer. \\

\key{x} & Kill or save the buffers previously marked with \key{s}
and \key{d}. \\

\key{u} & Remove all `kill' and `save' marks from the current line. \\

\key{back space} & Move up one line and remove marks. \\

\key{space} & Move down one line. \\

\end{tabular}
}

\newpage
\section{Windows}

Use these commands to control the appearance of windows on the screen:

\startkeytable

\describekey
 {Other Window}
 {\key{other window} (\kkey{6})}
 {\ctrl \key{x} \key{o}}
 {Move the cursor to the window immediately below the current window, or to
  the top window if the cursor is already in the lowest window.}

\describekey
 {Split Window Vertically}
 {\key{two windows} (\shift \kkey{6})}
 {\ctrl \key{x} \key{2}}
 {Split the current window into two windows.}

\describekey
 {Delete Other Windows}
 {\key{one window} (\ctrl \kkey{6})}
 {\ctrl \key{x} \key{1}}
 {Expand the current window to fill the entire screen.}

\describekey
 {Enlarge Window Vertically}
 {\key{grow window} (\ctrl \shift \kkey{6})}
 {\ctrl \key{x} \key{$\wedge$}}
 {Make the current window one line bigger.  If an argument is given, make the
  current window that number of lines bigger.}

\describekey
 {New Window}
 {\shift \key{recall}}
 {\ctrl \key{l}}
 {Center the point in the window and redisplay the screen.}
\finishkeytable

\newpage
\section{Saving and Loading Files}
\label{saving-loading}

Use these commands to save and load files:

\startkeytable

\describekey
 {Find File}
 {\key{find file} (\shift \kkey{0})}
 {\ctrl \key{x} \ctrl \key{f}}
 {Load a file into a new Edwin buffer.  Edwin will ask you the name of the
  file to load.}

\describekey
 {Find Alternate File}
 {\key{visit file} (\ctrl \kkey{0})}
 {\ctrl \key{x} \ctrl \key{v}}
 {Kill the current buffer, then load another file into a new buffer in the
  current window.  Same as typing \ctrl \shift \kkey{4} \key{enter} \key{find
  file}.  Edwin will ask the name of the file to load.}

\describekey
 {Save File}
 {\key{save file} (\kkey{0})}
 {\ctrl \key{x} \ctrl \key{s}}
 {Save current buffer to its file.  If there is not yet a file associated with
  the buffer, Edwin will ask for one in the typein window.}

\describekey
 {Write File}
 {\key{write file} (\ctrl \shift \kkey{0})}
 {\ctrl \key{x} \ctrl \key{w}}
 {Save current buffer to a file.  Edwin will ask the name of the file to which
  to save this buffer.  Normally, you will want to use \key{save file}; use
  \key{write file} when you want to make extra disk copies of a buffer.}

\describekey
 {Insert File}
 {\extend {\tt Insert File}}
 {\ctrl \key{x} \key{i}}
 {Insert the contents of a file into the buffer at the current point.  Edwin
  will ask you the name of the file to insert.}
\finishkeytable

\newpage
\section{Directory Edit}
\label{Dired}

Edwin has a major mode, {\it Dired}, for dealing with directories of files on
disks.  To create a Dired-mode buffer for a disk directory (for example, for
one of your floppy disks), issue the extended command {\tt dired} (i.e., type
\extend {\tt dired} \key{enter}).  Edwin will ask, in the typein window, for
the name of the directory to list.  Enter your response, remembering to end
the disk name with a colon `:', and press \key{enter}.  If Edwin can find the
directory you give, it will list the files.  You can move through the list of
files with the normal cursor motion commands (arrow keys, etc.).  The
following keys have special functions in Dired-mode buffers:

\noindent
{\smalltype
\begin{tabular}[l]{p{1in}p{4in}}

\noindent \key{f} & Load the file on the current line into a new Edwin
buffer. \\

\noindent \key{d} & Mark the file on the current line, so that it will be
erased when you press \key{x} in the buffer. \\

\noindent \key{u} & Remove marks (made by \key{d}) from the current line, so
that the file on the current line will not be deleted when you press \key{x}. \\

\noindent \key{back space} & Move up one line and remove marks. \\

\noindent \key{space} & Move down one line. \\

\noindent \key{x} & Erase the files previously marked using \key{d}. \\

\noindent \key{q} & Leave the {\tt Dired} buffer, erasing the files
previously marked using \key{d}. \\

\end{tabular}
}

\newpage
\section{Printing}
\label{printing}
Use these commands to print your work on paper:

\startkeytable

\describekey
 {Print Buffer}
 {\shift \key{ins ln}}
 {}
 {Print the entire buffer.}

\describekey
 {Print Region}
 {\ctrl \key{ins ln}}
 {}
 {Print the region.}

\describekey
 {Print File}	
 {\ctrl \shift \key{ins ln}}
 {}
 {Print a file.  Edwin will ask you the name of the file to print.}
\finishkeytable

\section{Miscellaneous Commands}

Here are some commands which do not fit in the categories above:

\startkeytable

\describekey
 {Uppercase Initial}
 {\ctrl \kkey{8}}
 {\runkey{c}}
 {Capitalize the first full word following the point.}

\describekey
 {Uppercase Word}
 {\shift \kkey{8}}
 {\runkey{u}}
 {Convert the first full word following the point to all upper case letters.}

\describekey
 {Lowercase Word}
 {\ctrl \shift \kkey{8}}
 {\runkey{l}}
 {Convert the first full word following the point to all lower case letters.}

\describekey
 {Screen Video}
 {\ctrl \shift \key{ins chr}}
 {\ctrl \key{x} \key{v}}
 {Reverse video.  Change white-on-black text to black-on-white and vice versa.
  This only affects how Edwin displays text on the screen, not how it will be
  printed.}
\finishkeytable