Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!rutgers!clyde!burl!codas!usfvax2!jc3b21!larry
From: larry@jc3b21.UUCP (Lawrence F. Strickland)
Newsgroups: comp.emacs
Subject: uemacs troff manual
Message-ID: <212@jc3b21.UUCP>
Date: Sat, 5-Dec-87 10:16:09 EST
Article-I.D.: jc3b21.212
Posted: Sat Dec 5 10:16:09 1987
Date-Received: Thu, 10-Dec-87 20:58:15 EST
Organization: St. Petersburg Jr. College, FL
Lines: 1031
Keywords: part 2 of 3
# This is part 2 of the 3. See part 1 for instructions
# 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:23 EST 1987
# Contents: emacstroff02
echo x - emacstroff02
sed 's/^@//' > "emacstroff02" <<'@//E*O*F emacstroff02//'
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- M-^L\fP where 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 , 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 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", 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 .
@.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 , 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 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 . 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\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-\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\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\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-\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.
@//E*O*F emacstroff02//
chmod u=rw,g=r,o=r emacstroff02
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 7302 43834 emacstroff02
!!!
wc emacstroff02 | 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 ---------+