\section{GNU Emacs customization}

One of the best features of GNU Emacs is ease of customization.  GNU
Emacs functions are written in emacs--lisp, a very well-documented
language (see the document ``Gnu Emacs Programming'' by Robert
Krawitz, available in the SIPB office, W20-557).  Changes to the
default key bindings, variable settings, and new functions all go in
one file, the GNU Emacs startup file, which (you guessed it) is read
by GNU Emacs on startup.

A sample startup file documenting the use of various handy functions can be found in {\it /mit/sipb/pro\-to\-type/sipb.emacs}.  Additional emacs--lisp functions can be found in the directory {\it /mit/watch\-maker/lib/elisp} (which is available after you type {\tt attach watchmaker}---see the section on useful filesystems for more details).  In particular, look at the file {\it world.emacs.el}.

When GNU Emacs starts, it looks for a file called {\it .emacs}.
If this file exists, Emacs reads and executes all of the commands
in it.

GNU Emacs allows emacs--lisp files to be {\sl byte-compile\/}'d. A
{\sl byte-compile\/}'d file loads much faster than the source file
from which it was compiled, but cannot be edited easily. The Emacs
function {\sl byte-compile-file} can be used to compile a {\it .el}
file into a {\it .elc} file (The extensions, {\it .el} and {\it .elc}
indicate, respectively, emacs--lisp and emacs--lisp--compiled.  They
let GNU Emacs know that you're working on a emacs--lisp file.).  To
speed up startup of your Emacs, put all your customizations in {\it
.emacs\_init.el}, {\sl byte-compile-file} it, and then load the
compiled file automatically upon startup of Emacs with a command in
your {\it .emacs} file:
\begin{verbatim}
(load "~/.emacs_init.elc")
\end{verbatim}

Any GNU Emacs command can be invoked with {\tt M-x} {\it command\_name}
when in Emacs.  To give an argument to a GNU Emacs command, type {\sl
ESC number} (the number can be several digits) before typing {\it
command}.  Some commands may already be
bound to keys.  GNU Emacs has an extensive online help facility.  If you
are interested, type {\tt M-x} {\sl help-for-help\/} or {\tt C-h C-h}.

GNU Emacs has many useful functions to help you get work done.  {\sl
manual-entry} prompts you for a topic, and runs the Unix {\tt man}
command, looking up the topic in the online Unix manual.  The text
that is found is inserted into a buffer named {\sl *Manual Entry*} and
displayed.  It is useful because the buffer stays around for further
reference, instead of disappearing irrevocably from the screen.  To
have more than one man page in an Emacs at any given time, though, you
should rename the old buffer, because otherwise the new man page will
overwrite the old one.  To rename a buffer, use {\sl rename-buffer}.
{\sl lpr-buffer} will send the contents of a buffer to the printer.

There are many functions of GNU Emacs that change their behavior based
on the value of variables.  You can set the value of these variables
by using {\sl set-variable} which will prompt for a variable name and
the value to assign to it.  After typing {\tt M-x} {\sl set-variable}
Emacs prompts you with ``Set Variable:'' to which you type the
variable name.  It then prompts ``Set {\it variable-name} to value:''
to which you type the value you wish to assign.  Remember that if you
are entering a list for a value, you must quote the list with a single
quote ('): {\tt '(elem1 elem2 \ldots)}.

The {\it lpr-switches} variable controls the flags passed on to {\tt
lpr} when using {\sl lpr-buffer}.  This variable should be a list of
strings, each a separate argument for {\tt lpr}.  If you want to
change the printer to which your output is routed, you should include
{\tt "}-P{\it printer-name\/}{\tt "} in the list: '({\tt "}-P{\it
printer-name\/}{\tt "} \ldots).


There are also several functions included solely for their hack value.
None of them are as captivating as, say, larn or nethack, but they {\em
are} readily available when you (and everyone else) are in the middle of
writing that 3am paper\ldots.

\begin{description}

\item[{\sl yow}] prints a random Zippy-the-Pinhead quotation

\item[{\sl dissociated-press}] takes a text buffer (the larger
the better) and turns it into something only slightly more
mangled than a typical Reagan speech.

\item[{\sl hanoi}] invoked with a numerical argument from 1 to 9,
solves the tower of hanoi puzzle with that many rings.  {\em Not} fun
to play over a 1200 baud line!

\item[{\sl doctor}] invokes a version of Joseph Weizenbaum's
famous Eliza, the computer ``psychoanalyst.''

\item[{\sl psychoanalyze-pinhead}] Zippy the Pinhead meets Eliza.
You have to see it to believe it.  (Type {\tt C-g} to return to your
work.)

\item[{\sl flame}] prints out a line of random flaming.  A cross between
{\sl yow} and {\sl dissociated-press}, sort of.  To get this, you must
load the {\it flame} library first, by typing {\sl {\tt M-x}
load-library {\tt <RETURN>} flame}.

\item[{\sl psychoanalyze-flamer}]  Eliza tackles the flamer.  Also
requires you to {\sl {\tt M-x} load-library {\tt <RETURN>} flame}.
You need only load {\sl flame} once per emacs session.

\end{description}
