.ll 6i
.lt 6i
.po .8i
.de HD
..
.de FO
..
.de P
.sp
.ti 8n
..
.de BG	\" make something BIG
.br
\s14\fB\\$1\fP\s0
.br
..
.wh 0 HD
.wh -1i FO
.ls 1
.in 1i
.sp 12
.BG MicroEMACS
.sp
.nf
Full Screen Text Editor
Reference Manual (preliminary draft)
.sp
Version 3.9e
November 4, 1987
.sp
(C)opyright 1987 by Daniel M. Lawrence
Reference Manual (C)opyright 1987
	by Brian Straight and Daniel M. Lawrence
All Rights Reserved
.sp
.fi
\fIMicroEMACS 3.9e can be copied and distributed freely
for any non-commercial purposes. MicroEMACS 3.9e can
only be incorporated into commercial software with
the permission of the current author.\fP
.in 0
.bp
.sp |.5i
.if t .sp .5i
.BG Introduction
.P
MicroEMACS is a tool for creating and changing documents,
programs, and other text files.  It is both relatively easy for the
novice to use, but also very powerful in the hands of an expert.
MicroEMACS can be extensively customized for the needs of the
individual user.
.P
MicroEMACS allows several files to be edited at the same time.
The screen can be split into different windows, and text may be moved
freely from one window to the next.  Depending on the type of file being
edited, MicroEMACS can change how it behaves to make editing simple. 
Editing standard text files, program files and word processing documents
are all possible at the same time.
.P
There are extensive capabilities to make word processing and
editing easier.  These include commands for string searching and
replacing, paragraph reformatting and deleting, automatic word wrapping,
word move and deletes, easy case controlling, and automatic word counts.
.P
For complex and repetitive editing tasks editing macroes can be
written.  These macroes allow the user a great degree of flexibility in
determining how MicroEMACS behaves.  Also, any and all the commands can
be used by any keystroke by changing, or rebinding, what commands
various keys are connected, or bound, to. 
.P
Special features are also available to perform a diverse set of
operations such as file encryption, automatic backup file generation,
entabbing and detabbing lines, executing of DOS commands and filtering
of text through other programs (like SORT to allow sorting text).
.sp
.BG "History"
.P
EMACS was originally a text editor written by Richard Stahlman
at MIT in the early 1970s for Digital Equipment computers. Various
versions, rewrites and clones have made an appearance since.
.P
This version of MicroEMACS is derived from code written by Dave
G. Conroy in 1985.  Later modifications were performed by Steve Wilhite
and George Jones.  In December of 1985 Daniel Lawrence picked up the
then current source (version 2.0) and made extensive modifications and
additions to it over the course of the next two years.  Updates and
support for the current version are still available.  The current
program author can be contacted by writing to:
.sp
.nf
	USMAIL:	Daniel Lawrence
			617 New York St
			Lafayette, IN 47901

	UUCP:	ihnp4!pur-ee!pur-phy!duncan!lawrence
	ARPA:	nwd@j.cc.purdue.edu
	FIDO:	Fido 201/2 The Programmer's Room (317) 742-5533
