Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!clyde!burl!codas!usfvax2!jc3b21!larry
From: larry@jc3b21.UUCP (Lawrence F. Strickland)
Newsgroups: comp.emacs
Subject: uemacs troff manual
Message-ID: <211@jc3b21.UUCP>
Date: Sat, 5-Dec-87 10:14:25 EST
Article-I.D.: jc3b21.211
Posted: Sat Dec 5 10:14:25 1987
Date-Received: Thu, 10-Dec-87 20:55:44 EST
Organization: St. Petersburg Jr. College, FL
Lines: 1047
Keywords: Part 1 of 3
# Due to numerous requests, more than 20 actually, it seemed like a good
# idea to post this rather than send by email. Anyway, this is part 1 of
# 3 of a troff'able (and nroff'able) uemacs 3.9e manual. It should be
# complete EXCEPT for table of contents and index (sorry). It uses its own
# internal macros, so won't require -ms -mm, -me, or -m? at all.
#
# Each part is a shar file. Unshar to get the files emacstroff01,
# emacstroff02, emacstroff03, then combine them together with cat:
# $ cat emacstroff0[123] >emacs.t (or whatever you want to call it)
#
# The result may now be fed through tbl and then to ?roff. I've tested this
# using eroff on a 3b2/300 with an HP LaserJet II printer. There is nothing
# unusual in it, so it should run everywhere. If you have troubles, send them
# to: ...gatech!codas!usfvax2!jc3b21!larry (and hope for good mailing
# conditions!) Have fun...
#
# P.S. I'm posting to comp.emacs because it seems like such a restricted file
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by larry on Fri Dec 4 18:38:06 EST 1987
# Contents: emacstroff01
echo x - emacstroff01
sed 's/^@//' > "emacstroff01" <<'@//E*O*F emacstroff01//'
@.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
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 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 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 or
key (we will refer to this key as 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 . 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 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
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 a couple of times to tab
down from the text you just entered. Now type the following paragraphs.
Press 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-\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-\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 [] :"''
@.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 key to start the search. If you
simply press the command line responds with "".
Although this may seem infuriating to users who are used to pressing the
return key to execute any command, EMACS' use of to begin
searches allows it to pinpoint text with great accuracy. After every
line wrap or carriage return, EMACS 'sees' a new line character ().
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\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\fP. The command
line now shows:
@.sp
@.tl ''"search [and]:"''
@.sp
Press \fB\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 []:"''
@.sp
where the square brackets enclose the default string. Type the word
\fBelectronic\fP and hit \fB\fP. The command line responds:
@.sp
@.tl ''"with []"''
@.sp
type \fBdesktop\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
@//E*O*F emacstroff01//
chmod u=rw,g=r,o=r emacstroff01
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
1000 6510 39045 emacstroff01
!!!
wc emacstroff01 | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0
--
+--------------------------------------+-- St. Petersburg Junior College --+
| Lawrence F. Strickland | P.O. Box 13489 |
| ...gatech!codas!usfvax2!jc3b21!larry | St. Petersburg, FL 33733 |
+-(or) ...gatech!usfvax2!jc3b21!larry -+-- Phone: +1 813 341 4705 ---------+