.fi
.de HD
'ev 2
'ft R
'ps 10
'vs 12
'sp .5i
'if o 'tl +\\*(Ct++MicroEMACS Reference Manual+
'if o 'tl +\\*(C2+++
'if e 'tl +MicroEMACS Reference Manual++\\*(Ct+
'if e 'tl +++\\*(C2+
'sp |1i
'ev
..
.nr Cn 0 1
.nr Sn 0 1
.nr Ss 0 1
.nr An 0 1
.af An A
.nr As 0 1
.de CH	\" Chapter Header
.ds Ct "\\$1
.ds C2 "\\$2
.bp
.if t \{\
.if e .bp  \" start chapters on odd pages
\}
.sp 1i
.tl ''\s+2\fBChapter \\n+(Cn\fP\s0''
.sp
.tl ''\s+2\fB\\$1 \\$2\fP\s0''
.sp
.nr Sn 0 1
.nr Ss 0 1
..
.de AH	\" Appendix Header
.ds Ct "\\$1
.ds C2 "\\$2
.bp
.if t \{\
.if e .bp  \" start chapters on odd pages
\}
.sp 1i
.tl ''\s+2\fBAppendix \\n+(An\fP\s0''
.sp
.tl ''\s+2\fB\\$1 \\$2\fP\s0''
.sp
.nr As 0 1
..
.de SH	\" Section Header
.ne 5
.sp 2
.tl '\fB\\n(Cn.\\n+(Sn\ \ \\$1\fP'''
.sp
.nr Ss 0 1
..
.de SS	\" Subsection Header
.ne 5
.sp 2
.tl '\fB\\n(Cn.\\n(Sn.\\n+(Ss\ \ \\$1\fP'''
.sp
..
.de AS	\" Appendix section
.bp
.sp |1i
.tl '\fB\\n(An.\\n+(As\ \ \\$1\fP'''
.sp
..
.de SD	\" Start description
.nr Di \\$1u
.in \\n(Diu
.ta \\n(Diu
..
.de ND	\" Next description element
.sp
.ti -\\n(Diu
..
.de ED	\" End description
.in 0
.nr Di 0
.sp
..
.de QS
.sp
.ll -.5i
.in +.5i
.ft I
..
.de QE
.sp
.ll +.5i
.in -.5i
.ft P
..
.de CS
.bp
.sp 1i
.tl ''\fBChapter \\n(Cn Summary\fP''
.P
In chapter \\n(Cn, \c
..
.pn 1
.CH "Basic Concepts"
.de FO
'ev 2
'ft R
'ps 10
'vs 12
'sp
'if o 'tl +%+++
'if e 'tl +++%+
'ev
'bp
..
.P
The current version of MicroEMACS is 3.9e (Third major re-write,
ninth public release, fifth minor edit), and for the rest of this
document, we shall simply refer to this version as "EMACS".  Any
modifications for later versions will be listed in the appendixes at the
end of this manual. 
.SH "Keys and the Keyboard"
.P
Many times throughout this manual we will be talking about
commands and the keys on the keyboard needed to use
them.  There are a number of "special" keys which can be used and are
listed here:
.SD \w'META\ or\ M-\ \ 'u
.ND
<NL>	NewLine which is also called RETURN or ENTER, this key is used to
end different commands. 
.ND
^	The control key can be used before any alphabetic character and some
symbols.  For example, ^C means to hold down the <CONTROL> key and type
the C key at the same time. 
.ND
^X	The CONTROL-X key is used at the beginning of many different
commands. 
.ND
META\ or\ M-	This is a special EMACS key used to begin many commands as
well.  This key is pressed and then released before
typing the next character.  On most systems, this is the <ESC> key, but
it can be changed.  (consult appendix E to learn what key is used for
META on your computer).
.ED
Whenever a command is described, the manual will list the actual
keystrokes needed to execute it in \fBboldface\fP using the above
conventions, and also the name of the command in \fIitalics\fP.
.SH "Getting Started"
.P
In order to use EMACS, you must call it up from your system or
computer's command prompt.  On UNIX and MSDOS machines, just type
"emacs" from the main command prompt and follow it with the <RETURN> or
<ENTER> key (we will refer to this key as <NL> for "new-line" for the
remainder of this manual).  On the Macintosh, the Amiga, the ATARI ST
and other icon based operating systems, double click on the uEMACS icon.
Shortly after this, a screen similar to the one below should appear.
.SH "Parts and Pieces"
.P
The screen is divided into a number of areas or \fBwindows\fP.  On
some systems the top window contains a function list of unshifted and
shifted function keys.  We will discuss these keys later. 
Below them is an EMACS \fBmode line\fP which, as we will
see, informs you of the present mode of operation of the editor \(em for
example "(WRAP)" if you set EMACS to wrap at the end of each line. 
Under the mode line is the \fBtext window\fP where text
appears and is manipulated.  Since each window has its own mode line,
below the text window is it's mode line.  The last line of the screen is
the \fBcommand line\fP where EMACS takes commands and reports on what it
is doing. 
.sp
.nf
.cs R 22
===============================================================================
f1 search-> f2 <-search |    MicroEMACS:  Text Editor
f3 hunt->   f4 <-hunt   | 
f5 fkeys    f6 help     |  Available function key Pages include:
f7 nxt wind f8 pg[    ] |    WORD  PROG  BOX
f9 save     f10 exit    |  [use the f8 key to load Pages]
===============================================================================
-- MicroEMACS 3.9e () -- Function Keys ----------------------------------------
===============================================================================












===============================================================================
-- MicroEMACS 3.9e () -- Main -------------------------------------------------
===============================================================================
.cs R
.fi
.sp
.tl ''Fig 1:  EMACS screen on an IBM-PC''
.SH "Entering Text"
.P
Entering text in EMACS is simple.  Type the following sentence fragment:
.QS
Fang Rock lighthouse, center of a series of mysterious and
.QE
The text is displayed at the top of the text window.  Now type:
.QS
terrifying events at the turn of the century
.QE
Notice the text to the left of the cursor disappears and a '$' sign
appears.  Don't panic \(em your text is safe!!! You've just discovered that
EMACS doesn't "wrap" text to the next line like most word processors
unless you hit <NL>.  But since EMACS is used for both word processing,
and text editing, it has a bit of a dual personality.  You can change
the way it works by setting various \fBmodes\fP.  In this
case, you need to set \fBWRAP\fP mode, using the \fIadd-mode\fP
command, by typing \fB^X-M\fP.  The command line at the
base of the screen will prompt you for the mode you wish to add.  Type
\fBwrap\fP followed by the <NL> key and any text you now enter will be
wrapped.  However, the command doesn't wrap text already entered.  To
get rid of the truncated line, delete characters with the <BACKSPACE>
key until the '$' goes away.  Now type in the words you deleted, watch
how EMACS goes down to the next line at the right time.  \fIIn some
versions of EMACS, \fP\fBWRAP\fP\fI is a default mode in which case you don't
have to worry about the instructions relating to adding this mode.\fP

Now let's type a longer insert.  Hit <NL> a couple of times to tab
down from the text you just entered.  Now type the following paragraphs. 
Press <NL> twice to indicate a paragraph break. 
.QS
Fang Rock lighthouse, center of a series of mysterious and
terrifying events at the turn of the century, is built on a rocky island
a few miles of the Channel coast.  So small is the island that wherever
you stand its rocks are wet with sea spray. 
.sp
The lighthouse tower is in the center of the island.  A steep flight of
steps leads to the heavy door in its base.  Winding stairs lead up to
the crew room.
.QE
.SH "Basic cursor movement"
.sp
Now let's practice moving around in this text.  To move the cursor back
to the word "Winding," enter \fBM-B\fP \fIprevious-word\fP.
This command moves the cursor backwards by one
word at a time.  Note you have to press the key combination every time
the cursor steps back by one word.  Continuously pressing META and
toggling B produces an error message.  To move forward to the word
"stairs" enter \fBM-F\fP, which moves the cursor forward by one word at a
time. 

Notice that EMACS commands are usually mnemonic \(em F for forward, B for
backward, for example.

To move the cursor up one line, enter \fB^P\fP \fIprevious-line\fP,
down one line \fB^N\fP \fInext-line\fP.
Practice this movement by moving the cursor to the
word "terrifying" in the second line. 

The cursor may also be moved forward or backward in smaller increments. 
To move forward by one character, enter \fB^F\fP \fIforward-character\fP,
to move backward, \fB^B\fP
\fIbackward-character\fP.  EMACS also allows
you to specify a number which is normally used to tell a command to
execute many times.  To repeat most commands, press META and then the
number before you enter the command.  Thus, the command META 5 ^F
(\fBM-5^F\fP) will move the cursor forward by five characters.  Try moving
around in the text by using these commands.  For extra practice, see how
close you can come to the word "small" in the first paragraph by giving
an argument to the commands listed here. 
.sp
Two other simple cursor commands that are useful to help us move around
in the text are \fBM-N\fP \fInext-paragraph\fP which
moves the cursor to the second paragraph, and \fBM-P\fP
\fIprevious-paragraph\fP which moves it back to
the previous paragraph.  The cursor may also be moved rapidly from one
end of the line to the other.  Move the cursor to the word "few" in the
second line.  Press \fB^A\fP \fIbeginning-of-line\fP.
Notice the cursor moves to the word "events"
at the beginning of the line.  Pressing \fB^E\fP \fIend-of-line\fP
moves the cursor to the end of the line. 
.sp
Finally, the cursor may be moved from any point in the file to the end
or beginning of the file.  Entering \fBM->\fP \fIend-of-file\fP
moves the cursor to the end of the buffer, \fBM-<\fP
\fIbeginning-of-file\fP to the first character
of the file. 
.sp
\fIOn the IBM-PC, the ATARI ST and many other machines, the cursor keys
can also be used to move the cursor about.  Also, if
there is one available, moving the mouse will move the cursor\fP.
.sp
Practice moving the cursor in the text until you are comfortable with
the commands we've explored in this chapter.
.SH "Saving your text"
.sp
When you've finished practicing cursor movement, save your file.  Your
file currently resides in a \fBBUFFER\fP.  The buffer is a
temporary storage area for your text, and is lost when the computer is
turned off.  You can save the buffer to a file by entering \fB^X-^S\fP
\fIsave-file\fP.  Notice that EMACS informs you that
your file has no name and will not let you save it. 
.sp
To save your buffer to a file with a different name than it's current
one (which is empty), press \fB^X^W\fP \fIwrite-file\fP. 
EMACS will prompt you for the filename you wish to write.  Enter the
name \fBfang.txt\fP and press return.  On a micro, the drive light will
come on, and EMACS will inform you it is writing the file.  When it
finishes, it will inform you of the number of lines it has written to
the disk. 
.sp
Congratulations!! You've just saved your first EMACS file!
.CS
you learned how to enter text, how
to use wrap mode, how to move the cursor, and to save a buffer.  The
following is a table of the commands covered in this chapter and their
corresponding key bindings:
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
abort-command	^G	aborts current command
.sp
add-mode	^XM	allows addition of EMACS mode
		such as \fBWRAP\fP
.sp
backward-character	^B	moves cursor left one character
.sp
beginning-of-file	M-<	moves cursor to beginning of file
.sp
beginning-of-line	^A	moves cursor to beginning of line
.sp
end-of-file	M->	moves cursor to end of file
.sp
end-of-line	^E	moves cursor to end of line
.sp
forward-character	^F	moves cursor right one character
.sp
next-line	^N	moves cursor to next line
.sp
next-paragraph	M-N	moves cursor to next paragraph
.sp
next-word	M-F	moves cursor forward one word
.sp
previous-line	^P	moves cursor backward by one line
.sp
previous-paragraph	M-P	moves cursor to previous paragraph
.sp
previous-word	M-B	moves cursor backward by one word
.sp
save-file	^X-^S	saves current buffer to a file
.sp
write-file	^X-^W	save current buffer under a new name
.TE
.CH "Basic Editing \(em" "Simple Insertions and Deletions"
.sp
.SH "A Word About Windows, Buffers, Screens, and Modes"
.sp
In the first chapter, you learned how to create and save a file in
EMACS.  Let's do some more editing on this file.  Call up emacs by
typing in the following command.
.sp
.tl ''\fBemacs fang.txt\fP''
.sp
\fIOn icon oriented systems, double click on the uEMACS icon, usually a
file dialog box of some sort will appear.  Choose \fP\fBFANG.TXT\fP\fI from the
appropriate folder.\fP
.sp
Shortly after you invoke EMACS, the text should appear on the screen
ready for you to edit.  The text you are looking at currently resides in
a \fBbuffer\fP.  A buffer is a temporary area of computer memory which is
the primary unit internal to EMACS -- this is the place
where EMACS goes to work.  The mode line at the bottom of the screen
lists the buffer name, \fBFANG.TXT\fP and the name of the file with which
this buffer is associated, \fBFANG.TXT\fP
.sp
The computer talks to you through the use of its \fBscreen\fP.  This
screen usually has an area of 24 lines each of 80
characters across.  You can use EMACS to subdivide the screen into
several separate work areas, or \fBwindows\fP, each of which can be
\&'looking into' different files or sections of text.  Using
windows, you can work on several related texts at one time, copying and
moving blocks of text between windows with ease.  To keep track of what
you are editing, each window is identified by a \fBmode line\fP on the
last line of the window which lists the
name of the \fBbuffer\fP which it is looking into, the file from which the
text was read, and how the text is being edited. 

An EMACS \fBmode\fP tells EMACS how to deal with user input.  As we have
already seen, the mode 'WRAP' controls how EMACS deals with long lines
(lines with over 79 characters) while the user is typing them in.  The
'VIEW' mode, allows you to read a file without modifying it.  Modes are
associated with buffers and not with files; hence, a mode needs to be
explicitly set or removed every time you edit a file.  A new file read
into a buffer with a previously specified mode will be edited under this
mode.  If you use specific modes frequently, EMACS allows you to set
the modes which are used by all new buffers, called \fBglobal\fP modes. 
.SH "Insertions"
.sp
Your previously-saved text should look like this:
.QS
Fang Rock lighthouse, center of a series of mysterious and
terrifying events at the turn of the century, is built on a rocky island
a few miles of the Channel coast.  So small is the island that wherever
you stand its rocks are wet with sea spray. 
.sp
The lighthouse tower is in the center of the island.  A steep flight of
steps leads to the heavy door in its base.  Winding stairs lead up to
the crew room.
.QE
Let's assume you want to add a sentence in the second paragraph after
the word "base."  Move the cursor until it is on the "W" of "Winding".
Now type the following:
.QS
This gives entry to the lower floor where the big steam
generator throbs steadily away, providing power for the electric
lantern.
.QE
If the line fails to wrap and you end up with a '$' sign in the right
margin, just enter \fBM-Q\fP \fIfill-paragraph\fP to
reformat the paragraph.  This new command attempts to fill out a
paragraph.  Long lines are divided up, and words are shuffled around to
make the paragraph look nicer. 
.sp
Notice that all visible EMACS characters are self-inserting \(em all you
had to do was type the characters to insert and the existing text made
space for it.  With a few exceptions discussed later, all non-printing
characters (such as control or escape sequences) are commands.  To
insert spaces, simply use the space bar.  Now move to the first line of
the file and type \fB^O\fP \fIopen-line\fP (Oh, not zero). 
You've just learned how to insert a blank line in your text. 
.SH "Deletions"
.sp
EMACS offers a number of deletion options.  For example, move the cursor
until it's under the period at the end of the insertion you just did. 
Press the backspace key.  Notice the "n" on "lantern" disappeared.  The
backspace implemented on EMACS is called a \fBdestructive\fP backspace \(em it
removes text immediately before the current cursor position from the
buffer.  Now type \fB^H\fP \fIdelete-previous-character\fP.
Notice that the cursor moves back
and obliterates the "r" \(em either command will backspace the cursor. 
.sp
Type in the two letters you erased to restore your text and move the
cursor to the beginning of the buffer \fBM->\fP \fIbeginning-of-file\fP.
Move the cursor down one line to the beginning of the first paragraph. 
.sp
To delete the forward character, type \fB^D\fP \fIdelete-next-character\fP.
The "F" of "Fang" disappears.  Continue
to type \fB^D\fP until the whole word is erased EMACS also permits the
deletion of larger elements of text.  Move the cursor to the word
"center" in the first line of text.  Pressing \fBM-<backspace>\fP
\fIdelete-previous-word\fP kills the word
immediately before the cursor.  \fBM-^H\fP has the same effect. 
.sp
Notice that the commands are very similar to the control commands you
used to delete individual letters.  As a general rule in EMACS, control
sequences affect small areas of text, META sequences larger areas.  The
word forward of the cursor position can therefore be deleted by typing
\fBM-D\fP \fBdelete-next-word\fP.  Now let's take
out the remainder of the first line by typing \fB^K\fP
\fIkill-to-end-of-line\fP.  You now have a
blank line at the top of your screen.  Typing \fB^K\fP again or \fB^X-^O\fP
\fIdelete-blank-lines\fP deletes the blank line
and flushes the second line to the top of the text.  Now exit EMACS by
typing \fB^X-^C\fP \fIexit-emacs\fP.  Notice EMACS
reminds you that you have not saved your buffer.  Ignore the warning and
exit.  This way you can exit EMACS without saving any of the changes you
just made. 
.CS
you learned about the basic 'building
blocks' of an EMACS text file \(em buffers, windows, and files. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key binding	Keystroke	Effect
_
delete-previous-character	^H	deletes character immediately be-
		fore the current cursor position
.sp
delete-next-character	^D	deletes character immediately
		after current cursor position
.sp
delete-previous-word	M-^H	deletes word immediately before
		current cursor position
.sp
delete-next-word	M-D	deletes word immediately after
		current cursor position
.sp
kill-to-end-of-line	^K	deletes from current cursor
		position to end of line
.sp
insert-space	^C	inserts a space to right of
		the cursor
.sp
open-line	^O	inserts blank line
.sp
delete-blank-lines	^X-^O	removes blank line
.sp
exit-emacs	^X-^C	exits emacs
.TE
.CH "Using Regions"
.SH "Defining and Deleting a Region"
.sp
At this point its time to familiarize ourselves with two more EMACS
terms--the \fBpoint\fP and the \fBmark\fP.  The point is located directly
behind the current cursor position.  The mark
(as we shall see shortly) is user defined.  These two elements together
are called the current \fBregion\fP and limit the \fBregion\fP of text on
which EMACS performs many of its editing functions. 
.sp
Let's begin by entering some new text.  Don't forget to add \fBwrap\fP
mode if its not set on this buffer.  Start EMACS and open a file called
\fBPUBLISH.TXT\fP.  Type in the following text:
.QS
One of the largest growth areas in personal computing is
electronic publishing.  There are packages available for practically
every machine from elegantly simple programs for the humble Commodore 64
to sophisticated professional packages for PC and Macintosh computers. 
.sp
Electronic publishing is as revolutionary in its way as the Gutenburg
press.  Whereas the printing press allowed the mass production and
distribution of the written word, electronic publishing puts the means
of production in the hands of nearly every individual.  From the class
magazine to the corporate report, electronic publishing is changing the
way we produce and disseminate information. 
.sp
Personal publishing greatly increases the utility of practically every
computer.  Thousands of people who joined the computer revolution of
this decade only to hide their machines unused in closets have
discovered a new use for them as dedicated publishing workstations.
.QE
Now let's do some editing.  The last paragraph seems a little out of
place.  To see what the document looks like without it we can cut it
from the text by moving the cursor to the beginning of the paragraph. 
Enter \fBM-<space>\fP \fIset-mark\fP.  EMACS will respond
with "[Mark set]".  Now move the cursor to the end of the paragraph. 
You have just defined a region of text.  To remove this text from the
screen, type \fB^W\fP \fIkill-region\fP.  The paragraph
disappears from the screen. 
.sp
On further consideration, however, perhaps the paragraph we cut wasn't
so bad after all.  The problem may have been one of placement.  If we
could tack it on to the end of the first paragraph it might work quite
well to support and strengthen the argument.  Move the cursor to the end
of the first paragraph and enter \fB^Y\fP \fIyank\fP.  Your
text should now look like this:
.QS
One of the largest growth areas in personal computing is
electronic publishing.  There are packages available for practically
every machine from elegantly simple programs for the humble Commodore 64
to sophisticated professional packages for PC and Macintosh computers. 
Personal publishing greatly increases the utility of practically every
computer.  Thousands of people who joined the computer revolution of
this decade only to hide their machines unused in closets have
discovered a new use for them as dedicated publishing workstations. 
.sp
Electronic publishing is as revolutionary in its way as the Gutenburg
press.  Whereas the printing press allowed the mass production and
distribution of the written word, electronic publishing puts the means
of production in the hands of nearly every individual.  From the class
magazine to the corporate report, electronic publishing is changing the
way we produce and disseminate information.
.QE
.SH "Yanking a Region"
.sp
The text you cut initially didn't simply just disappear, it was cut into
a buffer that retains the 'killed' text appropriately called the \fBkill
buffer\fP.  \fB^Y\fP "yanks" the text back from this buffer into the current
buffer. If you have a long line (indicated, remember, by the "$"
sign), simply hit \fBM-Q\fP to reformat the paragraph. 
.sp
There are other uses to which the kill buffer can be put.  Using the
method we've already learned, define the last
paragraph as a region.  Now type \fBM-W\fP \fIcopy-region\fP.
Nothing seems to have happened; the cursor stays
blinking at the point.  But things have changed, even though you may not
be able to see any alteration. 
.sp
To see what has happened to the contents of the kill buffer, move the
cursor down a couple of lines and "yank" the contents of the kill buffer
back with \fB^Y\fP.  Notice the last paragraph is now repeated.  The
region you defined is "tacked on" to the end of your file because
\fBM-W\fP \fBcopies\fP a region to the kill buffer while leaving the
original text in your working buffer.  Some caution is needed however,
because the contents of the kill buffer are updated when you delete any
regions, lines or words.  If you are moving large quantities of text,
complete the operation before you do any more deletions or you could
find that the text you want to move has been replaced by the most recent
deletion.  Remember \(em a buffer is a temporary area of computer memory
that is lost when the machine is powered down or switched off.  In order
to make your changes permanent, they must be saved to a file before you
leave EMACS.  Let's delete the section of text we just added and save
the file to disk. 
.CS
you learned how to achieve longer insertions
and deletions.  The EMACS terms \fBpoint\fP and \fBmark\fP were introduced
and you learned how to manipulate text with the kill buffer. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Delete-Region	^W	Deletes region between point and mark and
		places it in KILL buffer
.sp
Copy-Region	M-W	Copies text between point and mark into
		KILL buffer
.sp
Yank-Text	^Y	Inserts a copy of the KILL buffer into
		current buffer at point
.TE
.CH "Search and Replace"
.SH "Forward Search"
.sp
Load EMACS and bring in the file you just saved.  Your file should look
like the one below.
.QS
One of the largest growth areas in personal computing is electronic
publishing.  There are packages available for practically every machine
from elegantly simple programs for the humble Commodore 64 to
sophisticated professional packages for PC and Macintosh computers. 
Personal publishing greatly increases the utility of practically every
computer.  Thousands of people who joined the computer revolution of
this decade only to hide their machines unused in closets have
discovered a new use for them as dedicated publishing workstations. 
.sp
Electronic publishing is as revolutionary in its way as the Gutenburg
press.  Whereas the printing press allowed the mass production and
distribution of the written word, electronic publishing puts the means
of production in the hands of nearly every individual.  From the class
magazine to the corporate report, electronic publishing is changing the
way we produce and disseminate information.
.QE
Let's use EMACS to search for the word "revolutionary" in the second
paragraph.  Because EMACS searches from the current cursor position
toward the end of buffers, and we intend to search forward, move the
cursor to the beginning of the text.  Enter \fB^S\fP \fIsearch-forward\fP.
Note that the command line now reads
.sp
.tl ''"Search [] <META>:"''
.sp
EMACS is prompting you to enter the \fBsearch string\fP \(em the text you
want to find.  Enter the word \fBrevolutionary\fP and hit the \fBMETA\fP
key.  The cursor moves to the end of the word "revolutionary."
.sp
Notice that you must enter the <META> key to start the search.  If you
simply press <NL> the command line responds with "<NL>". 
Although this may seem infuriating to users who are used to pressing the
return key to execute any command, EMACS' use of <META> to begin
searches allows it to pinpoint text with great accuracy.  After every
line wrap or carriage return, EMACS 'sees' a new line character (<NL>). 
If you need to search for a word at the end of a line, you can specify
this word uniquely in EMACS. 
.sp
In our sample text for example, the word "and" occurs a number of times,
but only once at the end of a line.  To search for this particular
occurrence of the word, move the cursor to the beginning of the buffer
and type \fB^S\fP.  Notice that EMACS stores the last specified
search string as the \fBdefault\fP string.  If you
press \fB<META>\fP now, EMACS will search for the default string, in this
case, "revolutionary."
.sp
To change this string so we can search for our specified "and" simply
enter the word \fBand\fP followed by \fB<NL>\fP.  The command
line now shows:
.sp
.tl ''"search [and<NL>]<META>:"''
.sp
Press \fB<META>\fP and the cursor moves to "and" at the end of the second
last line.
.SH "Exact Searches"
.sp
If the mode EXACT is active in the current buffer, EMACS searches on a case
sensitive basis.  Thus, for example you could search for \fBPublishing\fP
as distinct from \fBpublishing\fP. 
.SH "Backward Search"
.sp
Backward searching is very similar to forward searching except that it
is implemented in the reverse direction.  To implement a reverse search,
type \fB^R\fP \fIsearch-reverse\fP.  Because EMACS
makes no distinction between forward and backward stored search strings,
the last search item you entered appears as the default string.  Try
searching back for any word that lies between the cursor and the
beginning of the buffer.  Notice that when the item is found, the point
moves to the beginning of the found string (i.e., the cursor appears
under the first letter of the search item). 
.sp
Practice searching for other words in your text.
.SH "Searching and Replacing"
.sp
Searching and replacing is a powerful and quick way of making changes to
your text.  Our sample text is about electronic publishing, but the
correct term is 'desktop' publishing.  To make the necessary changes we
need to replace all occurrences of the word "electronic" with "desktop."
First, move the cursor to the top of the current buffer with the \fBM-<\fP
command.  Then type \fBM-R\fP \fIreplace-string\fP. 
The command line responds:
.sp
.tl ''"Replace []<META>:"''
.sp
where the square brackets enclose the default string.  Type the word
\fBelectronic\fP and hit \fB<META>\fP.  The command line responds:
.sp
.tl ''"with []<META>"''
.sp
type \fBdesktop<META>\fP.  EMACS replaces all instances of the original
word with your revision.  Of course, you will have to capitalize the
first letter of "desktop" where it occurs at the beginning of a
sentence.
.sp
You have just completed an \fBunconditional replace\fP.  In this
operation, EMACS replaces every instance of the found string with the
replacement string. 
.SH "Query-Replace"
.sp
You may also replace text on a case by case basis.  The \fBM-^R\fP
\fIquery-replace-string\fP command causes
EMACS to pause at each instance of the found string. 
.sp
For example, assume we want to replace some instances of the word
"desktop" with the word "personal." Go back to the beginning of the
current buffer and enter the \fBM-^R\fP \fIquery-replace\fP
command.  The procedure is very similar to that
which you followed in the unconditional search/replace option.  When the
search begins however, you will notice that EMACS pauses at each
instance of "publishing" and asks whether you wish to replace it with
the replacement string.  You have a number of options available for
response:
.sp
.TS
center;
lfB lfB
lfB l.
Response	Effect
_
Y(es)	Make the current replacement and skip to the next
	occurrence of the search string
.sp
N(o)	Do not make this replacement but continue
.sp
\&!	Do the rest of the replacements with no more queries
.sp
U(ndo)	Undo just the last replacement and query for it
	again (This can only go back ONE time)
.sp
^G	Abort the replacement command (This action does not
	undo previously-authorized replacements
.sp
\&.	Same effect as ^G, but cursor returns to the point at
	which the replacement command was given
.sp
\&?	This lists help for the query replacement command
.TE
.sp
Practice searching and searching and replacing until you feel
comfortable with the commands and their effects.
.CS
you learned how to search for specified strings of text
in EMACS.  The chapter also dealt with searching for and replacing
elements within a buffer. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Search-Forward	^S	Searches from point to end of buffer.
		Point is moved from current location to
		the end of the found string
.sp
Search-Backward	^R	Searches from point to beginning of buffer.
		Point is moved from current location to
		beginning of found string
.sp
Replace	M-R	Replace ALL ocurrences of search string with 
		specified (null) string from point to the
		end of the current buffer
.sp
Query-Replace	M-^R	As above, but pause at each found string
		and query for action
.TE
.CH "Windows"
.SH "Creating Windows"
.sp
We have already met windows in an earlier chapter.  In this chapter, we
will explore one of EMACS' more powerful features \(em text manipulation
through multiple windowing.  Windows offer you a powerful and easy way
to edit text.  By manipulating a number of windows and buffers on the
screen simultaneously, you can perform complete edits and revisions on
the computer screen while having your draft text or original data
available for reference in another window. 
.sp
You will recall that windows are areas of buffer text that you can see
on the screen.  Because EMACS can support several screen
windows simultaneously you can use them to look into different places in
the same buffer.  You can also use them to look at text in different
buffers.  In effect, you can edit several files at the same time. 
.sp
Let's invoke EMACS and pull back our file on desktop publishing by
typing
.sp
.tl ''emacs publish.txt''
.sp
When the text appears, type the \fB^X-2\fP \fIsplit-window\fP
command.  The window splits into two windows.  The
window where the cursor resides is called the \fBcurrent\fP window \(em in
this case the bottom window.  Notice that each window has a text area
and a mode line.  The \fBcommand line\fP is however,
common to all windows on the screen. 
.sp
The two windows on your screen are virtually mirror images of each other
because the new window is opened into the same buffer as the one you are
in when you issue the \fIopen-window command\fP.  All
commands issued to EMACS are executed on the current buffer in the
current window. 
.sp
To move the cursor to the upper window (i.e., to make that window the
current window, type \fB^X-P\fP \fBprevious-window\fP.  
Notice the cursor
moves to the upper or \fBprevious\fP window.  Entering \fB^X-O\fP
\fInext-window\fP moves to the \fBnext\fP window.  Practice moving between
windows.  You will notice that you can also move into the Function Key
menu by entering these commands. 
.sp
Now move to the upper window.  Let's open a new file.  On the EMACS disk
is a tutorial file.  Let's call it into the upper window by typing:
.sp
.tl ''^X-^F''
.sp
and press return.
.sp
Enter the filename \fBemacs.tut\fP.
.sp
In a short time, the tutorial file will appear in the window.  We now have
two windows on the screen, each looking into different buffers.  We have
just used the \fB^X-^F\fP \fIfind-file\fP
command to find a file and bring
it into our current window.
.sp
You can scroll any window up and down with the cursor keys, or with the
commands we've learned so far.  However, because the area of visible
text in each window is relatively small, you can scroll the current
window a line at a time.  
.sp
Type \fB^X-^N\fP \fImove-window-down\fP.
.sp
The current window scrolls down by one line \(em the top line of text
scrolls out of view, and the bottom line moves towards the top of the
screen.  You can imagine, if you like, the whole window slowly moving
down to the end of the buffer in increments of one line.  The command
\fB^X-^P\fP \fImove-window-up\fP
scrolls the window in the opposite
direction. 
.sp
As we have seen, EMACS editing commands are executed in the current
window, but the program does support a useful feature that allows you to
scroll the \fBnext\fP window.  
\fBM-^Z\fP \fIscroll-next-up\fP
scrolls the next
window up, \fBM-^V\fP \fIscroll-next-down\fP
scrolls it downward.  From the
tutorial window, practice scrolling the window with the desktop
publishing text in it up and down. 
.sp
When you're finished, exit EMACS without saving any changes in your
files. 
.sp
Experiment with splitting the windows on your screen.  Open windows into
different buffers and experiment with any other files you may have.  Try
editing the text in each window, but
don't forget to save any changes you want to keep \(em you still have to
save each buffer separately.
.SH "Deleting Windows"
Windows allow you to perform complex editing tasks with ease.  However,
they become an inconvenience when your screen is cluttered with open
windows you have finished using.  The simplest solution is to delete
unneeded windows.  The command \fB^X-0\fP \fIdelete-window\fP
will delete the window you are currently working in and move you to the
next window.
.sp
If you have a number of windows open, you can delete all but the current
window by entering \fB^X-1\fP \fIdelete-other-windows\fP.
.SH "Resizing Windows"
.sp
During complex editing tasks, you will probably find it convenient to
have a number of windows on the screen simultaneously.  However this
situation may present inconveniences because the more windows you have
on the screen the smaller they are; in some cases, a window may show
only a couple of lines of text.  To increase the flexibility and utility
of the window environment, EMACS allows you to resize the window you are
working in (called, as you will recall, the \fBcurrent\fP window) to a
convenient size for easier editing, and then shrink it when you no
longer need it to be so large. 
.sp
Let's try an example.  Load in any EMACS text file and split the current
window into two.  Now type \fB^X-^(Shift-6)\fP,
\fIgrow-window\fP.  Your current window should be
the lower one on the screen.  Notice that it increases in size upwards
by one line.  If you are in the upper window, it increases in size in a
downward direction.  The command \fB^X-^Z\fP,
\fIshrink-window\fP correspondingly decreases window
size by one line at a time. 
.sp
EMACS also allows you to resize a window more precisely by entering a
numeric argument specifying the size of the window in lines.  To resize
the window this way, press the META key and enter a numeric argument
(remember to keep it smaller than the number of lines on your screen
display) then press \fB^X-W\fP \fIresize-window\fP. 
The current window will be enlarged or shrunk to the number of lines
specified in the numeric argument.  For example entering:
\fBM-8 ^X-W\fP will resize the current window to 8 lines.
.SH "Repositioning within a Window"
.sp
The cursor may be centered within a window by entering \fBM-! or M-^L\fP
\fIredraw-display\fP.  This command is especially
useful in allowing you to quickly locate the cursor if you are moving
frequently from window to window.  You can also use this command to move
the line containing the cursor to any position within the current
window.  This is done by using a numeric argument before the command.
Type \fBM-<n> M-^L\fP where <n> is the number of the line within the
window that you wish the current line to be displayed.
.sp
The \fB^L\fP \fIRefresh-screen\fP command is useful
for 'cleaning up' a 'messy' screen that can result of using EMACS on a
mainframe system and being interrupted by a system message. 
.CS
you learned how to manipulate windows and the
editing flexibility they offer. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Open-Window	^X-2	Splits current window into two windows if
		space is available
.sp
Close-Windows	^X-1	Closes all windows except current window
.sp
Next-Window	^X-O[oh]	Moves point into next (i.e. downward) window
.sp
Previous-Window	^XP	Moves point to previous (i.e. upward) window
.sp
Move-Window-Down	^X-^N	Scrolls current window down one line
.sp
Move-Window-Up	^X-^P	Scrolls current window up one line
.sp
Redraw-display	M ! or	Window is moved so line with point
	M ^L	(with cursor) is at center of window
.sp
Grow-Window	M-X ^ or	Current window is enlarged by one
	M ^L	line and nearest window is shrunk by
		one line
.sp
Shrink-Window	^X-^Z	Current window is shrunk by one line
		and nearest window is enlarged by one line
.sp
Clear-and-redraw	^L	Screen is blanked and redrawn.  Keeps
		screen updates in sync with your commands
.sp
Scroll-Next-Up	M-^Z	Scrolls next window up by one line
.sp
Scroll-Next-Down	M-^V	Scrolls next window down by one line
.sp
Delete-Window	^X-0	Deletes current window
.sp
Delete-Other-Windows	^X-1	Deletes all but current window
.sp
Resize-Window	^X-^W	Resizes window to a given numeric argument
.TE
.CH "Buffers"
.sp
We have already learned a number of things about buffers. 
As you will recall, they are the major internal entities in EMACS \(em the
place where editing commands are executed.  They are characterized by
their \fBnames\fP, their \fBmodes\fP, and by the file with which they are
associated.  Each buffer also "remembers" its \fBmark\fP and \fBpoint\fP. 
This convenient feature allows you to go to other buffers and return to
the original location in the "current" buffer. 
.sp
Advanced users of EMACS frequently have a number of buffers in the
computer's memory simultaneously.  In the last chapter, for example, you
opened at least two buffers \(em one into the text you were editing, and
the other into the EMACS on-line tutorial.  If you deal with complex
text files \(em say, sectioned chapters of a book, you may have five or
six buffers in the computer's memory.  You could select different
buffers by simply calling up the file with \fB^X-^F\fP \fIfind-file\fP,
and let EMACS open or reopen the buffer.  However,
EMACS offers fast and sophisticated buffering techniques that you will
find easy to master and much more convenient to use. 
.sp
Let's begin by opening three buffers.  You can open any three you
choose, for example call the following files into memory: \fBfang.txt\fP,
\fBpublish.txt\fP, and \fBemacs.tut\fP in the order listed here.  When
you've finished this process, you'll be looking at a screen showing the
EMACS tutorial.  Let's assume that you want to move to the fang.txt
buffer.  Enter:
.sp
.tl ''\fB^X-X\fP \fInext-buffer\fP''
.sp
This command moves you to the \fInext\fP buffer.  Because EMACS cycles
through the buffer list, which is alphabetized, you will now be in the
\fBfang.txt\fP buffer. Using \fB^X-X\fP again places you in the
\fBpublish.txt\fP buffer. \fIIf you are on a machine that supports
function keys, using \fP\fB^X-X\fP\fI again places you in the
\fP\fBFunction Keys\fP\fI
buffer\fP. Using \fB^X-X\fP one last time cycles you back to the beginning
of the list.
.sp
If you have a large number of buffers to deal with, this cycling process
may be slow and inconvenient.  The command \fB^X-B\fP \fIselect-buffer\fP
allows you to specify the buffer you wish to be
switched to.  When the command is entered, EMACS prompts, "Use buffer:". 
Simply enter the buffer name (\fBNOT the file name\fP), and that buffer will
then become the current buffer. 
.sp
Multiple buffer manipulation and editing is a complex activity, and you
will probably find it very inconvenient to re-save each buffer as you
modify it.  The command \fB^X-^B\fP \fIlist-buffers\fP
creates a new window that gives details about all the buffers currently
known to EMACS.  Buffers that have been modified are identified by the
\&"buffer changed" indicator (an asterisk in the second column).  You can
thus quickly and easily identify buffers that need to be saved to files
before you exit EMACS.  The buffer window also provides other
information \(em buffer specific modes, buffer size, and buffer name are
also listed.  To close this window, simply type the close-windows
command, \fB^X-1\fP. 
.sp
To delete any buffer, type \fB^X-K\fP \fIdelete-buffer\fP.
EMACS prompts you "Kill buffer:".  Enter the
buffer name you want to delete.  As this is destructive command, EMACS
will ask for confirmation if the buffer was changed and not saved. 
Answer Y(es) or N(o).  As usual \fB^G\fP cancels the command. 
.CS
you learned how to manipulate buffers. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Next-Buffer	^X-^X	Switch to the next buffer in the buffer list
.sp
Select-Buffer	^X-B	Switch to a particular buffer
.sp
List-Buffers	^X-^B	List all buffers
.sp
Delete-Buffer	^X-K	delete a particular buffer if it is off-screen
.TE
.CH "Modes"
.P
EMACS allows you to change the way it works in order to
customized it to the style of editing you are using.  It does this by
providing a number of different \fBmodes\fP.  These modes
can effect either a single buffer, or any new buffer that is created. 
To add a mode to the current buffer, type \fB^X-M\fP \fIadd-mode\fP.
EMACS will then prompt you for the name of a mode to
add.  When you type in a legal mode name, and type a <NL>, EMACS will
add the mode name to the list of current mode names in the modeline of
the current buffer. 
.P
To remove an existing mode, typing the \fB^X-^M\fP \fIdelete-mode\fP
will cause EMACS to prompt you for the name of a
mode to delete from the current buffer.  This will remove that mode from
the mode list on the current modeline.
.P
Global modes are the modes which are inherited by any new
buffers which are created.  For example, if you wish to always do string
searching with character case being significant, you would want global
mode EXACT to be set so that any new files read in inherent the EXACT
mode.  Global modes are set with the \fBM-M\fP \fIadd-global-mode\fP
command, and unset with the \fBM-^M\fP
\fIdelete-global-mode\fP command.  Also, the
current global modes are displayed in the first line of a
\fB^X-^B\fP \fIlist-buffers\fP command.
.P
On machines which are capable of displaying colors,
the mode commands can also set the background and
foreground character colors.  Using \fIadd-mode\fP or \fIdelete-mode\fP with
a lowercase color will set the background color in the current window. 
An uppercase color will set the foreground color in the current window. 
Colors that EMACS knows about are: white, cyan, magenta, yellow, blue,
red, green, and black.  If the computer you are running on does not have
eight colors, EMACS will attempt to make some intelligent guess at what
color to use when you ask for one which is not there. 
.SH "ASAVE mode"
.P
Automatic Save mode tells EMACS to automatically write out the
current buffer to its associated file on a regular basis.  Normally this
will be every 256 characters typed into the file.  The environment
variable $ACOUNT counts down to the next auto-save, and $ASAVE is the
value used to reset $ACOUNT after a save occurs. 
.SH "CMODE mode"
.P
CMODE is useful to C programmers.  When CMODE is active, EMACS
will try to assist the user in a number of ways.  This mode is set
automatically with files that have a .c or .h extension. 
.P
The <NL> key will normally attempt to return the user to the next
line at the same level of indentation as the current line, unless the
current line ends with a open brace ({) in which case the new line will
be further indented by one tab position.
.P
A close brace (}) will delete one tab position preceeding itself
as it is typed.  This should line up the close brace with its matching
IF, FOR or WHILE statement. 
.P
A pound sign (#) with only leading whitespace will delete all
the whitespace preceeding itself. This will always bring preprocessor
directives flush to the left margin.
.P
Whenever any close fence is typed, ie )]>}, if the matching open
fence is on screen in the current window, the cursor will briefly flash
to it, and then back. This makes balancing expressions, and matching
blocks much easier.
.SH "CRYPT mode"
.P
When a buffer is in CRYPT mode, it is
encrypted whenever it is written to a file, and decrypted when it is
read from the file.  The encryption key can be specified on the command
line with the -k switch, or with the \fBM-E\fP \fIset-encryption-key\fP
command.  If you attempt to read or write a
buffer in crypt mode and now key has not been set, EMACS will execute
\fIset-encryption-key\fP automatically, prompting you for the needed key. 
Whenever EMACS prompts you for a key, it will not echo the key to your
screen as you type it (ie make SURE you get it right when you set it
originally).
.P
The encryption algorithm used changes all characters into normal
printing characters, thus the resulting file is suitable for sending via
electronic mail.  All version of MicroEMACS should be able decrypt the
resulting file regardless of what machine encrypted it.  Also available
with EMACS is the stand alone program, MicroCRYPT, which can en/decrypt
the files produced by CRYPT mode in EMACS.
.SH "EXACT mode"
.P
All string searches and replacements will take upper/lower case
into account. Normally the case of a string during a search or replace
is not taken into account.
.SH "MAGIC mode"
.P
In the MAGIC mode certain characters gain special meanings when
used in a search pattern.  Collectively they are know as regular
expressions, and a limited number of them are supported in MicroEMACS. 
They grant greater flexibility when using the search command.  However,
they do not affect the incremental search command. 
.P
The symbols that have special meaning in MAGIC mode are
\&^, $, ., &, *, [ (and ], used with it), and \\.
.P
The characters ^ and $ fix the search pattern to the beginning and
end of line, respectively.  The ^ character must appear at the beginning
of the search string, and the $ must appear at the end, otherwise they
loose their meaning and are treated just like any other character.  For
example, in MAGIC mode, searching for the pattern "t$" would put the
cursor at the end of any line that ended with the letter 't'.  Note that
this is different than searching for "t<NL>", that is, 't' followed by a
newline character.  The character $ (and ^, for that matter) matches a
position, not a character, so the cursor remains at the end of the line. 
But a newline is a character that must be matched, just like any other
character, which means that the cursor is placed just after it \(en on the
beginning of the next line. 
.P
The character .  has a very simple meaning \(em it matches any single
character, except the newline.  Thus a search for "bad.er" could match
\&"badger", "badder" (slang), or up to the 'r' of "bad error". 
.P
The character * is known as closure, and means that zero or more of
the preceding character will match.  If there is no character preceding,
\&* has no special meaning, and since it will not match with a newline, *
will have no special meaning if preceded by the beginning of line symbol
\&^ or the literal newline character <NL>. 
.P
The notion of zero or more characters is important.  If, for
example, your cursor was on the line
.sp
.tl ''\fIThis line is missing two vowels.\fP''
.sp
and a search was made for "a*", the cursor would not move, because it is
guaranteed to match no letter 'a' , which satisfies the search
conditions.  If you wanted to search for one or more of the letter 'a',
you would search for "aa*", which would match the letter a, then zero or
more of them. 
.P
The character [ indicates the beginning of a character class.  It
is similar to the 'any' character ., but you get to choose which
characters you want to match.  The character class is ended with the
character ].  So, while a search for "ba.e" will match "bane", "bade",
"bale", "bate", et cetera, you can limit it to matching "babe" and
"bake" by searching for "ba[bk]e".  Only one of the characters inside
the [ and ] will match a character.  If in fact you want to match any
character except those in the character class, you can put a ^ as the
first character.  It must be the first character of the class, or else
it has no special meaning.  So, a search for [^aeiou] will match any
character except a vowel, but a search for [aeiou^] will match any vowel
or a ^.
.sp
If you have a lot of characters in order that you want to put in the
character class, you may use a dash (-) as a range character.  So, [a-z]
will match any letter (or any lower case letter if EXACT mode is on),
and [0-9a-f] will match any digit or any letter 'a' through 'f', which
happen to be the characters for hexadecimal numbers.  If the dash is at
the beginning or end of a character class, it is taken to be just a
dash. 
.P
The character & (ampersand) is a replacement character, and
represents the characters which matched the search string.  When used in
the \fBM-R\fP \fIreplace-string\fP or the \fBM-^R\fP
\fIquery-replace-string\fP commands, the &
will be substituted for the search string. 
.P
The escape character \\ is for those times when you want to be in
MAGIC mode, but also want to use a regular expression character
to be just a character.  It turns off the special meaning of the
character.  So a search for "it\\." will search for a line with "it.",
and not "it" followed by any other character.  The escape character
will also let you put ^, -, or ] inside a character class with no
special side effects.
.SH "OVER mode"
.P
OVER mode stands for overwrite mode.  When in this mode, when
characters are typed, instead of simply inserting them into the file,
EMACS will attempt to overwrite an existing character past the point. 
This is very useful for adjusting tables and diagrams. 
.SH "WRAP mode"
.P
Wrap mode is used when typing in continuous text.  Whenever the
cursor is past the currently set fill column (72 by
default) and the user types a space or a <NL>, the last word of the line
is brought down to the beginning of the next line.  Using this, one just
types a continuous stream of words and EMACS automatically inserts <NL>s
at appropriate places.
.sp
.tl ''\fINOTE to programmers:\fP''
.QS
EMACS actually calls up the function bound to the illegal
keystroke M-FNW.  This is bound to the function \fP\fBwrap-word\fP\fI
by default, but can be re-bound to activate different
functions and macros at wrap time.
.QE
.SH "VIEW mode"
.P
VIEW mode disables all commands which can change the current
buffer.  EMACS will display an error message and ring the bell every
time you attempt to change a buffer in VIEW mode.
.CS
you learned about modes and their effects.
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Add-Mode	^X-M	Add a mode to the current buffer
.sp
Delete-Mode	^X-^M	Delete a mode from the current buffer
.sp
Add-Global-Mode	M-M	Add a global mode to the
		current buffer
.sp
Delete-Global-Mode	M-^M	Delete a global mode from the
		current buffer
.TE
.CH "Files"
.sp
A file is simply a collection of related data.  In EMACS we are dealing
with text files \(em named collections of text residing on a disk (or some
other storage medium).  You will recall that the major entities EMACS
deals with are buffers.  Disk-based versions of files are only active in
EMACS when you are reading into or writing out of buffers.  As we have
already seen, buffers and physical files are linked by associated
file names.  For example, the buffer "ch7.txt" which is associated with
the physical disk file "ch7.txt." You will notice that the file is
usually specified by the drive name or (in the case of a hard drive) a
path.  Thus you can specify full file names in EMACS,
.sp
.tl ''e.g. disk:\\directories\\filename.extension''
.sp
If you do not specify a disk and directories, the default disk is used.
.sp
IMPORTANT \(em If you do not explicitly save your buffer to a file, all your
edits will be lost when you leave EMACS (although EMACS will prompt you
when you are about to lose edits by exiting).  In addition, EMACS does
not protect your disk-based files from overwriting when it saves files. 
Thus when you instruct EMACS to save a file to disk, it will create a
file if the specified file doesn't exist, or it will overwrite the
previously saved version of the file thus replacing it.  Your old
version is gone forever. 
.sp
If you are at all unsure about your edits, or if (for any reason) you
wish to keep previous versions of a file, you can change the name of the
associated file with the command \fB^X-N\fP.  When this file is saved
to disk, EMACS will create a new physical file under the new name.  The
earlier disk file will be preserved.
.sp
For example, let's load the file \fBfang.txt\fP into EMACS.  Now, type
\fB^X-N\fP.  The EMACS command line prompts "name:".  Enter a new name
for the file \(em say \fBnew.txt\fP and press <NL>.  The file will be
saved under the new filename, and your disk directory will show both
\fBfang.txt\fP and \fBnew.txt\fP.
.sp
An alternative method is to write the file directly to disk under a new
filename.  Let's pull our "publish.txt" file into EMACS.  To write this
file under another filename, type \fB^X-^W\fP.  EMACS will prompt
you "write file:".  Enter an alternate filename \(em \fBdesktop.txt\fP. 
Your file will be saved as the physical file "desktop.txt".
.sp
Note that in the examples above, although you have changed the names of
the related files, the buffer names remain the same.  However, when you
pull the physical file back into EMACS, you will find that the buffer
name now relates to the filename.
.sp
For example \(em You are working with a buffer "fang.txt" with the related
file "fang.txt".  You change the name of the file to "new.txt".  EMACS
now shows you working with the buffer "fang.txt" and the related file
"new.txt".  Now pull the file "new.txt" into EMACS.  Notice that the
buffer name has now changed to "new.txt". 
.sp
If for any reason a conflict of buffer names occurs, (if you have files
of the same name on different drives for example) EMACS will prompt
you "use buffer:".  Enter an alternative buffer name if you need to. 
.sp
For a list of file related commands (including some we've already
seen), see the summary page.
.CS
you learned some of the more advanced
concepts of file naming and manipulation.  The relationship between
files and buffers was discussed in some detail. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Save-file	^X-^S	Saves contents of current buffer with
		associated filename on default disk/
		directory (if not specified)
.sp
Write-File	^X-^W	Current buffer contents will be
		saved under specified name 
.sp
Change-File-name	^X-N	The associated filename is changed
		(or associated if not previously
		specified) as specified
.sp
Find-File	^X-^F	Reads specified file into buffer and
		switches you to that buffer, or switches
		to buffer in which the file has previously
		been read
.sp
Read-File	^X-^R	Reads file into buffer thus overwriting
		buffer contents.  If file has already
		been read into another buffer, you will
		be switched to it
.sp
View-File	^X-^V	The same as read-file except the buffer
		is automatically put into VIEW mode thus
		preventing any changes from being made
.TE
.CH "Screen Formatting"
.SH "Wrapping Text"
.sp
As we learned in the introduction, EMACS is not a word processor, but an
editor.  Some simple formatting options are available however, although
in most cases they will not affect the appearance of the finished text
when it is run through the formatter.  We have
already encountered WRAP mode which wraps lines longer than a certain
length (default is 75 characters).  You will recall that WRAP is enabled
by entering \fB^X-M\fP and responding to the command line prompt with
\fBwrap\fP. 
.sp
You can also set your own wrap margin with the command \fB^X-F\fP
\fIset-fill-column\fP.  Notice EMACS responds
"[Fill column is 1]." Now try typing some text.  You'll notice some very
strange things happening -- your text wraps at every word!! This effect
occurs because the set wrap margin command must be preceeded by a
numeric argument or EMACS sets it to the first column.  Thus any text
you type that extends past the first column will wrap at the most
convenient line break. 
.sp
To reset the wrap column to 72 characters, press the \fB<META>\fP key and
enter 72.  EMACS will respond "Arg: 72".  Now press \fB^X-F\fP.  EMACS
will respond "[Fill column is 72]".  Your text will again wrap at the
margin you've been using up to this point.
.SH "Reformatting Paragraphs"
.sp
After an intensive editing session, you may find that you have
paragraphs containing lines of differing lengths.  Although this
disparity will not affect the formatted text, aesthetic and technical
concerns may make it desirable to have consistent paragraph blocks on
the screen.  If you are in WRAP mode, you can reformat a paragraph with
the command \fBM-Q\fP \fIfill-paragraph\fP.  This
command 'fills' the current paragraph reformatting it so all the lines
are filled and wrap logically.  The process is complex, and (especially
with longer paragraphs) may take a little time. 
.SH "Changing Case"
.sp
There may be occasions when you find it necessary to change the case of
the text you've entered.  EMACS allows you to change the case of even
large amounts of text with ease.  Let's try and convert a few of the
office traditionalists to the joy of word processing.  Type in the
following text:
.QS
Throw away your typewriter and learn to use a word processor. 
Word processing is relatively easy to learn and will increase your
productivity enormously.  Enter the Computer Age and find out just how
much fun it can be!!
.QE
Let's give it a little more impact by capitalizing the first four words. 
The first step is to define the region of text just as you would if you
were doing an extensive deletion.  Set the mark at the beginning of the
paragraph with \fBM-<space>\fP \fIset-mark\fP and move the cursor to the
space beyond "typewriter." Now enter \fB^X-^U\fP \fIcase-region-upper\fP. 
Your text should now look like this:
.QS
THROW AWAY YOUR TYPEWRITER and learn to use a word processor. 
Word processing is relatively easy to learn and will increase your
productivity enormously.  Enter the Computer Age and find out just how
much fun it can be!!
.QE
If you want to change the text back to lower case, type \fB^X-^L\fP
\fIcase-region-lower\fP.  You can also
capitalize individual words.  To capitalize the word "fun", position the
cursor in front of the word and type \fBM-U\fP \fIcase-word-upper\fP.
The word is now capitalized.  To change it
back to lower case, move the cursor back to the beginning of the word
and type \fBM-L\fP \fIcase-word-lower\fP.
.sp
You may also capitalize individual letters in EMACS.  The command
\fBM-C\fP \fIcase-word-capitalize\fP
capitalizes the first letter after the point.  This command would
normally be issued with the cursor positioned in front of the first
letter of the word you wish to capitalize.  If you issue it in the
middle of a word, you can end up with some strAnge looking text. 
.SH "Tabs"
.sp
Unless your formatter is instructed to take screen text literally (as
MicroSCRIBE does in the 'verbatim' environment for example), tabs in
EMACS generally affect screen formatting only. 
.sp
When EMACS is first started, it sets the default tab to every eighth
column.  As long as you stay with default, every time you press the tab
key a tab character, \fB^I\fP is inserted.  This character, like other
control characters, is invisible \(em but it makes a subtle and
significant difference to your file and editing. 
.sp
For example, in default mode, press the tab key and then type the word
\fBTest\fP.  "Test" appears at the eighth column.  Move your cursor to the
beginning of the word and delete the backward character.  The word
doesn't move back just one character, but flushes to the left margin. 
The reason for this behavior is easily explained.  In tab default, EMACS
inserts a 'real' tab character when you press the tab key.  This
character is inserted at the default position, but NO SPACES are
inserted between the tab character and the margin (or previous tab
character).  As you will recall, EMACS only recognizes characters (such
as spaces or letters) and thus when the tab character is removed, the
text beyond the tab is flushed back to the margin or previous tab mark.
.sp
This situation changes if you alter the default configuration.  The
default value may be changed by entering a numeric argument before
pressing the tab key.  As we saw earlier, pressing the \fBMETA\fP key and
entering a number allows you to specify how EMACS performs a given
action.  In this case, let's specify an argument of 10 and hit the tab
key. 
.sp
Now hit the tab key again and type \fBTest\fP.  Notice the word now
appears at the tenth column.  Now move to the beginning of the word and
delete the backward character.	"Test" moves back by one character. 
.sp
EMACS behaves differently in these circumstances because the \fB^I\fP
\fIhandle-tab\fP function deals
with tabbing in two distinct ways.  In default conditions, or if the
numeric argument of zero is used, \fIhandle-tab\fP inserts a true tab
character.  If, however, a non-zero numeric argument is specified,
\fIhandle-tab\fP inserts the correct number of spaces needed to position
the cursor at the next specified tab position.  It does NOT insert the
single tab character and hence any editing functions should take account
of the number of spaces between tabbed columns. 
.sp
Many times you would like to take a line which has been created using
the tab character and change it to use just spaces.  The command
\fB^X-^D\fP \fIdetab-line\fP changes any tabs from the
point to the end of the current line into the right number of spaces so
the line does not change.  This is very useful for times when the file
must be printed or transfered to a machine which does not understand
tabs. 
.sp
Also, the inverse command, \fB^X-^E\fP \fBentab-lines\fP
changes multiple spaces to tabs where possible.  This is a good way to
shrink the size of large documents, especially with data tables.  Both
of these commands can take a numeric argument which will be interpreted
as the number of lines to en/detab. 
.CS
we introduced some of the formatting features of
EMACS. Text-wrap, paragraph reformatting, and tabs were discussed in
some detail.  The commands in the following table were covered in the
chapter. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Add-Mode/WRAP	^X-M[WRAP]	Add wrap mode to current buffer
.sp
Delete-Mode/WRAP	^X-^M[WRAP]	Remove wrap mode from current buffer
.sp
Set-Fill-Column	^X-F	Set fill column to given numeric
		argument
.sp
Fill-Paragraph	M-Q	Logically reformats the current
		paragraph
.sp
Case-Word-Upper	M-U	Text from point to end of the
		current word is changed to uppercase
.sp
Case-Word-Lower	M-L	Text from point to end of the
		current word is changed to lowercase
.sp
Case-Word-Capitalize	M-C	First word (or letter) after the
		point is capitalized
.sp
Case-Region-Upper	^X-^U	The current region is uppercased
.sp
Case-Region-Lower	^X-^L	The current region is lowercased
.sp
Handle-Tab	^I	Tab interval is set to the given
		numeric argument
.sp
Entab-Line	^X-^E	Changes multiple spaces to tabs
		characters where possible
.sp
Detab-Line	^X-^D	Changes tab characters to the
		appropriate number of spaces
.TE
.CH "Access to the Outside World"
.P
EMACS has the ability to interface to other programs and the
environment of the computer outside of itself.  It does this through a
series of commands that allow it to talk to the computer's \fBcommand
processor\fP or \fBshell\fP.  Just
what this is varies between different computers.  Under MSDOS or PCDOS
this is the \fBcommand.com\fP command processor. 
Under UNIX it is the \fBcsh\fP (cshell) shell.  On the Atari ST is
can be the Mark Williams \fBMSH\fP or the Beckmeyer shell.  In each case,
it is the part of the computer's operating system that is responsible
for determining what programs are executed, and when. 
.P
The \fB^X-!\fP \fIshell-command\fP command
prompts the user for a command line to send out to the shell to execute.
This can be very useful for doing file listings and changing the
current directory or folder.  EMACS gives control to the shell, which
executed the command, and then types \fB[END]\fP and waits for the user to
type a character before redrawing the screen and resuming editing. If
the \fIshell-command\fP command is used from within the macro language,
there is no pause.
.P
\fB^X-@\fP \fIpipe-command\fP command allows
EMACS to execute a shell command, and if the particular computer allows
it, send the results into a buffer which is automatically displayed on
the screen. The resulting buffer, called "command" can be manipulated
just like any other editing buffer. Text can be copied out of it or
rearranged as needed. This buffer is originally created in \fBVIEW\fP mode,
so remember to \fB^X-^Mview<NL>\fP in order to change it.
.P
Many computers provide tools which will allow you to \fBfilter\fP
text, making some modifications to it along the way. A
very common tool is the \fBSORT\fP program which accepts a file, sorts it,
and prints the result out.  The EMACS command, \fB^X-#\fP \fIfilter-buffer\fP
sends the current buffer through such a filter.  Therefore, if you
wished to sort the current buffer on a system which supplied a sort
filter, you would type \fB^X-#sort<NL>\fP.  You can also create your own
filters by writing programs and utilities which read text from the
keyboard and display the results.  EMACS will use any of these which
would normally be available from the current shell.
.P
If you would like to execute another program directly, without
the overhead of an intervening shell, you can use the \fB^X-$\fP
\fIexecute-program\fP command. It will prompt you
for an external program and its arguments and attempt to execute it. 
Like when EMACS looks for command files, EMACS will look first in the
HOME directory, then down the execute PATH, and finally in the current
directory for the named program. On some systems, it will automatically
tack the proper extension on the file name to indicate it is a program.
On some systems that don't support this function, \fB^X-$\fP will be
equivalent to \fB^X-!\fP \fIshell-command\fP.
.P
Sometimes, you would like to get back to the shell and execute
other commands, without losing the current contents of EMACS.  The
\fB^X-C\fP \fIi-shell\fP command shells out of EMACS,
leaving EMACS in the computer and executing another command shell.  Most
systems would allow you to return to EMACS with the "exit" command. 
.P
\fIOn some systems, mainly advanced versions of UNIX, you can
direct EMACS to "go into the background" with the \fP\fB^X-D\fP\fI suspend-emacs
command.  This places EMACS in the background
returning you to the original command shell. EMACS can then be returned
to at any time with the "fg" foreground command.\fP
.CS
we introduced different ways to access the
computers shell or command processor from within EMACS.  The commands
in the following table were covered in the chapter. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Execute-program	^X-$	Execute an external program directly
.sp
Filter-command	^X-#	Send the current buffer through
		a shell filter
.sp
I-shell	^X-C	Escape to a new shell
.sp
Pipe-command	^X-@	Send the results of an external
		shell command to a buffer
.sp
Shell-command	^X-!	Execute one shell command
.sp
Suspend-emacs	^X-D	Place EMACS in the background
		(some UNIX systems only)
.TE
.CH "Keyboard Macros"
.sp
In many applications, it may be necessary to repeat a series of
characters or commands frequently.  For example, a paper may require the
frequent repetition of a complex formula or a long name.  You may also
have a series of EMACS commands that you invoke frequently.  Keyboard
macros offer a convenient method of recording and repeating these
commands. 
.sp
Imagine, for example, you are writing a scholarly paper on \fIAsplenium
platyneuron\fP, the spleenwort fern.  Even the dedicated botanist would
probably find it a task bordering on the agonizing to type
\fIAsplenium platyneuron\fP frequently throughout the paper.  An
alternative method is 'record' the name in a keyboard macro.  Try it
yourself.
.sp
The command \fB^X-(\fP \fIbegin-macro\fP starts
recording the all the keystrokes and commands you input.  After you've
typed it, enter \fBAsplenium platyneuron\fP.  To stop recording, type
\fB^X-)\fP \fIend-macro\fP.  EMACS has stored all the
keystrokes between the two commands.  To repeat the name you've stored,
just enter \fB^X-E\fP \fIexecute-macro\fP, and the
name "Asplenium platyneuron" appears.  You can repeat this action as
often as you want, and of course as with any EMACS command, you may
precede it with a numerical argument. 
.sp
Because EMACS records keystrokes, you may freely intermix commands and
text.  Unfortunately, you can only store one macro at a time.  Thus, if
you begin to record another macro, the previously defined macro is
lost. Be careful to ensure that you've finished with one macro before
defining another.  If you have a series of commands that you would like
to 'record' for future use, use the macro or procedure facilities
detailed in chapter 12.
.CS
we covered keyboard macros.  You learned how to
record keystrokes and how to repeat the stored sequence. 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Key Binding	Keystroke	Effect
_
Start-Macro	^X-(	Starts recording all keyboard input
.sp
End-Macro	^X-)	Stops recording keystrokes for macro
.sp
Execute-Macro	^X-E	Entire sequence of recorded
		keystrokes is replayed
.TE
.CH "MicroEMACS Macros"
.P
Macros are programs that are used to customize the editor and to
perform complicated editing tasks.  They may be stored in files or
buffers and may be executed using an appropriate command, or bound to a
particular keystroke.  Portions of the standard start-up file are
implemented via macros, as well as the example menu system.  The
\fIexecute-macro-<n>\fP commands cause the
macro, numbered from 1 to 40, to be executed.  The \fIexecute-file\fP
command allows you to execute a macro stored in a
disk file, and the \fIexecute-buffer\fP command
allows you to execute a macro stored in a buffer.  Macros are stored for
easy execution by executing files that contain the store-macro command. 
.P
If you need more than 40 macros, named macroes, called
\fBprocedures\fP, can be used.  The \fIstore-procedure\fP
command takes a string argument which is the
name of a procedure to store.  These procedures than can be executed
with the \fBM-^E\fP \fIexecute-procedure\fP or the
\fIrun\fP commands. 
.P
There are many different aspects to the macro language within
MicroEMACS.  Editor commands are the various commands that manipulate
text, buffers, windows, etc, within the editor.  Directives are commands
which control what lines get executed within a macro.  Also there are
various types of variables.  Environmental variables both control and
report on different aspects of the editor.  User variables hold string
values which may be changed and inspected.  Buffer variables allow text
to be placed into variables.  Interactive variable allow the program to
prompt the user for information.  Functions can be used to manipulate
all these variables. 
.sp
.SH "Constants"
.P
All constants and variable contents in EMACS are stored as
strings of characters. Numbers are stored digit by digit as characters.
This allows EMACS to be "typeless", not having different variables types
be legal in different contexts. This has the disadvantage of forcing the
user to be more careful about the context of the statements variables
are placed in, but in turn gives them more flexibility in where they
can place variables. Needless to say, this also allows EMACS's expression
evaluator to be both concise and quick.
.P
Wherever statements need to have arguments, it is legal to place
constants.  A constant is a double quote character, followed by a string
of characters, and terminated by another double quote character. To
represent various special characters within a constant, the tilde (~)
character is used. The character following the tilde is interpreted
according to the following table:
.bp
.TS
center;
lfB lfB lfB
l l l.
Sequence	Result
_
\&~n	^J	linefeed/newline,
		(EMACS newline character)
\&~r	^M	carriage return
\&~~	~	tilde character
\&~b	^H	backspace
\&~f	^L	formfeed
\&~t	^I	tab
\&~"	"	double quote character
.TE
.P
Any character not in the table which follows a tilde will be
passed unmodified.  This action is similar to the \fB^Q\fP
\fIquote-character\fP command available from the keyboard. 
.P
The double quotes around constants are not needed if the
constant contains no internal whitespace and it also does not happen to
meet the rules for any other EMACS commands, directives, variables, or
functions. This is reasonable useful for numeric constants.
.SH "Variables"
.P
Variables in MicroEMACS can be used to return values within
expressions, as repeat counts to editing commands, or as text to be
inserted into buffers and messages.  The value of these variables is set
using the set (\fB^X-A\fP) command.  For example, to set the current fill
column to 64 characters, the following macro line would be used:
.sp
.in 2i
set $fillcol 64
.sp
.in -2i
or to have the contents of \fB%name\fP inserted at the point in the
current buffer, the command to use would be:
.sp
.in 2i
insert-string %name
.br
.in -2i
.bp
.SS "Environmental Variables"
.sp
.tl ++\fB"What good is a quote if you can't change it?"\fP++
.P
These variables are used to change different aspects of the way
the editor works.  Also they will return the current settings if used as
part of an expression.  All environmental variable names begin with a
dollar sign ($) and are in lower case.
.sp
.SD \w'$progname\ \ \ 'u
.ND
$acount	The countdown of inserted characters until the next save-file.
.ND
$asave	The number of inserted characters between automatic file-saves
in ASAVE mode. 
.ND
$cbufname	Name of the current buffer
.ND
$cfname	File name of the current buffer
.ND
$cmode	Integer containing the mode of the current buffer. (See Appendix F
for values)
.ND
$curchar	Character currently at the point
.ND
$curcol	Current column of point in current buffer
.ND
$curline	Current line of point in current buffer
.ND
$curwidth	Number of columns used currently
.ND
$cwline	Current display line in current window
.ND
$debug	Flag to trigger macro debugging (try it... you'll like it!)
.ND
$discmd	Flag to disable the echoing of messages on the command line
.ND
$disinp	Flag to disable the echoing of characters during command line input
.ND
$fillcol	Current fill column
.ND
$flicker	Flicker Flag set to TRUE if IBM CGA set to FALSE for most others
.ND
$gflags	Global flags controlling some EMACS internal functions (See
appendix G for details)
.ND
$gmode	Global mode flags. (See Appendix F for values)
.ND
$lastkey	[READ ONLY]Last keyboard character typed
.ND
$line	The current line in the current buffer can be retrieved and
set with this environment variable
.ND
$lwidth	[READ ONLY]Returns the number of characters in the current line
.ND
$match	[READ ONLY]Last string matched in a magic mode search
.ND
$pagelen	Number of screen lines used currently
.ND
$palette	string used to control the palette register settings on
graphics versions.  The usually form consists of groups of three octal
digits setting the red, green, and blue levels. 
.ND
$pending	[READ ONLY]Flag to determine if there are user keystrokes
waiting to be processed.
.ND
$progname	[READ ONLY]Always contains the string "MicroEMACS" for
standard MicroEMACS.  Could be something else if EMACS is incorporated
as part of someone else's program
.ND
$replace	Current default replace string
.ND
$rval	This contains the return value from the last subprocess which was
invoked from EMACS
.ND
$search	Current default search string
.ND
$seed	Integer seed of the random number generator
.ND
$sres	Current screen resolution (CGA, MONO or EGA on the IBM-PC driver. 
LOW, MEDIUM, HIGH or DENSE on the Atari ST1040, NORMAL on all others)
.ND
$status	[READ ONLY]Status of the success of the last command (TRUE or
FALSE).  This is usually used with !force to check on the success of a
search, or a file operation. 
.ND
$target	Current target for line moves (setting this fool's EMACS into
believing the last command was a line move)
.ND
$tpause	Controls the length of the pause to display a matched fence
when the current buffer is in CMODE and a close fence has been typed
.ND
$version	[READ ONLY]Contains the current MicroEMACS version number
.ND
$wline	Number of display lines in current window
.ED
.P
Obviously, many more of these variables will be available in
future releases of MicroEMACS. (Yes, send a vote for your favorite new
environmental variables today).
.SS "User variables"
.P
User variables allow you, the user, to store strings and
manipulate them.  These strings can be pieces of text, numbers (in text
form), or the logical values \fBTRUE\fP and \fBFALSE\fP.  These variables
can be combined, tested, inserted into buffers, and otherwise used to
control the way your macros execute.  At the moment, up to 255 user
variables may be in use in one editing session.  All users variable
names must begin with a percent sign (%) and may contain any printing
characters.  Only the first 10 characters are significant (i.e.
differences beyond the tenth character are ignored).  Most operators
will truncate strings to a length of 128 characters. 
.SS "Buffer Variables"
.P
Buffer variables are special in that they can only be queried
and cannot be set.  What buffer variables are is a way to take text from
a buffer and place it in a variable. For example, if I have a buffer by
the name of RIGEL2, and it contains the text:
.sp
.TS
center;
l l.
Richmond
Lafayette
<*>Bloomington	(where <*> is the current point)
Indianapolis
Gary
.T&
l s.
=* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt =====
.TE
.sp
and within a command I reference #rigel2, like:
.sp
.tl ''insert-string #rigel2''
.P
MicroEMACS would start at the current point in the RIGEL2
buffer and grab all the text up to the end of that line and pass that
back.  Then it would advance the point to the beginning of the next line.
Thus, after our last command executes, the string "Bloomington" gets
inserted into the current buffer, and the buffer RIGEL2 now looks like
this:
.sp
.TS
l l.
Richmond
Lafayette
Bloomington
<*>Indianapolis	(where <*> is the current point)
Gary
.T&
l s.
=* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt =====
.TE
.sp
as you have probably noticed, a buffer variable consists of the
buffer name, preceded by a pound sign (#).
.sp
.SS "Interactive variables"
.P
Interactive variables are actually a method to prompt the user
for a string.  This is done by using an at sign (@) followed either with
a quoted string, or a variable containing a string.  The string is the
placed on the bottom line, and the editor waits for the user to type in
a string.  Then the string typed in by the users is returned as the
value of the interactive variable.  For example:
.sp
.in 1i
.nf
set %quest "What file? "
find-file @%quest
.fi
.in -1i
.sp
will ask the user for a file name, and then attempt to find it.
Note also that complex expressions can be built up with these
operators, such as:
.sp
.in 1i
\&&cat &cat "File to decode[" %default "]: "
.sp
.in -1i
which prompts the user with the concatenated string.
.SH "Functions"
.P
Functions can be used to manipulate variables in various ways. 
Functions can have one, two, or three arguments.  These arguments will
always be placed after the function on the current command line.  For
example, if we wanted to increase the current fill column by two, using
emacs's set (^X-A) command, we would write:
.sp
.nf
.in 1i
.cs R 24
set $fillcol &add $fillcol 2
 \(ua     \(ua      \(ua     \(ua    \(ua____second operand
 |     |      |     |_________first operand
 |     |      |_______________function to execute
 |     |______________________variable to set
 |____________________________set (^X-A) command
.cs R
.in -1i
.fi
.P
Function names always begin with the ampersand (&) character,
and are only significant to the first three characters after the
ampersand.  Functions will normal expect one of three types of
arguments, and will automatically convert types when needed.
.sp
.SD \w'<num>\ \ \ \ \ 'u
.ND
<num>	an ascii string of digits which is interpreted as a numeric value. 
Any string which does not start with a digit or a minus sign (-) will be
considered zero. 
.ND
<str>	An arbitrary string of characters.  At the moment, strings are
limited to 128 characters in length. 
.ND
<log>	A logical value consisting of the string "TRUE" or "FALSE". 
Numeric strings will also evaluate to "FALSE" if they are equal to zero,
and "TRUE" if they are non-zero.  Arbitrary text strings will have the
value of "FALSE". 
.ED
.P
A list of the currently available functions follows: (Once
again, send in those votes on what kind of functions you would like to
see added!) Functions are always used in lower case, the uppercase
letters in the function table are the short form of the function (ie
\&&div for &divide).
.sp
.TS
center;
l s s
lw(1.2i) lw(1.2i) lw(3.4i).
Numeric Functions:  (returns <num>)
_
&ADD	<num> <num>	Add two numbers
&SUB	<num> <num>	Subtract the second number from the first
&TIMes	<num> <num>	Multiply two numbers
&DIVide	<num> <num>	Divide the first number by the second
		giving an integer result
&MOD	<num> <num>	Return the reminder of dividing the
		first number by the second
&NEGate	<neg>	Multiply the arg by -1
&LENgth	<str>	Returns length of string
&SINdex	<str1> <str2>	Finds the position of <str2> within
		<str1>. Returns zero if not found.
&ASCii	<str>	Return the ascii code of the first
		character in <str>
&RND	<num>	Returns a random integer between 1 and <num>
&ABS	<num>	Returns the absolute value of <num>
&BANd	<num> <num>	Bitwise AND function
&BOR	<num> <num>	Bitwise OR function
&BXOr	<num> <num>	Bitwise XOR function
&BNOt	<num>	Bitwise NOT function
.TE
.sp
.TS
center;
l s s
lw(1.2i) lw(1.2i) lw(3.4i).
String manipulation functions:  (returns <str>)
_
&CAT	<str> <str>	Concatenate the two strings to form one
&LEFt	<str> <num>	return the <num> leftmost characters
		from <str>
&RIGht	<str> <num>	return the <num> rightmost characters
		from <str>
&MID	<str> <num1> <num2>
		Starting from <num1> position in <str>,
		return <num2> characters.
&UPPer	<str>	Uppercase <str>
&LOWer	<str>	lowercase <str>
&CHR	<num>	return a string with the character
		represented by ascii code <num>
&GTK		return a string containing a single
		keystroke from the user
&ENV	<str>	If the operating system is capable, this
		returns the environment string associated
		with <str>
&BIND	<str>	return the function name bound to the
		keystroke <str>
&ENV	<str>	Returns the operating system value
		attached to environmental variable <str>
&FINd	<str>	Find the named file <str> along the
		path and return its full file specification
		or an empty string if none exists
.TE
.sp
.TS
center;
l s s
lw(1.2i) lw(1.2i) lw(3.4i).
Logical Testing functions:  (returns <log>)
_
&NOT	<log>	Return the opposite logical value
&AND	<log1> <log2>	Returns TRUE if BOTH logical arguments
		are TRUE
&OR	<log1> <log2>	Returns TRUE if either argument
		is TRUE
&EQUal	<num> <num>	If <num> and <num> are numerically
		equal, return TRUE
&LESs	<num1> <num2>	If <num1> is less than <num2>, return
		TRUE.
&GREater	<num1> <num2>	If <num1> is greater than, or equal to
		<num2>, return TRUE.
&SEQual	<str1> <str2>	If the two strings are the same, return
		TRUE.
&SLEss	<str1> <str2>	If <str1> is less alphabetically than
		<str2>, return TRUE.
&SGReater	<str1> <str2>	If <str1> is alphabetically greater than
		or equal to <str2>, return TRUE.
&FINd	<str>	Does the named file <str> exist?
.TE
.sp
.TS
center;
l s s
lw(1.2i) lw(1.2i) lw(3.4i).
Special Functions:
_
&INDirect	<str>	Evaluate <str> as a variable.
.TE
.ta 1i 2i 3i 4i 5i
.P
This last function deserves more explanation. The &IND function
evaluates its argument, takes the resulting string, and then uses it as
a variable name.  For example, given the following code sequence:
.sp
.nf
	; set up reference table
.sp
	set %one	"elephant"
	set %two	"giraffe"
	set %three	"donkey"
.sp
	set %index "two"
	insert-string &ind %index
.fi
.sp
the string "giraffe" would have been inserted at the point in
the current buffer.  This indirection can be safely nested up to about
10 levels.
.SH "Directives"
.P
Directives are commands which only operate within an executing
macro, ie they do not make sense as a single command. As such, they
cannot be called up singly or bound to keystroke. Used within macros,
they control what lines are executed and in what order.
.P
Directives always start with the exclamation mark (!) character
and must be the first thing placed on a line.  Directives executed
interactively (via the execute-command-line command) will be ignored. 
.SS "!ENDM Directive"
.P
This directive is used to terminate a macro being stored. For
example, if a file is being executed contains the text:
.sp
.nf
	;	Read in a file in view mode, and make the window red
.sp
	26	store-macro
		find-file @"File to view: "
		add-mode "view"
		add-mode "red"
	!endm
.sp
	write-message "[Consult macro has been loaded]"
.fi
.sp
only the lines between the store-macro command and the !ENDM
directive are stored in macro 26.  Both numbered macroes and named
procedures (via the \fIstore-procedure\fP command) should be terminated with
this directive.
.SS "!FORCE Directive"
.P
When MicroEMACS executes a macro, if any command fails, the
macro is terminated at that point. If a line is preceeded by a !FORCE
directive, execution continues weather the command succeeds or not. For
example:
.sp
.nf
	;	Merge the top two windows
.sp
	save-window		;remember what window we are at
	1 next-window		;go to the top window
	delete-window		;merge it with the second window
	!force restore-window	;This will continue regardless
	add-mode "red"
.fi
.SS "!IF, !ELSE, and !ENDIF Directives"
.P
This directive allows statements only to be executed if a
condition specified in the directive is met.  Every line following the
\&!IF directive, until the first !ELSE or !ENDIF directive, is only
executed if the expression following the !IF directive evaluates to a
TRUE value.  For example, the following macro segment creates the
portion of a text file automatically.  (yes believe me, this will be
easier to understand then that last explanation....)
.sp
.nf
	!if &sequal %curplace "timespace vortex"
		insert-string "First, rematerialize~n"
	!endif
	!if &sequal %planet "earth"	;If we have landed on earth...
		!if &sequal %time "late 20th century"  ;and we are then
			write-message "Contact U.N.I.T."
		!else
			insert-string "Investigate the situation....~n"
			insert-string "(SAY 'stay here Sara')~n"
		!endif
	!else
		set %conditions @"Atmosphere conditions outside? "
		!if &sequal %conditions "safe"
			insert-string &cat "Go outside......" "~n"
			insert-string "lock the door~n"
		!else
			insert-string "Dematerialize..try somewhen else"
			newline
		!endif
	!endif
.fi
.SS "!GOTO Directive"
.P
Flow can be controlled within a MicroEMACS macro using the !GOTO
directive. It takes as an argument a label. A label consists of a line
starting with an asterisk (*) and then an alphanumeric label.  Only
labels in the currently executing macro can be jumped to, and trying to
jump to a non-existing label terminates execution of a macro.  For
example..
.sp
.nf
	;Create a block of DATA statements for a BASIC program
.sp
		insert-string "1000 DATA "
		set %linenum 1000
.sp
	*nxtin
		update-screen		;make sure we see the changes
		set %data @"Next number: "
		!if &equal %data 0
			!goto finish
		!endif
.sp
		!if &greater $curcol 60
			2 delete-previous-character
			newline
			set %linenum &add %linenum 10
			insert-string &cat %linenum " DATA "
		!endif
.sp
		insert-string &cat %data ", "
		!goto nxtin
.sp
	*finish
.sp
		2 delete-previous-character
		newline
.fi
.SS "!WHILE and !ENDWHILE Directives"
.P
This directive allows you to set up repetitive tasks easily and
efficiently. If a group of statements need to be executed while a
certain condition is true, enclose them with a while loop. For example,
.sp
.nf
	!while &less $curcol 70
		insert-string &cat &cat "[" #stuff "]"
	!endwhile
.fi
.sp
places items from buffer "item" in the current line until the
cursor is at or past column 70.  While loops may be nested and can
contain and be the targets of !GOTOs with no ill effects. Using a while
loop to enclose a repeated task will run much faster than the
corresponding construct using !IFs.
.SS "!BREAK Directive"
.P
This directive allows the user to abort out of the currently
most inner while loop, regardless of the condition.  It is often used
to abort processing for error conditions.  For example:
.sp
.nf
;	Read in files and substitute "begining" with "beginning"
.sp
	set %filename #list
	!while &not &seq %filename "<end>"
!force		find-file %filename
		!if &seq $status FALSE
			write-message "[File read error]"
			!break
		!endif
		beginning-of-file
		replace-string "begining" "beginning"
		save-file
		set %filename #list
	!endwhile
.fi
.sp
This while loop will process files until the list is exhausted
or there is an error while reading a file.
.SS "!RETURN Directive"
.P
The !RETURN Directive causes the current macro to exit, either
returning to the caller (if any) or to interactive mode.  For example:
.sp
.nf
	;	Check the monitor type and set %mtyp
.sp
	!if &sres "CGA"
		set %mtyp 1
		!return
	!else
		set %mtyp 2
	!endif
.sp
	insert-string "You are on a MONOCHROME machine!~n"
.fi
.AH "Micro EMACS Command Line Switches" "and Startup Files"
.P
When EMACS first executes, it always searches for a file,
called \fB.emacsrc\fP \fIunder most UNIX systems\fP or \fBemacs.rc\fP \fIon
most other systems\fP which it will
execute as EMACS macros before it reads in the named source files. This
file normally contains EMACS macroes to bind the function keys to
useful functions and load various useful macros.  The contents of this
file will probably vary from system to system and can be modified by the
user as desired.
.P
When searching for this file, EMACS looks for it in this order. 
First, it attempts to find a definition for "\fBHOME\fP" in the
environment.  It will look in that directory first.  Then it searches
all the directories listed in the "\fBPATH\fP" environment variable.  Then
it looks through a list of predefined standard directories which vary
from system to system.  Finally, failing all of these, it looks in the
current directory.  This is also the same method EMACS uses to look up
any files to execute, and to find it's help file \fBEMACS.HLP\fP. 
.P
On computers that call up EMACS via a command line process, such
as MSDOS and UNIX, there are different things that can be added to the
command line to control the way EMACS operates. These can be switches,
which are a dash ('-') followed by a letter, and possible other
parameters, or a startup file specifier, which is an at sign '@'
followed by a file name.
.sp
.SD \w'-S<string>\ \ \ \ \ 'u
.ND
@<file>	This causes the named file to be executed instead of the
standard emacs.rc file before emacs reads in any other files.  More than
one of these can be placed on the command line, and they will be
executed in the order that they appear. 
.ND
-A	This flag causes emacs to automatically run the startup file
"error.cmd" instead of emacs.rc. This is used by various C compilers for
error processing (for example, Mark Williams C).
.ND
-E	The following source files on the command line can be edited (as
opposed to being in VIEW mode). This is mainly used to cancel the
effects of the -v switch used previously in the same command line.
.ND
-G<num>	Upon entering EMACS, position the cursor at the <num> line of
the first file.
.ND
-K<key>	This key tells emacs to place the source files in CRYPT
mode and read it in using <key> as the encryption
key.  If no key is listed immediately after the -K switch, EMACS will
prompt for a key, and not echo it as it is typed. 
.ND
-R	This places EMACS in "restricted mode"
where any commands allowing the user to read or write any
files other than the ones listed on the command line are disabled. Also
all commands allowing the user access to the operating system are
disabled. This makes EMACS very useful as a "safe" environment for use
within other applications and especially used as a remote editor for a
BBS or electronic bulletin board system.
.ND
-S<string>	After EMACS is started, it automatically searches for
\&<string> in the first source file.
.ND
-V	This tells EMACS that all the following sources files on the command
line should be in VIEW mode to prevent any changes being made to them.
.ED
.AH "MicroEMACS commands"
.sp
	Below is a complete list of the commands in EMACS, the keys
normally used to do the command, and what the command does.  Remember,
on some computers there may also be additional ways of using a command
(cursor keys and special function keys for example). 
.sp
.TS
center;
lfB lfB lfB
l lfB l.
Command	Binding	Meaning
_
abort-command	 ^G	This allows the user to abort out of any
		command that is waiting for input
.sp
add-mode	^X-M	Add a mode to the current buffer
.sp
add-global-mode	M-M	Add a global mode for all new buffers
.sp
apropos	M-A	List out commands whose name contains
		the string specified
.sp
backward-character	^B	Move one character to the left
.sp
begin-macro	^X-(	Begin recording a keyboard macro
.sp
beginning-of-file	M-<	Move to the beginning of the file in
		the current buffer
.sp
beginning-of-line	^A	Move to the beginning of the current line
.sp
bind-to-key	M-K	Bind a key to a function
.sp
buffer-position	^X-=	List the position of the cursor in the
		current window on the command line
.sp
case-region-lower	^X-^L	Make a marked region all lower case
.sp
case-region-upper	^X-^U	Make a marked region all upper case
.sp
case-word-capitalize	M-C	Capitalize the following word
.sp
case-word-lower	M-L	Lower case the following word
.sp
case-word-upper	M-U	Upper case the following word
.sp
change-file-name	^X-N	Change the name of the file in the
		current buffer
.sp
change-screen-size	M-^S	Change the number of lines of the screen
		currently being used
.sp
change-screen-width	M-^T	Change the number of columns of the
		screen currently being used
.sp
clear-and-redraw	^L	Clear the physical screen and redraw it
.sp
clear-message-line	(none)	Clear the command line
.sp
copy-region	M-W	Copy the currently marked region into
		the kill buffer
.sp
count-words	M-^C	Count how many words, lines and
		characters are in the current marked region
.sp
ctlx-prefix	^X	Change the key used as the ^X prefix
.sp
delete-blank-lines	^X-^O	Delete all blank lines around the cursor
.sp
delete-buffer	^X-K	Delete a buffer which is not being
		currently displayed in a window
.sp
delete-mode	^X-^M	Turn off a mode in the current buffer
.sp
delete-global-mode	M-^M	Turn off a global mode
.sp
delete-next-character	^D	Delete the character following the cursor
.sp
delete-next-word	M-D	Delete the word following the cursor
.sp
delete-other-windows	^X-1	Make the current window cover the entire
		screen
.sp
delete-previous-character	^H	Delete the character to the left of the
		cursor
.sp
delete-previous-word	M-^H	Delete the word to the left of the cursor
.sp
delete-window	^X-0	Remove the current window from the screen
.sp
describe-bindings	(none)	Make a list of all legal commands
.sp
describe-key	^X-?	Describe what command is bound to a
		keystroke sequence
.sp
detab-line	^X-^D	Change all tabs in a line to the
		equivalent spaces
.sp
end-macro	^X-)	stop recording a keyboard macro
.sp
end-of-file	M->	Move cursor to the end of the current buffer
.sp
end-of-line	^E	Move to the end of the current line
.sp
entab-line	^X-^E	Change multiple spaces to tabs where
		possible
.sp
exchange-point-and-mark	^X-^X	Move cursor to the last marked spot,
		make the original position be marked
.sp
execute-buffer	(none)	Execute a buffer as a macro
.sp
execute-command-line	(none)	Execute a line typed on the command
		line as a macro command
.sp
execute-file	FNB	Execute a file as a macro
.sp
execute-macro	^X-E	Execute the keyboard macro (play back
		the recorded keystrokes)
execute-macro-<n>	(none)	Execute numbered macro <N> where <N> is
		an integer from 1 to 40
.sp
execute-named-command	M-X	Execute a command by name
.sp
execute-procedure	M-^E	Execute a procedure by name
.sp
execute-program	^X-$	Execute a program directly (not through
		an intervening shell)
.sp
exit-emacs	^X-^C	Exit EMACS. If there are unwritten,
		changed buffers EMACS will ask to confirm
.sp
fill-paragraph	M-Q	Fill the current paragraph
.sp
filter-buffer	^X-#	Filter the current buffer through an
		external filter
.sp
find-file	^X-^F	Find a file to edit in the current window
.sp
forward-character	^F	Move cursor one character to the right
.sp
goto-line	M-G	Goto a numbered line
.sp
goto-matching-fence	M-^F	Goto the matching fence
.sp
grow-window	^X-^	Make the current window larger
.sp
handle-tab	^I	Insert a tab or set tab stops
.sp
hunt-forward	FN=	Hunt for the next match of the last
		search string
.sp
hunt-backward	FN>	Hunt for the last match of the last
		search string
.sp
help	M-?	Read EMACS.HLP into a buffer and display it
.sp
i-shell	^X-C	Shell up to a new command processor
.sp
incremental-search	^X-S	Search for a string, incrementally
.sp
insert-file	^X-^I	insert a file at the cursor in the
		current file
.sp
insert-space	^C	Insert a space to the right of the cursor
.sp
insert-string	(none)	Insert a string at the cursor
.sp
kill-paragraph	M-^W	Delete the current paragraph
.sp
kill-region	^W	Delete the current marked region, moving
		it to the kill buffer
.sp
kill-to-end-of-line	^K	Delete the rest of the current line
.sp
list-buffers	^X-^B	List all existing buffers
.sp
meta-prefix	<ESC>	Key used to precede all META commands
.sp
move-window-down	^X-^N	Move all the lines in the current window down
.sp
move-window-up	^X-^P	Move all the lines in the current window up
.sp
name-buffer	M-^N	Change the name of the current buffer
.sp
newline 	^M	Insert a <NL> at the cursor
.sp
newline-and-indent	^J	Insert a <NL> at the cursor and indent
		the new line the same as the preceeding line
.sp
next-buffer	^X-X	Bring the next buffer in the list into
		the current window
.sp
next-line	^N	Move the cursor down one line
.sp
next-page	^V	Move the cursor down one page
.sp
next-paragraph	M-N	Move cursor to the next paragraph
.sp
next-window	^X-O	Move cursor to the next window
.sp
next-word	M-F	Move cursor to the beginning of the
		next word
.sp
nop	M-FNC	Does nothing
.sp
open-line	^O	Open a line at the cursor
.sp
overwrite-string	(none)	Overwrite a string at the cursor
.sp
pipe-command	^X-@	Execute an external command and place
		its output in a buffer
.sp
previous-line	^P	Move cursor up one line
.sp
previous-page	^Z	Move cursor up one page
.sp
previous-paragraph	M-P	Move back one paragraph
.sp
previous-window	^X-P	Move the cursor to the last window
.sp
previous-word	M-B	Move the cursor to the beginning of the
		word to the left of the cursor
.sp
query-replace-string	M-^R	Replace all of one string with another
		string, interactively querying the user
.sp
quick-exit	M-Z	Exit EMACS, writing out all changed buffers
.sp
quote-character	^Q	Insert the next character literally
.sp
read-file	^X-^R	Read a file into the current buffer
.sp
redraw-display	M-^L	Redraw the display, centering the
		current line
.sp
resize-window	^X-W	Change the number of lines in the
		current window
.sp
restore-window	(none)	Move cursor to the last saved window
.sp
replace-string	M-R	Replace all occurrences of one string
		with another string from the cursor
		to the end of the buffer
.sp
reverse-incremental-search	^X-R	Search backwards, incrementally
.sp
run	M-^E	Execute a named procedure
.sp
save-file	^X-^S	Save the current buffer if it is changed
.sp
save-window	(none)	Remember current window (to restore later)
.sp
scroll-next-up	M-^Z	Scroll the next window up
.sp
scroll-next-down	M-^V	Scroll the next window down
.sp
search-forward	^S	Search for a string
.sp
search-reverse	^R	Search backwards for a string
.sp
select-buffer	^X-B	Select a buffer to display in the
		current window
.sp
set	^X-A	Set a variable to a value
.sp
set-encryption-key	M-E	Set the encryption key of the current buffer
.sp
set-fill-column	^X-F	Set the current fill column
.sp
set-mark	M-<SPC>	Set the mark
.sp
shell-command	^X-!	Causes an external shell to execute
		a command
.sp
shrink-window	^X-^Z	Make the current window smaller
.sp
split-current-window	^X-2	Split the current window in two
.sp
store-macro	(none)	Store the following macro lines to a
		numbered macro
.sp
store-procedure	(none)	Store the following macro lines to a
		named procedure
.sp
transpose-characters	^T	Transpose the character at the cursor
		with the character to the left
.sp
trim-line	^X-^T	Trim any trailing whitespace from line
.sp
unbind-key	M-^K	Unbind a key from a function
.sp
universal-argument	^U	Execute the following command 4 times
.sp
unmark-buffer	M-~	Unmark the current buffer (so it is
		no longer changed)
.sp
update-screen	(none)	Force a screen update during macro execution
.sp
view-file	^X-^V	Find a file,and put it in view mode
.sp
wrap-word	M-FNW	Wrap the current word, this is an
		internal function
.sp
write-file	^X-^W	Write the current buffer under a new
		file name
.sp
write-message	(none)	Display a string on the command line
.sp
yank	^Y	yank the kill buffer into the current
		buffer at the cursor
.TE
.AH "MicroEMACS Bindings"
.P
Below is a complete list of the key bindings used in MicroEMACS.
This can be used as a wall chart reference for MicroEMACS commands.
.sp
.TS
center expand;
cfB s s s
lfB l5 lfB l.
Default Key Bindings for MicroEMACS 3.9e
.sp
^A	Move to start of line	ESC A	Apropos (list some commands)
^B	Move backward by characters	ESC B	Backup by words
^C	Insert space	ESC C	Initial capitalize word
^D	Forward delete	ESC D	Delete forward word
^E	Goto end of line	ESC E	Reset Encryption Key
^F	Move forward by characters	ESC F	Advance by words
^G	Abort out of things	ESC G	Go to a line
^H	Backward delete
^I	Insert tab/Set tab stops
^J	Insert <NL>, then indent
^K	Kill forward	ESC K	Bind Key to function
^L	Refresh the screen	ESC L	Lower case word
^M	Insert <NL>	ESC M	Add global mode
^N	Move forward by lines	ESC N	Goto End paragraph
^O	Open up a blank line
^P	Move backward by lines	ESC P	Goto Beginning of paragraph
^Q	Insert literal	ESC Q	Fill current paragraph
^R	Search backwards	ESC R	Search and replace
^S	Search forward
^T	Transpose characters
^U	Repeat command four times	ESC U	Upper case word
^V	Move forward by pages	ESC V	Move backward by pages
^W	Kill region	ESC W	Copy region to kill buffer
^Y	Yank back from killbuffer	ESC X	Execute named command
^Z	Move backward by pages	ESC Z	Save all buffers and exit
.sp
ESC ^C	Count words in region	ESC ~	Unmark current buffer
ESC ^E	Execute named procedure
ESC ^F	Goto matching fence	ESC !	Reposition window
ESC ^H	Delete backward word	ESC <	Move to start of buffer
ESC ^K	Unbind Key from function	ESC >	Move to end of buffer
ESC ^L	Reposition window	ESC .	Set mark
ESC ^M	Delete global mode	ESC <SPC>	Set mark
ESC ^N	Rename current buffer	ESC <RUB>	Delete backward word
ESC ^R	Search & replace w/query	<RUB>	Backward delete
ESC ^S	Change screen rows
ESC ^T	Change screen columns
ESC ^V	Scroll next window down
ESC ^W	Delete Paragraph
ESC ^Z	Scroll next window up
.sp
^X ?	Describe a key	^X !	Run 1 command in a shell
^X =	Show the cursor position	^X @	Pipe shell command to buffer
^X ^	Enlarge display window	^X #	Filter buffer thru shell filter
^X 0	Delete current window	^X $	Execute an external program
^X 1	Delete other windows	^X (	Begin macro
^X 2	Split current window	^X )	End macro
		^X A	Set variable value
^X ^B	Display buffer list	^X B	Switch a window to a buffer
^X ^C	Exit MicroEMACS	^X C	Start a new command processor
^X ^D	Detab line	^X D	Suspend MicroEMACS (BSD4.2 only)
^X ^E	Entab line	^X E	Execute macro
^X ^F	Find file	^X F	Set fill column
^X ^I	Insert file
		^X K	Delete buffer
^X ^L	Lower case region
^X ^M	Delete Mode	^X M	Add a mode
^X ^N	Move window down	^X N	Rename current filename
^X ^O	Delete blank lines	^X O	Move to the next window
^X ^P	Move window up 	^X P	Move to the previous window
^X ^R	Get a file from disk	^X R	Incremental reverse search
^X ^S	Save current file	^X S	Incremental forward search
^X ^T	Trim line		(Incremental search
^X ^U	Upper case region		not always available)
^X ^V	View file
^X ^W	Write a file to disk	^X W	resize Window
^X ^X	Swap "." and mark	^X X	Use next buffer
^X ^Z	Shrink window	^X Z	Enlarge display window
.TE
.sp
.TS
center expand;
l s
l l.
Usable Modes
_
WRAP	Lines going past right margin "wrap" to a new line
VIEW	Read-Only mode where no modifications are allowed
CMODE	Change behavior of some commands to work better with C
EXACT	Exact case matching on search strings
OVER	Overwrite typed characters instead of inserting them
CRYPT	Current buffer will be encrypted on write, decrypted on read
MAGIC	Use regular expression matching in searches
ASAVE	Save the file every 256 inserted characters
.TE
.sp
.TS
center expand;
l l.
WHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK	Sets foreground color
white/cyan/magenta/yellow/blue/red/green/black	Sets background color
.TE
.AH "Supported machines"
.P
The following table lists all the hardware/compilers for which I
currently support MicroEMACS.  This is not exclusive of all machines
which MicroEMACS will run on, but I have either run it myself, or had a
first hand report of it running.
.sp
.TS
center expand;
lfB lfB lfB lfB
l l l l.
Hardware	OS	Compiler	Comments
_
VAX 780	UNIX V5	native
	UNIX V7	native
	BSD 4.2	native	job control supported
	*VMS	native	only some terminals supported
.sp
NCR Tower	UNIX V5	native
.sp
Fortune 32:16	UNIX V7	native
.sp
IBM-PC	MSDOS	LATTICE 2.15	Large CODE/Large DATA
	2.0 & 3.2	AZTEC 3.4e	Small CODE/Large DATA
		TURBO C v1.00	LARGE memory model
		*MSC 4.0
		*MWC 86
	SCO XENIX	native
.sp
HP150	MSDOS	Lattice 2.15	Function key labels
			for the touch screen
HP110	MSDOS	Lattice 2.15
		Aztec 3.4e
.sp
*Data General 10	MSDOS	Lattice 2.15
.sp
*TI Professional	MSDOS	Lattice 2.15
.sp
Amiga	Intuition	Lattice 3.03	no mouse or menus yet
		*Aztec 3
.sp
ST520	TOS	Mark Williams C	Spawns under MSH
		Lattice 3.10	(no shell commands)
.sp
.T&
l s s s
l l l l.
Systems to be supported (i.e. some code is already written):
Macintosh	Finder 5.0	Aztec
.TE
.sp
*means that I do not own or have access to the listed compiler and/or
 machine and must rely upon others to help support it.
.AH "Machine Dependent Notes"
.P
This appendix lists some notes specific to individual
implementations of MicroEMACS.  Every attempt has been made to allow
EMACS to be identical on all machines, but we have also tried to take
advantage of function keys, cursor keys, mice, and special screen modes
where possible.
.AS "IBM-PC/XT/AT and its clones"
.P
The IBM-PC family of computers is supported with a variety of
different display adapters.  EMACS will attempt to discover what adapter
is connected and use the proper driver for it.  Below is a list of the
currently supported video adapters:
.sp
.TS
center expand;
lfB lfB lfB
l l l.
Adapter	$sres	Original mode used
_
Monochrome Graphics Adapter	MONO	MONO
Color Graphics Adapter	CGA	CGA
Enhanced Graphics Adapter	EGA	CGA
.TE
.P
EMACS also takes advantage of various function keys and the keys
on the keypad on an IBM-PC.  The function keys are initially not bound
to any particular functions (except by the emacs.rc startup file), but
the keypad keys do default to the following:
.sp
.TS
center;
lfB lfB
l l.
Keypad key	Function
_
Home	beginning-of-file
CSRS UP	previous-line
Pg Up	previous-page
CSRS LEFT	backward-character
CSRS RIGHT	forward-character
End	end-of-file
CSRS DOWN	next-line
Pg Dn	Next-page
.TE
.P
All these special keys are indicated in EMACS macroes by use of
the \fBFN\fP prefix.  Below is a list of many of the keys and the codes
used to specify them.  Also the codes may be gotten by using the
describe-key (^X ?) command on the suspect key.
.bp
.sp 1i
.TS
center;
cfB s s s s
lfB cfB cfB cfB cfB
l c c c c.
IBM PC function keys in MicroEMACS
.sp
	function	Function	^function	Alt-function
_
f1)	FN;	FNT	FN^	FNh
f2)	FN<	FNU	FN_	FNi
f3)	FN=	FNV	FN`	FNj
f4)	FN>	FNW	FNa	FNk
f5)	FN?	FNX	FNb	FNl
f6)	FN@	FNY	FNc	FNm
f7)	FNA	FNZ	FNd	FNn
f8)	FNB	FN[	FNe	FNo
f9)	FNC	FN\	FNf	FNp
f10)	FND	FN]	FNg	FNq
.sp
home)	FNG		FNw
CsUp)	FNH
PgUp)	FNI		FNa(umlaut)	{Alt 132}
CsLf)	FNK		FNs
5)
CsRt)	FNM		FNt
End)	FNO		FNu
CsDn)	FNP
PgDn)	FNQ		FNv
Ins)	FNR
Del)	FNS
.TE
.AS "HP 150"
.P
This machine from Hewlett Packard is very unusual for an MSDOS
machine.  It has a touch screen and is very function key oriented.  An
additional command, \fIlabel-function-key\fP
allows you to place labels on the on screen function key labels.  A
numeric argument indicates which function key to label (one through
eight) and then the program prompts for a 16 character label, which will
be used as two lines of eight characters.  To label function key three
with "save file" from a macro, you would use:
.sp
.nf
	3 label-function-key "save    file"
.fi
.sp
Notice the 4 spaces after "save".  This forces "file" to begin on
the second line of the label.
.AS "Atari 520/1040ST"
.P
The ATARI ST family of computers have a dual personality.  They
may use either a monochrome or a color screen.  EMACS supports two
screen resolutions on each monitor.
.sp
.TS
center expand;
lfB lfB lfB lfB lfB
l l l l l.
Monitor	$sres	size	#color	$palette format
_
Color	LOW	40x25	16	000111222333444555666777
	MEDIUM	80x25	4	000111222333
Mono	HIGH	80x25	2	000
	DENSE	80x50	2	000
.TE
.sp
The $palette environment variable can be used to change what
color is associated with each color name.  With a color monitor, each
group of three digits indicates an octal number specifying the RED,
GREEN and BLUE levels of that color.  Each color digit can vary from 0
to 7.  For example, the initial setting of $palette in LOW resolution is:
.ta 9n 17n 25n 33n 41n 49n
.sp
.nf
	000700070770007707077777
.fi
.sp
which broken up is:
.sp
.nf
	000 700 070 770 007 707 077 777
.fi
.sp
which means:
.sp
.TS
center;
l l.
000	Black
700	Red
070	Green
770	Yellow
007	Blue
707	Magenta
077	Cyan
777	White
.TE
.P
Also the mouse generates FN prefix codes when moved, or when one
of the two buttons is pressed.  Initially the movement of the mouse is
bound to movement of the cursor, and the left mouse button generates a
set-mark (M-space) command.  The cursor keys and the function keys are
bound similarly to to IBM-PC.
.P
Files generated by EMACS on the ATARI ST have a single return
character at the end of each line, unlike the desktop files which want
to have two returns. This makes it display files strangely from GEM's
\&[SHOW] option, but makes the files port to other computers much nicer.
.P
Currently, when operating under the Mark Williams MSH program,
EMACS can shell out and perform external commands. This capability will
be added later for the Beckmeyer shell and under GEMDOS.
.AS "Amiga 1000"
.P
The Commodore AMIGA 1000 version of MicroEMACS does not have
extensive support of the mouse or of pull down menus as of yet.  It does
however come up in a window, and it is possible to re-size it to run in
different sized windows.  The \fBM-^S\fP \fIchange-screen-size\fP
takes its numeric argument as the new number
of lines for EMACS to use.  The \fBM-^T\fP \fIchange-screen-width\fP
command allows you to change the number of
columns EMACS will use.  The defaults for these are 23 lines and 77
characters across for a full screen window.
.sp
.tl ''\fINote about Compiling MicroEMACS\fP''
.sp
.QS
If you are compiling the sources on the AMIGA to produce an
executable image, and you are using the Lattice compiler, be sure to
give the CLI command 'STACK 40000' before compiling to make sure the
compiler has sufficient stack space to successfully complete
compilation.
.QE
.AS "UNIX V5, V7, and BSD4.[23]"
.P
MicroEMACS under UNIX utilizes the \fBTERMCAP\fP
library to provide machine independent screen functions.  Make sure that
your TERM variable is properly set on your account before attempting
to use MicroEMACS.
.P
Under systems which support job control, you can use the
\fB^X-D\fP \fIsuspend-emacs\fP command to place EMACS
into the background.  This carries a much smaller overhead than bringing
up a new shell under EMACS.  EMACS will properly redraw the screen when
you bring it back to the foreground.
.P
If the symbol VT100 has been set to 1 in the \fIestruct.h\fP
options file, EMACS will recognize the key sequence <ESC>[ as the lead
in sequence for the FN function key prefix.
.P
With the addition of some very machine/operating system specific
code, EMACS can prevent two or more people from modifying the same file
at the same time.  The upper level of a set of
functions to provide file locking exist in the source file \fBLOCK.C\fP.
It requires two machine specific functions written and linked into EMACS
for it to operate properly.
.sp
.in 1i
.nf
char *dolock(fname)
.sp
char *fname;
.sp
dolock() locks a file, preventing others from modifying it. If
it succeeds, it returns NULL, otherwise it returns a pointer to
a string in the form "LOCK ERROR: explanation".
.sp
char *undolock(fname)
.sp
char *fname;
.sp
undolock() unlocks a file, allowing others to modifying it. If
it succeeds, it returns NULL, otherwise it returns a pointer to
a string in the form "LOCK ERROR: explanation".
.fi
.in -1i
.AH "Mode Flags"
.P
The two environment variables, $cmode and $gmode, contain a
number the corresponds to the modes set for the current buffer and
the editor as a whole.  These are encoded as the sum of the following
numbers for each of the possible modes:
.sp
.TS
center expand;
l r l.
WRAP	1	Word wrap
CMODE	2	C indentation and fence match
SPELL	4	Interactive spell checking (Not Implemented Yet)
EXACT	8	Exact matching for searches
VIEW	16	Read-only buffer
OVER	32	Overwrite mode
MAGIC	64	Regular expressions in search
CRYPT	128	Encryption mode active
ASAVE	256	Auto-save mode
.TE
.P
So, if you wished to set the current buffer to have CMODE,
EXACT, and MAGIC on, and all the others off, you would add up the values
for those three, CMODE 2  +  EXACT 8  +  MAGIC 64 = 74, and use a
statement like:
.sp
	set $cmode 74
.sp
or, use the binary or operator to combine the different modes:
.sp
	set $cmode &bor &bor 2 8 64
.sp
.BG "Internal Flags"
.P
Some of the ways EMACS controls its internal functions can be
modified by the value in the $gflags environment variable.  Each bit in
this variable will be used to control a different function.
.sp
.TS
center expand;
l r l.
GFFLAG	1	If this bit is set to zero, EMACS will not
		automatically switch to the buffer of the
		first file after executing the startup macros.
.TE
