nwd@j.cc.purdue.edu (Daniel Lawrence) (11/26/87)
[Sorry for the hiatus. A short trip out of state turned out to be longer than I expected; ``the best-laid plans,'' and so on. This shar archive arrived in pieces; you must save the messages, chop off headers and trailers, concatenate, THEN unshar. Somewhat bogus, by my reckoning.... ++bsa] # This is a shar archive. # Remove everything above this line. # Run the file through sh, not csh. # (type `sh this_file') # If you do not see the message # `this_file completed!' # then the file was incomplete. echo extracting - emacs.mss sed 's/^X//' > emacs.mss << 'FRIDAY_NIGHT' X@style(indent 8 chars, spacing 1 lines) X@pagefooting() X X X X X X X X X X X X X @big(MicroEMACS) X X Full Screen Text Editor X Reference Manual (preliminary draft) X X Version 3.9e X November 4, 1987 X X (C)opyright 1987 by Daniel M. Lawrence X Reference Manual (C)opyright 1987 X by Brian Straight and Daniel M. Lawrence X All Rights Reserved X X @i(MicroEMACS 3.9e can be copied and distributed freely X for any non-commercial purposes. MicroEMACS 3.9e can X only be incorporated into commercial software with X the permission of the current author.) X@newpage X@newpage X@flushleft(@big[Introduction]) X X MicroEMACS is a tool for creating and changing documents, Xprograms, and other text files. It is both relatively easy for the Xnovice to use, but also very powerful in the hands of an expert. XMicroEMACS can be extensively customized for the needs of the Xindividual user. X X MicroEMACS allows several files to be edited at the same time. XThe screen can be split into different windows, and text may be moved Xfreely from one window to the next. Depending on the type of file being Xedited, MicroEMACS can change how it behaves to make editing simple. XEditing standard text files, program files and word processing documents Xare all possible at the same time. X X There are extensive capabilities to make word processing and Xediting easier. These include commands for string searching and Xreplacing, paragraph reformatting and deleting, automatic word wrapping, Xword move and deletes, easy case controlling, and automatic word counts. X X For complex and repetitive editing tasks editing macroes can be Xwritten. These macroes allow the user a great degree of flexibility in Xdetermining how MicroEMACS behaves. Also, any and all the commands can Xbe used by any keystroke by changing, or rebinding, what commands Xvarious keys are connected, or bound, to. X X Special features are also available to perform a diverse set of Xoperations such as file encryption, automatic backup file generation, Xentabbing and detabbing lines, executing of DOS commands and filtering Xof text through other programs (like SORT to allow sorting text). X X@flushleft(@big[History]) X X EMACS was originally a text editor written by Richard Stahlman Xat MIT in the early 1970s for Digital Equipment computers. Various Xversions, rewrites and clones have made an appearence since. X X This version of MicroEMACS is derived from code written by Dave XG. Conroy in 1985. Later modifications were performed by Steve Wilhite Xand George Jones. In December of 1985 Daniel Lawrence picked up the Xthen current source (version 2.0) and made extensive modifications and Xadditions to it over the course of the next two years. Updates and Xsupport for the current version are still availible. The current Xprogram author can be contacted by writing to: X X@begin(verbatim) X USMAIL: Daniel Lawrence X 617 New York St X Lafayette, IN 47901 X X UUCP: ihnp4!pur-ee!pur-phy!duncan!lawrence X ARPA: nwd@@j.cc.purdue.edu X FIDO: Fido 201/2 The Programmer's Room (317) 742-5533 X@end(verbatim) X@string(ChapterTitle="") X@set(page = 0) X@pageheading(odd, left "@title[Chapter]", right "MicroEMACS Reference Manual") X@pageheading(even, left "MicroEMACS Reference Manual", right "@title[Chapter]") X@pagefooting(odd, left="@value(page)") X@pagefooting(even, right="@value(page)") X@chapter(Basic Concepts) X X The current version of MicroEMACS is 3.9e (Third major re-write, Xninth public release, fifth minor edit), and for the rest of this Xdocument, we shall simply refer to this version as "EMACS". Any Xmodifications for later versions will be listed in the appendixes at the Xend of this manual. X X@section(Keys and the Keyboard) X X Many times throughout this manual we will be talking about X@index(special keys) commands and the keys on the keyboard needed to use Xthem. There are a number of "special" keys which can be used and are Xlisted here: X X@begin(description) X<NL>@\NewLine which is also called RETURN or ENTER, this key is used to X@index(newline) end different commands. X X^@\The control key can be used before any alphabetic character and some Xsymbols. For example, ^C means to hold down the <CONTROL> key and type X@index(control key) the C key at the same time. X X^X@\The CONTROL-X key is used at the beginning of many different X@index(control-x) commands. X XMETA or M-@\This is a special EMACS key used to begin many commands as X@index(meta key) well. This key is pressed and then released before Xtyping the next character. On most systems, this is the <ESC> key, but Xit can be changed. (consult appendix E to learn what key is used for XMETA on your computer). X@end(description) X XWhenever a command is described, the manual will list the actual Xkeystrokes needed to execute it in @b(boldface) using the above Xconventions, and also the name of the command in @i(italics). X@section(Getting Started) X X In order to use EMACS, you must call it up from your system or Xcomputer's command prompt. On UNIX and MSDOS machines, just type X"emacs" from the main command prompt and follow it with the <RETURN> or X<ENTER> key (we will refer to this key as <NL> for "new-line" for the Xremainder of this manual). On the Macintosh, the Amiga, the ATARI ST Xand other icon based operating systems, double click on the uEMACS icon. XShortly after this, a screen similar to the one below should appear. X X@section(Parts and Pieces) X X The screen is divided into a number of areas or @b<windows>. On Xsome systems the top window contains a function list of unshifted and X@index(windows) shifted function keys. We will discuss these keys later. X@index(mode line) Below them is an EMACS @b<mode line> which, as we will Xsee, informs you of the present mode of operation of the editor--for Xexample "(WRAP)" if you set EMACS to wrap at the end of each line. X@index(text window) Under the mode line is the @b<text window> where text Xappears and is manipulated. Since each window has its own mode line, Xbelow the text window is it's mode line. The last line of the screen is Xthe @b(command line) where EMACS takes commands and reports on what it Xis doing. X X@begin(verbatim) X=============================================================================== Xf1 search-> f2 <-search | MicroEMACS: Text Editor Xf3 hunt-> f4 <-hunt | Xf5 fkeys f6 help | Available function key Pages include: Xf7 nxt wind f8 pg[ ] | WORD PROG BOX Xf9 save f10 exit | [use the f8 key to load Pages] X=============================================================================== X-- MicroEMACS 3.9e () -- Function Keys --------------------------------------- X=============================================================================== X X X X X X X X X X X X X=============================================================================== X-- MicroEMACS 3.9e () -- Main ------------------------------------------------ X=============================================================================== X Fig 1: EMACS screen on an IBM-PC X@end(verbatim) X X@section(Entering Text) X XEntering text in EMACS is simple. Type the following sentence fragment: X X@quotation<Fang Rock lighthouse, center of a series of mysterious and> X X@flushleft(The text is displayed at the top of the text window. Now type:) X X@quotation<terrifying events at the turn of the century> X XNotice the text to the left of the cursor disappears and a '$' sign Xappears. Don't panic--your text is safe!!! You've just discovered that XEMACS doesn't "wrap" text to the next line like most word processors Xunless you hit <NL>. But since EMACS is used for both word processing, Xand text editing, it has a bit of a dual personality. You can change X@index(modes) the way it works by setting various @b(modes). In this Xcase, you need to set @b(WRAP) mode, using the @i(add-mode) X@index(add-mode) command, by typing @b(^X-M). The command line at the Xbase of the screen will prompt you for the mode you wish to add. Type X@b<wrap> followed by the <NL> key and any text you now enter will be Xwrapped. However, the command doesn't wrap text already entered. To Xget rid of the truncated line, delete characters with the <BACKSPACE> Xkey until the '$' goes away. Now type in the words you deleted, watch Xhow EMACS goes down to the next line at the right time. @i{(In some Xversions of EMACS, @b<WRAP> is a default mode in which case you don't Xhave to worry about the instructions relating to adding this mode.)} X XNow let's type a longer insert. Hit <NL> a couple of times to tab Xdown from the text you just entered. Now type the following paragraphs. XPress <NL> twice to indicate a paragraph break. X X@quotation<Fang Rock lighthouse, center of a series of mysterious and Xterrifying events at the turn of the century, is built on a rocky island Xa few miles of the Channel coast. So small is the island that wherever Xyou stand its rocks are wet with sea spray. X XThe lighthouse tower is in the center of the island. A steep flight of Xsteps leads to the heavy door in its base. Winding stairs lead up to Xthe crew room.> X X@section<Basic cursor movement> X XNow let's practice moving around in this text. To move the cursor back Xto the word "Winding," enter @b<M-B> @i(previous-word) X@index(previous-word). This command moves the cursor backwards by one Xword at a time. Note you have to press the key combination every time Xthe cursor steps back by one word. Continuously pressing META and Xtoggling B produces an error message. To move forward to the word X"stairs" enter @b<M-F>, which moves the cursor forward by one word at a Xtime. X XNotice that EMACS commands are usually mnemonic--F for forward, B for Xbackward, for example. X XTo move the cursor up one line, enter @b<^P> @i(previous-line) X@index(previous-line), down one line @b<^N> @i(next-line) X@index(next-line). Practice this movement by moving the cursor to the Xword "terrifying" in the second line. X XThe cursor may also be moved forward or backward in smaller increments. XTo move forward by one character, enter @b<^F> @i(forward-character) X@index(forward-character), to move backward, @b<^B> X@i(backward-character) @index(backward-character). EMACS also allows Xyou to specify a number which is normally used to tell a command to Xexecute many times. To repeat most commands, press META and then the Xnumber before you enter the command. Thus, the command META 5 ^F X(@b<M-5^F>) will move the cursor forward by five characters. Try moving Xaround in the text by using these commands. For extra practice, see how Xclose you can come to the word "small" in the first paragraph by giving Xan argument to the commands listed here. X XTwo other simple cursor commands that are useful to help us move around Xin the text are @b<M-N> @i(next-paragraph) @index(next-paragraph) which Xmoves the cursor to the second paragraph, and @b<M-P> X@i(previous-paragraph) @index(previous-paragraph) which moves it back to Xthe previous paragraph. The cursor may also be moved rapidly from one Xend of the line to the other. Move the cursor to the word "few" in the Xsecond line. Press @b<^A> @i(beginning-of-line) X@index(beginning-of-line). Notice the cursor moves to the word "events" Xat the beginning of the line. Pressing @b<^E> @i(end-of-line) X@index(end-of-line) moves the cursor to the end of the line. X XFinally, the cursor may be moved from any point in the file to the end Xor beginning of the file. Entering @b{M->} @i(end-of-file) X@index(end-of-file) moves the cursor to the end of the buffer, @b{M-<} X@i(beginning-of-file) @index(beginning-of-file) to the first character Xof the file. X X@i(On the IBM-PC, the ATARI ST and many other machines, the cursor keys X@index(cursor keys) can also be used to move the cursor about. Also, if Xthere is one available, moving the mouse will move the cursor.) X XPractice moving the cursor in the text until you are comfortable with Xthe commands we've explored in this chapter. X X@section(Saving your text) X XWhen you've finished practicing cursor movement, save your file. Your X@index(buffer) file currently resides in a @b<BUFFER>. The buffer is a Xtemporary storage area for your text, and is lost when the computer is Xturned off. You can save the buffer to a file by entering @b<^X-^S> X@i(save-file) @index(save-file). Notice that EMACS informs you that Xyour file has no name and will not let you save it. X XTo save your buffer to a file with a different name than it's current Xone (which is empty), press @b<^X^W> @i(write-file) @index(write-file). XEMACS will prompt you for the filename you wish to write. Enter the Xname @b<fang.txt> and press return. On a micro, the drive light will Xcome on, and EMACS will inform you it is writing the file. When it Xfinishes, it will inform you of the number of lines it has written to Xthe disk. X XCongratulations!! You've just saved your first EMACS file! X@newpage X@heading(Chapter @value(chapter) Summary) X X In chapter @value(chapter), you learned how to enter text, how Xto use wrap mode, how to move the cursor, and to save a buffer. The Xfollowing is a table of the commands covered in this chapter and their Xcorresponding key bindings: X X@begin{verbatim} X@u(Key Binding Keystroke Effect) X Xabort-command @b<^G> aborts current command X Xadd-mode @b<^XM> allows addition of EMACS X mode such as @b(WRAP) X Xbackward-character @b<^B> moves cursor left one character X Xbeginning-of-file @b{M-<} moves cursor to beginning of file X Xbeginning-of-line @b<^A> moves cursor to beginning of line X Xend-of-file @b{M->} moves cursor to end of file X Xend-of-line @b<^E> moves cursor to end of line X Xforward-character @b<^F> moves cursor right one character X Xnext-line @b<^N> moves cursor to next line X Xnext-paragraph @b<M-N> moves cursor to next paragraph X Xnext-word @b<M-F> moves cursor forward one word X Xprevious-line @b<^P> moves cursor backward by one line X Xprevious-paragraph @b<M-P> moves cursor to previous paragraph X Xprevious-word @b<M-B> moves cursor backward by one word X Xsave-file @b<^X-^S> saves current buffer to a file X Xwrite-file @b<^X-^W> save current buffer under a new name X@end(verbatim) X@newpage X@chapter(Basic Editing--Simple Insertions and Deletions) X X@section<A Word About Windows, Buffers, Screens, and Modes> X XIn the first chapter, you learned how to create and save a file in XEMACS. Let's do some more editing on this file. Call up emacs by Xtyping in the following command. X X@b<emacs fang.txt> X X@i(On icon oriented systems, double click on the uEMACS icon, usually a Xfile dialog box of some sort will appear. Choose @b(FANG.TXT) from the Xappropriate folder.) X XShortly after you invoke EMACS, the text should appear on the screen Xready for you to edit. The text you are looking at currently resides in Xa @b<buffer>. A buffer is a temporary area of computer memory which is X@index(buffer) the primary unit internal to EMACS -- this is the place Xwhere EMACS goes to work. The mode line at the bottom of the screen Xlists the buffer name, @b<FANG.TXT> and the name of the file with which Xthis buffer is associated, @b<FANG.TXT> X XThe computer talks to you through the use of its @b(screen). This X@index(screen) screen usually has an area of 24 lines each of 80 Xcharacters across. You can use EMACS to subdivide the screen into Xseveral separate work areas, or @b(windows), each of which can be X@index(window) 'looking into' different files or sections of text. Using Xwindows, you can work on several related texts at one time, copying and Xmoving blocks of text between windows with ease. To keep track of what Xyou are editing, each window is identified by a @b(mode line) on the X@index(mode line) @index(buffer) last line of the window which lists the Xname of the @b(buffer) which it is looking into, the file from which the Xtext was read, and how the text is being edited. X XAn EMACS @b<mode> tells EMACS how to deal with user input. As we have Xalready seen, the mode 'WRAP' controls how EMACS deals with long lines X(lines with over 79 characters) while the user is typing them in. The X'VIEW' mode, allows you to read a file without modifying it. Modes are Xassociated with buffers and not with files; hence, a mode needs to be Xexplicitly set or removed every time you edit a file. A new file read Xinto a buffer with a previously specified mode will be edited under this Xmode. If you use specific modes frequently, EMACS allows you to set Xthe modes which are used by all new buffers, called @b<global> modes. X X@section<Insertions> X XYour previously-saved text should look like this: X X@quotation<Fang Rock lighthouse, center of a series of mysterious and Xterrifying events at the turn of the century, is built on a rocky island Xa few miles of the Channel coast. So small is the island that wherever Xyou stand its rocks are wet with sea spray. X XThe lighthouse tower is in the center of the island. A steep flight of Xsteps leads to the heavy door in its base. Winding stairs lead up to Xthe crew room.> X XLet's assume you want to add a sentence in the second paragraph after Xthe word "base." Move the cursor until it is on the "W" of "Winding". XNow type the following: X X@quotation<This gives entry to the lower floor where the big steam Xgenerator throbs steadily away, providing power for the electric Xlantern.> X XIf the line fails to wrap and you end up with a '$' sign in the right Xmargin, just enter @b{M-Q} @i(fill-paragraph) @index(fill-paragraph) to Xreformat the paragraph. This new command attempts to fill out a Xparagraph. Long lines are divided up, and words are shuffled around to Xmake the paragraph look nicer. X XNotice that all visible EMACS characters are self-inserting -- all you Xhad to do was type the characters to insert and the existing text made Xspace for it. With a few exceptions discussed later, all non-printing Xcharacters (such as control or escape sequences) are commands. To Xinsert spaces, simply use the space bar. Now move to the first line of Xthe file and type @b{^O} @i(open-line) @index(open-line) (Oh, not zero). XYou've just learned how to insert a blank line in your text. X X@section<Deletions> X XEMACS offers a number of deletion options. For example, move the cursor Xuntil it's under the period at the end of the insertion you just did. XPress the backspace key. Notice the "n" on "lantern" disappeared. The Xbackspace implemented on EMACS is called a @b<destructive> backspace--it Xremoves text immediately before the current cursor position from the Xbuffer. Now type @b<^H> @i(delete-previous-character) X@index(delete-previous-character). Notice that the cursor moves back Xand obliterates the "r"--either command will backspace the cursor. X XType in the two letters you erased to restore your text and move the Xcursor to the beginning of the buffer @b{M->} @i(beginning-of-file) X@index(beginning-of-file). Move the cursor down one line to the Xbeginning of the first paragraph. X XTo delete the forward character, type @b{^D} @i(delete-next-character) X@index(delete-next-character). The "F" of "Fang" disappears. Continue Xto type @b{^D} until the whole word is erased EMACS also permits the Xdeletion of larger elements of text. Move the cursor to the word X"center" in the first line of text. Pressing @b{M-<backspace>} X@i(delete-previous-word) @index(delete-previous-word) kills the word Ximmediately before the cursor. @b{M-^H} has the same effect. X XNotice that the commands are very similar to the control commands you Xused to delete individual letters. As a general rule in EMACS, control Xsequences affect small areas of text, META sequences larger areas. The Xword forward of the cursor position can therefore be deleted by typing X@b{M-D} @i(delete-next-word) @index(delete-next-word). Now let's take Xout the remainder of the first line by typing @b{^K} X@i(kill-to-end-of-line) @index(kill-to-end-of-line). You now have a Xblank line at the top of your screen. Typing @b{^K} again or @b{^X-^O} X@i(delete-blank-lines) @index(delete-blank-lines) deletes the blank line Xand flushes the second line to the top of the text. Now exit EMACS by Xtyping @b{^X-^C} @i(exit-emacs) @index(exit-emacs). Notice EMACS Xreminds you that you have not saved your buffer. Ignore the warning and Xexit. This way you can exit EMACS without saving any of the changes you Xjust made. X X@heading(Chapter @value(chapter) Summary) X XIn Chapter @value(chapter), you learned about the basic 'building Xblocks' of an EMACS text file--buffers, windows, and files. X X@begin{verbatim} X@u(Key binding Keystroke Effect) Xdelete-previous-character X @b{^H} deletes character immediately before X the current cursor position X Xdelete-next-character @b{^D} deletes character immediately after X current cursor position X Xdelete-previous-word @b{M-^H} deletes word immediately before X current cursor position X Xdelete-next-word @b{M-D} deletes word immediately after X current cursor position X Xkill-to-end-of-line @b<^K> deletes from current cursor X position to end of line X Xinsert-space @b<^C> inserts a space to right of cursor X Xopen-line @b{^O} inserts blank line X Xdelete-blank-lines @b{^X-^O} removes blank line X Xexit-emacs @b{^X-^C} exits emacs X@end(verbatim) X@chapter(Using Regions) X X@section(Defining and Deleting a Region) X XAt this point its time to familiarize ourselves with two more EMACS Xterms--the @b<point> and the @b<mark>. The point is located directly X@index(point) @index(mark) behind the current cursor position. The mark X(as we shall see shortly) is user defined. These two elements together Xare called the current @b(region) and limit the @b<region> of text on Xwhich EMACS performs many of its editing functions. X XLet's begin by entering some new text. Don't forget to add @b(wrap) Xmode if its not set on this buffer. Start EMACS and open a file called X@b{PUBLISH.TXT}. Type in the following text: X X@quotation{One of the largest growth areas in personal computing is Xelectronic publishing. There are packages available for practically Xevery machine from elegantly simple programs for the humble Commodore 64 Xto sophisticated professional packages for PC and Macintosh computers. X XElectronic publishing is as revolutionary in its way as the Gutenburg Xpress. Whereas the printing press allowed the mass production and Xdistribution of the written word, electronic publishing puts the means Xof production in the hands of nearly every individual. From the class Xmagazine to the corporate report, electronic publishing is changing the Xway we produce and disseminate information. X XPersonal publishing greatly increases the utility of practically every Xcomputer. Thousands of people who joined the computer revolution of Xthis decade only to hide their machines unused in closets have Xdiscovered a new use for them as dedicated publishing workstations.} X XNow let's do some editing. The last paragraph seems a little out of Xplace. To see what the document looks like without it we can cut it Xfrom the text by moving the cursor to the beginning of the paragraph. XEnter @b(M-<space>) @i(set-mark) @index(set-mark). EMACS will respond Xwith "[Mark set]". Now move the cursor to the end of the paragraph. XYou have just defined a region of text. To remove this text from the Xscreen, type @b<^W> @i(kill-region) @index(kill-region). The paragraph Xdisappears from the screen. X XOn further consideration, however, perhaps the paragraph we cut wasn't Xso bad after all. The problem may have been one of placement. If we Xcould tack it on to the end of the first paragraph it might work quite Xwell to support and strengthen the argument. Move the cursor to the end Xof the first paragraph and enter @b<^Y> @i(yank) @index(yank). Your Xtext should now look like this: X X@quotation{One of the largest growth areas in personal computing is Xelectronic publishing. There are packages available for practically Xevery machine from elegantly simple programs for the humble Commodore 64 Xto sophisticated professional packages for PC and Macintosh computers. XPersonal publishing greatly increases the utility of practically every Xcomputer. Thousands of people who joined the computer revolution of Xthis decade only to hide their machines unused in closets have Xdiscovered a new use for them as dedicated publishing workstations. X XElectronic publishing is as revolutionary in its way as the Gutenburg Xpress. Whereas the printing press allowed the mass production and Xdistribution of the written word, electronic publishing puts the means Xof production in the hands of nearly every individual. From the class Xmagazine to the corporate report, electronic publishing is changing the Xway we produce and disseminate information.} X X@section(Yanking a Region) X XThe text you cut initially didn't simply just disappear, it was cut into Xa buffer that retains the 'killed' text appropriately called the @b<kill Xbuffer>. @b<^Y> "yanks" the text back from this buffer into the current Xbuffer. If you have a long line (indicated, remember, by the "$" Xsign), simply hit @b{M-Q} to reformat the paragraph. X XThere are other uses to which the kill buffer can be put. Using the X@index(kill buffer) method we've already learned, define the last Xparagraph as a region. Now type @b<M-W> @i(copy-region) X@index(copy-region). Nothing seems to have happened; the cursor stays Xblinking at the point. But things have changed, even though you may not Xbe able to see any alteration. X XTo see what has happened to the contents of the kill buffer, move the Xcursor down a couple of lines and "yank" the contents of the kill buffer Xback with @b<^Y>. Notice the last paragraph is now repeated. The Xregion you defined is "tacked on" to the end of your file because X@b<M-W> @b<copies> a region to the kill buffer while leaving the Xoriginal text in your working buffer. Some caution is needed however, Xbecause the contents of the kill buffer are updated when you delete any Xregions, lines or words. If you are moving large quantities of text, Xcomplete the operation before you do any more deletions or you could Xfind that the text you want to move has been replaced by the most recent Xdeletion. Remember--a buffer is a temporary area of computer memory Xthat is lost when the machine is powered down or switched off. In order Xto make your changes permanent, they must be saved to a file before you Xleave EMACS. Let's delete the section of text we just added and save Xthe file to disk. X X@heading(Chapter @value(chapter) Summary) X XIn Chapter @value(chapter), you learned how to achieve longer insertions Xand deletions. The EMACS terms @b<point> and @b<mark> were introduced Xand you learned how to manipulate text with the kill buffer. X X@begin{verbatim} X@begin(group) X@u(Key Binding Keystroke Effect) X XDelete-Region @b{^W} Deletes region between point and mark and X places it in KILL buffer X XCopy-Region @b{M-W} Copies text between point and mark into X KILL buffer X XYank-Text @b{^Y} Inserts a copy of the KILL buffer into X current buffer at point X@end(group) X@end(verbatim) X@chapter(Search and Replace) X X@section<Forward Search> X XLoad EMACS and bring in the file you just saved. Your file should look Xlike the one below. X X@quotation{One of the largest growth areas in personal computing is electronic Xpublishing. There are packages available for practically every machine Xfrom elegantly simple programs for the humble Commodore 64 to Xsophisticated professional packages for PC and Macintosh computers. XPersonal publishing greatly increases the utility of practically every Xcomputer. Thousands of people who joined the computer revolution of Xthis decade only to hide their machines unused in closets have Xdiscovered a new use for them as dedicated publishing workstations. X XElectronic publishing is as revolutionary in its way as the Gutenburg Xpress. Whereas the printing press allowed the mass production and Xdistribution of the written word, electronic publishing puts the means Xof production in the hands of nearly every individual. From the class Xmagazine to the corporate report, electronic publishing is changing the Xway we produce and disseminate information.} X XLet's use EMACS to search for the word "revolutionary" in the second Xparagraph. Because EMACS searches from the current cursor position Xtoward the end of buffers, and we intend to search forward, move the Xcursor to the beginning of the text. Enter @b<^S> @i(search-forward) X@index(search-forward). Note that the command line now reads X X"Search [] <META>:" X XEMACS is prompting you to enter the @b<search string> -- the text you Xwant to find. Enter the word @b<revolutionary> and hit the @b<META> Xkey. The cursor moves to the end of the word "revolutionary." X XNotice that you must enter the <META> key to start the search. If you X@index(<NL>) simply press <NL> the command line responds with "<NL>". XAlthough this may seem infuriating to users who are used to pressing the Xreturn key to execute any command, EMACS' use of <META> to begin Xsearches allows it to pinpoint text with great accuracy. After every Xline wrap or carriage return, EMACS 'sees' a new line character (<NL>). XIf you need to search for a word at the end of a line, you can specify Xthis word uniquely in EMACS. X XIn our sample text for example, the word "and" occurs a number of times, Xbut only once at the end of a line. To search for this particular Xoccurence of the word, move the cursor to the beginning of the buffer Xand type @b(^S). Notice that EMACS stores the last specified X@index(default string) search string as the @b<default> string. If you Xpress @b{<META>} now, EMACS will search for the default string, in this Xcase, "revolutionary." X XTo change this string so we can search for our specified "and" simply Xenter the word @b{and} followed by @b{<NL>}. The command Xline now shows: X X"search [and<NL>]<META>:" X XPress @b{<META>} and the cursor moves to "and" at the end of the second Xlast line. X X@section<Exact Searches> X XIf the mode EXACT is active in the current buffer, EMACS searches on a case Xsensitive basis. Thus, for example you could search for @b{Publishing} Xas distinct from @b{publishing}. X X X@section<Backward Search> X XBackward searching is very similar to forward searching except that it Xis implemented in the reverse direction. To implement a reverse search, Xtype @b{^R} @i(search-reverse) @index(search-reverse). Because EMACS Xmakes no distinction between forward and backward stored search strings, Xthe last search item you entered appears as the default string. Try Xsearching back for any word that lies between the cursor and the Xbeginning of the buffer. Notice that when the item is found, the point Xmoves to the beginning of the found string (i.e., the cursor appears Xunder the first letter of the search item). X XPractice searching for other words in your text. X X@section<Searching and Replacing> X XSearching and replacing is a powerful and quick way of making changes to Xyour text. Our sample text is about electronic publishing, but the Xcorrect term is 'desktop' publishing. To make the necessary changes we Xneed to replace all occurences of the word "electronic" with "desktop." XFirst, move the cursor to the top of the current buffer with the @b(M-<) Xcommand. Then type @b[M-R] @i(replace-string) @index(replace-string). XThe command line responds: X X"Replace []<META>:" X Xwhere the square brackets enclose the default string. Type the word X@b<electronic> and hit @b{<META>}. The command line responds: X X"with []<META>" X Xtype @b{desktop<META>}. EMACS replaces all instances of the original Xword with your revision. Of course, you will have to capitalize the Xfirst letter of "desktop" where it occurs at the beginning of a Xsentence. X XYou have just completed an @b<unconditional replace>. In this Xoperation, EMACS replaces every instance of the found string with the Xreplacement string. X X@section<Query-Replace> X XYou may also replace text on a case by case basis. The @b{M-^R} X@i(query-replace-string) @index(query-replace-string) command causes XEMACS to pause at each instance of the found string. X XFor example, assume we want to replace some instances of the word X"desktop" with the word "personal." Go back to the beginning of the Xcurrent buffer and enter the @b(M-^R) @i(query-replace) X@index(query-replace) command. The procedure is very similar to that Xwhich you followed in the unconditional search/replace option. When the Xsearch begins however, you will notice that EMACS pauses at each Xinstance of "publishing" and asks whether you wish to replace it with Xthe replacement string. You have a number of options available for Xresponse: X X@begin(verbatim) X@u( Response Effect) X Y(es) Make the current replacement and skip to the next X occurence of the search string X X N(o) Do not make this replacement but continue X X ! Do the rest of the replacements with no more queries X X U(ndo) Undo just the last replacement and query for it X again (This can only go back ONE time) X X ^G Abort the replacement command (This action does not X undo previously-authorized replacements X X . Same effect as ^G, but cursor returns to the point at X which the replacement command was given X X ? This lists help for the query replacement command X@end(verbatim) X XPractice searching and searching and replacing until you feel Xcomfortable with the commands and their effects. X@begin(group) X@heading(Chapter @value(chapter) Summary) X XIn this chapter, you learned how to search for specified strings of text Xin EMACS. The chapter also dealt with searching for and replacing Xelements within a buffer. X X@begin(verbatim) X@u(Key Binding Keystroke Effect) X XSearch-Forward @b{^S} Searches from point to end of buffer. X Point is moved from current location to X the end of the found string X XSearch-Backward @b{^R} Searches from point to beginning of buffer. X Point is moved from current location to X beginning of found string X XReplace @b{M-R} Replace ALL ocurrences of search string with X specified (null) string from point to the X end of the current buffer X XQuery-Replace @b{M-^R} As above, but pause at each found string X and query for action X@end(verbatim) X@end(group) X@chapter(Windows) X X@section<Creating Windows>@index{Windows, Creating} X XWe have already met windows in an earlier chapter. In this chapter, we Xwill explore one of EMACS' more powerful features -- text manipulation Xthrough multiple windowing. Windows offer you a powerful and easy way Xto edit text. By manipulating a number of windows and buffers on the Xscreen simultaneously, you can perform complete edits and revisions on Xthe computer screen while having your draft text or original data Xavailable for reference in another window. X XYou will recall that windows are areas of buffer text that you can see X@index(windows) on the screen. Because EMACS can support several screen Xwindows simultaneously you can use them to look into different places in Xthe same buffer. You can also use them to look at text in different Xbuffers. In effect, you can edit several files at the same time. X XLet's invoke EMACS and pull back our file on desktop publishing by Xtyping X X@quotation<emacs publish.txt> X XWhen the text appears, type the @b{^X-2} @i(split-window) X@index{split-window} command. The window splits into two windows. The Xwindow where the cursor resides is called the @b<current> window -- in Xthis case the bottom window. Notice that each window has a text area Xand a mode line. The @b(command line) @index{command line} is however, Xcommon to all windows on the screen. X XThe two windows on your screen are virtually mirror images of each other Xbecause the new window is opened into the same buffer as the one you are Xin when you issue the @i{open-window command} @index{open-window}. All Xcommands issued to EMACS are executed on the current buffer in the Xcurrent window. X XTo move the cursor to the upper window (i.e., to make that window the Xcurrent window, type @b{^X-P} @i(previous-window) @index{previous-window}. XNotice the cursor Xmoves to the upper or @b<previous> window. Entering @b{^X-O} X@i(next-window) moves to the @b{next} window. Practice moving between Xwindows. You will notice that you can also move into the Function Key Xmenu by entering these commands. X XNow move to the upper window. Let's open a new file. On the EMACS disk Xis a tutorial file. Let's call it into the upper window by typing: X X@quotation<^X-^F> X Xand press return. X XEnter the filename @b<emacs.tut>. X XIn a short time, the tutorial file will appear in the window. We now have Xtwo windows on the screen, each looking into different buffers. We have Xjust used the @b(^X-^F) @i(find-file) @index{find-file} Xcommand to find a file and bring Xit into our current window. X XYou can scroll any window up and down with the cursor keys, or with the Xcommands we've learned so far. However, because the area of visible Xtext in each window is relatively small, you can scroll the current Xwindow a line at a time. X XType @b{^X-^N} @i(move-window-down)@index{move-window-down} X XThe current window scrolls down by one line -- the top line of text Xscrolls out of view, and the bottom line moves towards the top of the Xscreen. You can imagine, if you like, the whole window slowly moving Xdown to the end of the buffer in increments of one line. The command X@b{^X-^P} @i(move-window-up)@index{move-window-up} Xscrolls the window in the opposite Xdirection. X XAs we have seen, EMACS editing commands are executed in the current Xwindow, but the program does support a useful feature that allows you to Xscroll the @b<next> window. X@b<M-^Z> @i(scroll-next-up)@index{scroll-next-up} Xscrolls the next Xwindow up, @b{M-^V} @i(scroll-next-down)@index{scroll-next-down} Xscrolls it downward. From the Xtutorial window, practice scrolling the window with the desktop Xpublishing text in it up and down. X XWhen you're finished, exit EMACS without saving any changes in your Xfiles. X X XExperiment with splitting the windows on your screen. Open windows into Xdifferent buffers and experiment with any other files you may have. Try Xediting the text in each window, but Xdon't forget to save any changes you want to keep -- you still have to Xsave each buffer separately. X X@section(Deleting Windows)@index{Windows, Deleting} XWindows allow you to perform complex editing tasks with ease. However, Xthey become an inconvenience when your screen is cluttered with open Xwindows you have finished using. The simplest solution is to delete Xunneeded windows. The command @b{^X-0} @i{delete-window} Xwill delete the window you are currently working in and move you to the Xnext window. X XIf you have a number of windows open, you can delete all but the current Xwindow by entering @b{^X-1} @i{delete-other-windows}. X X@section(Resizing Windows)@index{Windows, Resizing} X XDuring complex editing tasks, you will probably find it convenient to Xhave a number of windows on the screen simultaneously. However this Xsituation may present inconveniences because the more windows you have Xon the screen the smaller they are; in some cases, a window may show Xonly a couple of lines of text. To increase the flexibility and utility Xof the window environment, EMACS allows you to resize the window you are Xworking in (called, as you will recall, the @b<current> window) to a Xconvenient size for easier editing, and then shrink it when you no Xlonger need it to be so large. X XLet's try an example. Load in any EMACS text file and split the current Xwindow into two. Now type @b{^X-^(Shift-6)}, X@i{grow-window}@index{grow-window}. Your current window should be Xthe lower one on the screen. Notice that it increases in size upwards Xby one line. If you are in the upper window, it increases in size in a Xdownward direction. The command @b{^X-^Z}, X@i{shrink-window}@index{shrink-window} correspondingly decreases window Xsize by one line at a time. X XEMACS also allows you to resize a window more precisely by entering a Xnumeric argument specifying the size of the window in lines. To resize Xthe window this way, press the META key and enter a numeric argument X(remember to keep it smaller than the number of lines on your screen Xdisplay) then press @b{^X-W} @i{resize-window}@index{resize-window}. XThe current window will be enlarged or shrunk to the number of lines Xspecified in the numeric argument. For example entering: X X@quotation{@b[M-8 ^X-W]}will resize the current window to 8 lines. X X@section(Repositioning within a Window) X XThe cursor may be centered within a window by entering @b{M-! or M-^L} X@i{redraw-display} @index{redraw-display}. This command is especially Xuseful in allowing you to quickly locate the cursor if you are moving Xfrequently from window to window. You can also use this command to move Xthe line containing the cursor to any position within the current Xwindow. This is done by using a numeric argument before the command. XType @b(M-<n> M-^L) where <n> is the number of the line within the Xwindow that you wish the current line to be displayed. X XThe @b{^L} @i{Refresh-screen} @index{refresh-screen} command is useful Xfor 'cleaning up' a 'messy' screen that can result of using EMACS on a Xmainframe system and being interupted by a system message. X@newpage X@u<Chapter @value(chapter) summary> X XIn Chapter @value(chapter) you learned how to manipulate windows and the Xediting flexibility they offer. X X@begin(verbatim) X@u(Key Binding Keystroke Effect) X XOpen-Window @b{^X-2} Splits current window into two windows if X space available X XClose-Windows @b{^X-1} Closes all windows except current window X XNext-Window @b{^X-O}[oh] Moves point into next (i.e. downward) window X XPrevious-Window @b{^XP} Moves point to previous (i.e. upward) window X XMove-Window-Down @b{^X-^N} Scrolls current window down one line X XMove-Window-Up @b{^X-^P} Scrolls current window up one line X XRedraw-display @b{M !} or Window is moved so line with point X @b{M ^L} (with cursor) is at center of window X XGrow-Window @b{M-X ^} or Current window is enlarged by one X @b{M ^L} line and nearest window is shrunk by X one line X XShrink-Window @b{^X-^Z} Current window is shrunk by one line X and nearest window is enlarged by one line X XClear-and-redraw @b{^L} Screen is blanked and redrawn. Keeps X screen updates in sync with your commands X XScroll-Next-Up @b{M-^Z} Scrolls next window up by one line X XScroll-Next-Down @b{M-^V} Scrolls next window down by one line X XDelete-Window @b{^X-0} Deletes current window X XDelete-Other-Windows @b{^X-1} Deletes all but current window X XResize-Window @b{^X-^W} Resizes window to a given numeric argument X@end(verbatim) X@chapter(Buffers) X X@index(buffer) We have already learned a number of things about buffers. XAs you will recall, they are the major internal entities in EMACS -- the Xplace where editing commands are executed. They are characterized by Xtheir @b<names>, their @b<modes>, and by the file with which they are Xassociated. Each buffer also "remembers" its @b(mark) and @b(point). XThis convenient feature allows you to go to other buffers and return to Xthe original location in the "current" buffer. X XAdvanced users of EMACS frequently have a number of buffers in the Xcomputer's memory simultaneously. In the last chapter, for example, you Xopened at least two buffers -- one into the text you were editing, and Xthe other into the EMACS on-line tutorial. If you deal with complex Xtext files -- say, sectioned chapters of a book, you may have five or Xsix buffers in the computer's memory. You could select different Xbuffers by simply calling up the file with @b{^X-^F} @i(find-file) X@index(find-file), and let EMACS open or reopen the buffer. However, XEMACS offers fast and sophisticated buffering techniques that you will Xfind easy to master and much more convenient to use. X XLet's begin by opening three buffers. You can open any three you Xchoose, for example call the following files into memory: @b(fang.txt), X@b(publish.txt), and @b(emacs.tut) in the order listed here. When Xyou've finished this process, you'll be looking at a screen showing the XEMACS tutorial. Let's assume that you want to move to the fang.txt Xbuffer. Enter: X X@b{^X-X} @i(next-buffer) @index(next-buffer) X XThis command moves you to the @u<next> buffer. Because EMACS cycles Xthrough the buffer list, which is alphabetized, you will now be in the X@b(fang.txt) buffer. Using @b(^X-X) again places you in the X@b(publish.txt) buffer. @i(If you are on a machine that supports Xfunction keys, using @b[^X-X] again places you in the @b(Function Keys) Xbuffer). Using @b(^X-X) one last time cycles you back to the beginning Xof the list. X XIf you have a large number of buffers to deal with, this cycling process Xmay be slow and inconvenient. The command @b{^X-B} @i(select-buffer) X@index(select-buffer) allows you to specify the buffer you wish to be Xswitched to. When the command is entered, EMACS prompts, "Use buffer:". XSimply enter the buffer name (NOT the file name), and that buffer will Xthen become the current buffer. X XMultiple buffer manipulation and editing is a complex activity, and you Xwill probably find it very inconvenient to re-save each buffer as you Xmodify it. The command @b{^X-^B} @i(list-buffers) @index(list-buffers) Xcreates a new window that gives details about all the buffers currently Xknown to EMACS. Buffers that have been modified are identified by the X"buffer changed" indicator (an asterisk in the second column). You can Xthus quickly and easily identify buffers that need to be saved to files Xbefore you exit EMACS. The buffer window also provides other Xinformation -- buffer specific modes, buffer size, and buffer name are Xalso listed. To close this window, simply type the close-windows Xcommand, @b{^X-1}. X XTo delete any buffer, type @b{^X-K} @i(delete-buffer) X@index(delete-buffer). EMACS prompts you "Kill buffer:". Enter the Xbuffer name you want to delete. As this is destructive command, EMACS Xwill ask for confirmation if the buffer was changed and not saved. XAnswer Y(es) or N(o). As usual @b{^G} cancels the command. X X@newpage X@heading(Chapter @value(chapter) Summary) X XIn Chapter @value(chapter) you learned how to manipulate buffers. X X@begin{verbatim} X@u(Key Binding Keystroke Effect) XNext-Buffer @b(^X-^X) Switch to the next buffer in the X buffer list X XSelect-Buffer @b(^X-B) Switch to a particular buffer X XList-Buffers @b(^X-^B) List all buffers X XDelete-Buffer @b(^X-K) delete a particular buffer if it X is off-screen X@end(verbatim) X@chapter(Modes) X X EMACS allows you to change the way it works in order to Xcustomized it to the style of editing you are using. It does this by Xproviding a number of different @b(modes) @index(modes). These modes Xcan effect either a single buffer, or any new buffer that is created. XTo add a mode to the current buffer, type @b(^X-M) @i(add-mode) X@index(add-mode). EMACS will then prompt you for the name of a mode to Xadd. When you type in a legal mode name, and type a <NL>, EMACS will Xadd the mode name to the list of current mode names in the modeline of Xthe current buffer. X X To remove an existing mode, typing the @b(^X-^M) @i(delete-mode) X@index(delete-mode) will cause EMACS to prompt you for the name of a Xmode to delete from the current buffer. This will remove that mode from Xthe mode list on the current modeline. X X Global modes are the modes which are inherited by any new Xbuffers which are created. For example, if you wish to always do string Xsearching with character case being significant, you would want global Xmode EXACT to be set so that any new files read in inherent the EXACT Xmode. Global modes are set with the @b(M-M) @i(add-global-mode) X@index(add-global-mode) command, and unset with the @b(M-^M) X@i(delete-global-mode) @index(delete-global-mode) command. Also, the Xcurrent global modes are displayed in the first line of a X@b(^X-^B) @i(list-buffers) @index(list-buffers) command. X X On machines which are capable of displaying colors, X@index(color) the mode commands can also set the background and Xforeground character colors. Using @i(add-mode) or @i(delete-mode) with Xa lowercase color will set the background color in the current window. XAn uppercase color will set the foreground color in the current window. XColors that EMACS knows about are: white, cyan, magenta, yellow, blue, Xred, green, and black. If the computer you are running on does not have Xeight colors, EMACS will attempt to make some intelligent guess at what Xcolor to use when you ask for one which is not there. X X@section(ASAVE mode)@index(ASAVE mode) X X Automatic Save mode tells EMACS to automatically write out the Xcurrent buffer to its associated file on a regular basis. Normally this Xwill be every 256 characters typed into the file. The environment Xvariable $ACOUNT counts down to the next auto-save, and $ASAVE is the
nwd@j.cc.purdue.edu (Daniel Lawrence) (11/26/87)
Xvalue used to reset $ACOUNT after a save occurs. X X@section(CMODE mode)@index(CMODE mode) X X CMODE is useful to C programmers. When CMODE is active, EMACS Xwill try to assist the user in a number of ways. This mode is set Xautomatically with files that have a .c or .h extension. X X The <NL> key will normally attempt to return the user to the next Xline at the same level of indentation as the current line, unless the Xcurrent line ends with a open brace ({) in which case the new line will Xbe further indented by one tab position. X X A close brace (}) will delete one tab position preceeding itself Xas it is typed. This should line up the close brace with its matching XIF, FOR or WHILE statement. X X A pound sign (#) with only leading whitespace will delete all Xthe whitespace preceeding itself. This will always bring preprocessor Xdirectives flush to the left margin. X X Whenever any close fence is typed, ie )]>}, if the matching open Xfence is on screen in the current window, the cursor will briefly flash Xto it, and then back. This makes balancing expressions, and matching Xblocks much easier. X X@section(CRYPT mode)@index(CRYPT mode) X X When a buffer is in CRYPT mode, @index(encryption) it is Xencrypted whenever it is written to a file, and decrypted when it is Xread from the file. The encryption key can be specified on the command Xline with the -k switch, or with the @b(M-E) @i(set-encryption-key) X@index(set-encryption-key) command. If you attempt to read or write a Xbuffer in crypt mode and now key has not been set, EMACS will execute X@i(set-encryption-key) automatically, prompting you for the needed key. XWhenever EMACS prompts you for a key, it will not echo the key to your Xscreen as you type it (ie make SURE you get it right when you set it Xoriginally). X X The encryption algorithm used changes all characters into normal Xprinting characters, thus the resulting file is suitable for sending via Xelectronic mail. All version of MicroEMACS should be able decrypt the Xresulting file regardless of what machine encrypted it. Also available Xwith EMACS is the stand alone program, MicroCRYPT, which can en/decrypt Xthe files produced by CRYPT mode in EMACS. X X@section(EXACT mode)@index(EXACT mode) X X All string searches and replacements will take upper/lower case Xinto account. Normally the case of a string during a search or replace Xis not taken into account. X X@section(MAGIC mode)@index(MAGIC mode) X X In the MAGIC mode certain characters gain special meanings when Xused in a search pattern. Collectively they are know as regular Xexpressions, and a limited number of them are supported in MicroEmacs. XThey grant greater flexibility when using the search command. However, Xthey do not affect the incremental search command. X X The symbols that have special meaning in MAGIC mode are X^, $, ., &, *, [ (and ], used with it), and \. X X The characters ^ and $ fix the search pattern to the beginning and Xend of line, respectively. The ^ character must appear at the beginning Xof the search string, and the $ must appear at the end, otherwise they Xloose their meaning and are treated just like any other character. For Xexample, in MAGIC mode, searching for the pattern "t$" would put the Xcursor at the end of any line that ended with the letter 't'. Note that Xthis is different than searching for "t<NL>", that is, 't' followed by a Xnewline character. The character $ (and ^, for that matter) matches a Xposition, not a character, so the cursor remains at the end of the line. XBut a newline is a character that must be matched, just like any other Xcharacter, which means that the cursor is placed just after it - on the Xbeginning of the next line. X X The character . has a very simple meaning -- it matches any single Xcharacter, except the newline. Thus a search for "bad.er" could match X"badger", "badder" (slang), or up to the 'r' of "bad error". X X The character * is known as closure, and means that zero or more of Xthe preceding character will match. If there is no character preceding, X* has no special meaning, and since it will not match with a newline, * Xwill have no special meaning if preceded by the beginning of line symbol X^ or the literal newline character <NL>. X X The notion of zero or more characters is important. If, for Xexample, your cursor was on the line X X@quotation(This line is missing two vowels.) X Xand a search was made for "a*", the cursor would not move, because it is Xguaranteed to match no letter 'a' , which satifies the search Xconditions. If you wanted to search for one or more of the letter 'a', Xyou would search for "aa*", which would match the letter a, then zero or Xmore of them. X X The character [ indicates the beginning of a character class. It Xis similar to the 'any' character ., but you get to choose which Xcharacters you want to match. The character class is ended with the Xcharacter ]. So, while a search for "ba.e" will match "bane", "bade", X"bale", "bate", et cetera, you can limit it to matching "babe" and X"bake" by searching for "ba[bk]e". Only one of the characters inside Xthe [ and ] will match a character. If in fact you want to match any Xcharacter except those in the character class, you can put a ^ as the Xfirst character. It must be the first character of the class, or else Xit has no special meaning. So, a search for [^aeiou] will match any Xcharacter except a vowel, but a search for [aeiou^] will match any vowel Xor a ^. X XIf you have a lot of characters in order that you want to put in the Xcharacter class, you may use a dash (-) as a range character. So, [a-z] Xwill match any letter (or any lower case letter if EXACT mode is on), Xand [0-9a-f] will match any digit or any letter 'a' through 'f', which Xhappen to be the characters for hexadecimal numbers. If the dash is at Xthe beginning or end of a character class, it is taken to be just a Xdash. X X The character & (ampersand) is a replacement character, and Xrepresents the characters which matched the search string. When used in Xthe @b[M-R] @i(replace-string) @index(replace-string) or the @b[M-^R] X@i(query-replace-string) @index(query-replace-string) commands, the & Xwill be substituted for the search string. X X The escape character \ is for those times when you want to be in XMAGIC mode, but also want to use a regular expression character Xto be just a character. It turns off the special meaning of the Xcharacter. So a search for "it\." will search for a line with "it.", Xand not "it" followed by any other character. The escape character Xwill also let you put ^, -, or ] inside a character class with no Xspecial side effects. X X@section(OVER mode)@index(OVER mode) X X OVER mode stands for overwrite mode. When in this mode, when Xcharacters are typed, instead of simply inserting them into the file, XEMACS will attempt to overwrite an existing character past the point. XThis is very useful for adjusting tables and diagrams. X X@section(WRAP mode)@index(WRAP mode) X X Wrap mode is used when typing in continuous text. Whenever the Xcursor is past the currently set fill column @index(fill column) (72 by Xdefault) and the user types a space or a <NL>, the last word of the line Xis brought down to the beginning of the next line. Using this, one just Xtypes a continuous stream of words and EMACS automatically inserts <NL>s Xat appropriate places. X X@center(NOTE to programmers:) X X@quotation{EMACS actually calls up the function bound to the illegal Xkeystroke M-FNW. This is bound to the function @i(wrap-word) X@index(wrap-word) by default, but can be re-bound to activate different Xfunctions and macros at wrap time.} X X@section(VIEW mode)@index(VIEW mode) X X VIEW mode disables all commands which can change the current Xbuffer. EMACS will display an error message and ring the bell every Xtime you attempt to change a buffer in VIEW mode. X@newpage X@heading(Chapter @value(chapter) Summary) X XIn Chapter @value(chapter) you learned about modes and their effects. X X@begin{verbatim} X@u(Key Binding Keystroke Effect) XAdd-Mode @b(^X-M) Add a mode to the current buffer X XDelete-Mode @b(^X-^M) Delete a mode from the current buffer X XAdd-Global-Mode @b(M-M) Add a global mode to the X current buffer X XDelete-Global-Mode @b(M-^M) Delete a global mode from the X current buffer X@end(verbatim) X@chapter(Files) X XA file is simply a collection of related data. In EMACS we are dealing Xwith text files -- named collections of text residing on a disk (or some Xother storage medium). You will recall that the major entities EMACS Xdeals with are buffers. Disk-based versions of files are only active in XEMACS when you are reading into or writing out of buffers. As we have Xalready seen, buffers and physical files are linked by associated Xfile names. For example, the buffer "ch7.txt" which is associated with Xthe physical disk file "ch7.txt." You will notice that the file is Xusually specified by the drive name or (in the case of a hard drive) a Xpath. Thus you can specify full file names in EMACS, X Xe.g. disk:\directories\filename.extension X XIf you do not specify a disk and directories, the default disk is used. X XIMPORTANT -- If you do not explicitly save your buffer to a file, all your Xedits will be lost when you leave EMACS (although EMACS will prompt you Xwhen you are about to lose edits by exiting). In addition, EMACS does Xnot protect your disk-based files from overwriting when it saves files. XThus when you instruct EMACS to save a file to disk, it will create a Xfile if the specified file doesn't exist, or it will overwrite the Xpreviously saved version of the file thus replacing it. Your old Xversion is gone forever. X XIf you are at all unsure about your edits, or if (for any reason) you Xwish to keep previous versions of a file, you can change the name of the Xassociated file with the command @b{^X-N}. When this file is saved Xto disk, EMACS will create a new physical file under the new name. The Xearlier disk file will be preserved. X XFor example, let's load the file @b{fang.txt} into EMACS. Now, type X@b{^X-N}. The EMACS command line prompts "name:". Enter a new name Xfor the file -- say @b(new.txt) and press <NL>. The file will be Xsaved under the new filename, and your disk directory will show both X@b(fang.txt) and @b(new.txt). X XAn alternative method is to write the file directly to disk under a new Xfilename. Let's pull our "publish.txt" file into EMACS. To write this Xfile under another filename, type @b{^X-^W}. EMACS will prompt Xyou "write file:". Enter an alternate filename -- @b{desktop.txt}. XYour file will be saved as the physical file "desktop.txt". X XNote that in the examples above, although you have changed the names of Xthe related files, the buffer names remain the same. However, when you Xpull the physical file back into EMACS, you will find that the buffer Xname now relates to the filename. X XFor example -- You are working with a buffer "fang.txt" with the related Xfile "fang.txt". You change the name of the file to "new.txt". EMACS Xnow shows you working with the buffer "fang.txt" and the related file X"new.txt". Now pull the file "new.txt" into EMACS. Notice that the Xbuffer name has now changed to "new.txt". X XIf for any reason a conflict of buffer names occurs,(if you have files Xof the same name on different drives for example) EMACS will prompt Xyou "use buffer:". Enter an alternative buffer name if you need to. X XFor a list of file related commands (including some we`ve already Xseen), see the summary page. X@newpage X@heading(Chapter @value(chapter) Summary) X XIn Chapter @value(chapter) you learned some of the more advanced Xconcepts of file naming and manipulation. The relationship between Xfiles and buffers was discussed in some detail. X X@begin(verbatim) X@u(Key Binding Keystroke Effect) X XSave-file @b{^X-^S} Saves contents of current buffer with X associated filename on default disk/ X directory (if not specified) X XWrite-File @b{^X-^W} Current buffer contents will be X saved under specified name X XChange-File-name X @b{^X-N} The associated filename is changed X (or associated if not previously X specified) as specified X XFind-File @b{^X-^F} Reads specified file into buffer and X switches you to that buffer, or switches X to buffer in which the file has previously X been read X XRead-File @b{^X-^R} Reads file into buffer thus overwriting X buffer contents. If file has already X been read into another buffer, you will X be switched to it X XView-File @b{^X-^V} The same as read-file except the buffer X is automatically put into VIEW mode thus X preventing any changes from being made X@end{verbatim} X@chapter(Screen Formatting) X X@section<Wrapping Text> X XAs we learned in the introduction, EMACS is not a word processor, but an Xeditor. Some simple formatting options are available however, although Xin most cases they will not affect the appearence of the finished text X@index(wrapping text) when it is run through the formatter. We have Xalready encountered WRAP mode which wraps lines longer than a certain Xlength (default is 75 characters). You will recall that WRAP is enabled Xby entering @b{^X-M} and responding to the command line prompt with X@b{wrap}. X XYou can also set your own wrap margin with the command @b{^X-F} X@i(set-fill-column) @index(set-fill-column). Notice EMACS responds X"[Fill column is 1]." Now try typing some text. You'll notice some very Xstrange things happening -- your text wraps at every word!! This effect Xoccurs because the set wrap margin command must be preceeded by a Xnumeric argument or EMACS sets it to the first column. Thus any text Xyou type that extends past the first column will wrap at the most Xconvenient line break. X XTo reset the wrap column to 72 characters, press the @b{<META>} key and Xenter 72. EMACS will respond "Arg: 72". Now press @b<^X-F>. EMACS Xwill respond "[Fill column is 72]". Your text will again wrap at the Xmargin you've been using up to this point. X X@section<Reformatting Paragraphs> X XAfter an intensive editing session, you may find that you have Xparagraphs containing lines of differing lengths. Although this Xdisparity will not affect the formatted text, aesthetic and technical Xconcerns may make it desirable to have consistent paragraph blocks on Xthe screen. If you are in WRAP mode, you can reformat a paragraph with Xthe command @b{M-Q} @i(fill-paragraph) @index(fill-paragraph). This Xcommand 'fills' the current paragraph reformatting it so all the lines Xare filled and wrap logically. The process is complex, and (especially Xwith longer paragraphs) may take a little time. X X@section<Changing Case> X XThere may be occasions when you find it necessary to change the case of Xthe text you've entered. EMACS allows you to change the case of even Xlarge amounts of text with ease. Let's try and convert a few of the Xoffice traditionalists to the joy of word processing. Type in the Xfollowing text: X X@quotation{Throw away your typewriter and learn to use a word processor. XWord processing is relatively easy to learn and will increase your Xproductivity enormously. Enter the Computer Age and find out just how Xmuch fun it can be!!} X XLet's give it a little more impact by capitalizing the first four words. XThe first step is to define the region of text just as you would if you Xwere doing an extensive deletion. Set the mark at the beginning of the Xparagraph with @b{M-<space>} @i(set-mark) and move the cursor to the Xspace beyond "typewriter." Now enter @b{^X-^U} @i(case-region-upper). XYour text should now look like this: X X@quotation{THROW AWAY YOUR TYPEWRITER and learn to use a word processor. XWord processing is relatively easy to learn and will increase your Xproductivity enormously. Enter the Computer Age and find out just how Xmuch fun it can be!!} X XIf you want to change the text back to lower case, type @b{^X-^L} X@i(case-region-lower) @index(case-region-lower). You can also Xcapitalize individual words. To capitalize the word "fun", position the Xcursor in front of the word and type @b{M-U} @i(case-word-upper) X@index(case-word-upper). The word is now capitalized. To change it Xback to lower case, move the cursor back to the beginning of the word Xand type @b{M-L} @i(case-word-lower) @index(case-word-lower). X XYou may also capitalize individual letters in EMACS. The command X@b{M-C} @i(case-word-capitalize) @index(case-word-capitalize) Xcapitalizes the first letter after the point. This command would Xnormally be issued with the cursor positioned in front of the first Xletter of the word you wish to capitalize. If you issue it in the Xmiddle of a word, you can end up with some strAnge looking text. X X@section<Tabs> X XUnless your formatter is instructed to take screen text literally (as XMicroSCRIBE does in the 'verbatim' environment for example), tabs in XEMACS generally affect screen formatting only. X XWhen EMACS is first started, it sets the default tab to every eighth Xcolumn. As long as you stay with default, every time you press the tab Xkey a tab character, @b(^I) is inserted. This character, like other Xcontrol characters, is invisible -- but it makes a subtle and Xsignificant difference to your file and editing. X XFor example, in default mode, press the tab key and then type the word X@b{Test}. "Test" appears at the eighth column. Move your cursor to the Xbeginning of the word and delete the backward character. The word Xdoesn't move back just one character, but flushes to the left margin. XThe reason for this behavior is easily explained. In tab default, EMACS Xinserts a 'real' tab character when you press the tab key. This Xcharacter is inserted at the default position, but NO SPACES are Xinserted between the tab character and the margin (or previous tab Xcharacter). As you will recall, EMACS only recognizes characters (such Xas spaces or letters) and thus when the tab character is removed, the Xtext beyond the tab is flushed back to the margin or previous tab mark. X XThis situation changes if you alter the default configuration. The Xdefault value may be changed by entering a numeric argument before Xpressing the tab key. As we saw earlier, pressing the @b{META} key and Xentering a number allows you to specify how EMACS performs a given Xaction. In this case, let's specify an argument of 10 and hit the tab Xkey. X XNow hit the tab key again and type @b{Test}. Notice the word now Xappears at the tenth column. Now move to the beginning of the word and Xdelete the backward character. "Test" moves back by one character. X XEMACS behaves differently in these circumstances because the @b(^I) X@index(tab handling) @i(handle-tab) @index(handle-tab) function deals Xwith tabbing in two distinct ways. In default conditions, or if the Xnumeric argument of zero is used, @i(handle-tab) inserts a true tab Xcharacter. If, however, a non-zero numeric argument is specified, X@i(handle-tab) inserts the correct number of spaces needed to position Xthe cursor at the next specified tab position. It does NOT insert the Xsingle tab character and hence any editing functions should take account Xof the number of spaces between tabbed columns. X XMany times you would like to take a line which has been created using Xthe tab character and change it to use just spaces. The command X@b(^X-^D) @i(detab-line) @index(detab-line) changes any tabs from the Xpoint to the end of the current line into the right number of spaces so Xthe line does not change. This is very useful for times when the file Xmust be printed or transfered to a machine which does not understand Xtabs. X XAlso, the inverse command, @b(^X-^E) @i(entab-lines) @index(entab-lines) Xchanges multiple spaces to tabs where possible. This is a good way to Xshrink the size of large documents, especially with data tables. Both Xof these commands can take a numeric argument which will be interpeted Xas the number of lines to en/detab. X@newpage X@heading(Chapter @value(chapter) Summary) X XIn Chapter @value(chapter) introduced some of the formatting features of XEMACS. Text-wrap, paragraph reformatting, and tabs were discussed in Xsome detail. The commands in the following table were covered in the Xchapter. X X@begin{verbatim} X X@u(Key Binding Keystroke Effect) XAdd-Mode/WRAP @b{^X-M}[WRAP] Add wrap mode to current buffer X XDelete-Mode/WRAP @b{^X-^M}[WRAP] Remove wrap mode from current buffer X XSet-Fill-Column @b{^X-F} Set fill column to given numeric X argument X XFill-Paragraph @b{M-Q} Logically reformats the current X paragraph X XCase-Word-Upper @b{M-U} Text from point to end of the X current word is changed to uppercase X XCase-Word-Lower @b{M-L} Text from point to end of the X current word is changed to lowercase X XCase-Word-Capitalize @b{M-C} First word (or letter) after the X point is capitalized X XCase-Region-Upper @b{^X-^U} The current region is uppercased X XCase-Region-Lower @b{^X-^L} The current region is lowercased X XHandle-Tab @b{^I} Tab interval is set to the given X numeric argument XEntab-Line @b(^X-^E) Changes multiple spaces to tabs X characters where possible XDetab-Line @b(^X-^D) Changes tab characters to the X appropriate number of spaces X@end{verbatim} X@chapter(Access to the Outside World) X X EMACS has the ability to interface to other programs and the Xenvironment of the computer outside of itself. It does this through a Xseries of commands that allow it to talk to the computer's @b(command Xprocessor) @index(command processor) or @b(shell) @index(shell). Just Xwhat this is varies between different computers. Under MSDOS or PCDOS Xthis is the @b(command.com) @index(command.com) command processor. XUnder UNIX it is the @b(csh) @index(cshell) shell. On the Atari ST is Xcan be the Mark Williams @b(MSH) or the Beckmeyer shell. In each case, Xit is the part of the computer's operating system that is responcable Xfor determining what programs are executed, and when. X X The @b(^X-!) @i(shell-command) @index(shell-command) command Xprompts the user for a command line to send out to the shell to execute. XThis can be very useful for doing file listings and changing the Xcurrent directory or folder. EMACS gives control to the shell, which Xexecuted the command, and then types @b([END]) and waits for the user to Xtype a character before redrawing the screen and resuming editing. If Xthe @i(shell-command) command is used from within the macro language, Xthere is no pause. X X @b(^X-@@) @i(pipe-command) @index(pipe-command) command allows XEMACS to execute a shell command, and if the particular computer allows Xit, send the results into a buffer which is automatically displayed on Xthe screen. The resulting buffer, called "command" can be manipulated Xjust like any other editing buffer. Text can be copied out of it or Xrearanged as needed. This buffer is originally created in @b(VIEW) mode, Xso remember to @b(^X-^Mview<NL>) in order to change it. X X Many computers provide tools which will allow you to @b(filter) X@index(filter) text, making some modifications to it along the way. A Xvery common tool is the @b(SORT) program which accepts a file, sorts it, Xand prints the result out. The EMACS command, @b(^X-#) @i(filter-buffer) Xsends the current buffer through such a filter. Therefore, if you Xwished to sort the current buffer on a system which supplied a sort Xfilter, you would type @b(^X-#sort<NL>). You can also create your own Xfilters by writing programs and utilities which read text from the Xkeyboard and display the results. EMACS will use any of these which Xwould normally be available from the current shell. X X If you would like to execute another program directly, without Xthe overhead of an intervening shell, you can use the @b(^X-$) X@i(execute-program) @index(execute-program) command. It will prompt you Xfor an external program and its arguments and attempt to execute it. XLike when EMACS looks for command files, EMACS will look first in the XHOME directory, then down the execute PATH, and finally in the current Xdirectory for the named program. On some systems, it will automatically Xtack the proper extension on the file name to indicate it is a program. XOn some systems that don't support this function, @b(^X-$) will be Xequivalent to @b(^X-!) @i(shell-command). X X Sometimes, you would like to get back to the shell and execute Xother commands, without losing the current contents of EMACS. The X@b(^X-C) @i(i-shell) @index(i-shell) command shells out of EMACS, Xleaving EMACS in the computer and executing another command shell. Most Xsystems would allow you to return to EMACS with the "exit" command. X X@i( On some systems, mainly advanced versions of UNIX, you can Xdirect EMACS to "go into the background" with the @b(^X-D) suspend-emacs X@index(suspend-emacs) command. This places EMACS in the background Xreturning you to the original command shell. EMACS can then be returned Xto at any time with the "fg" foreground command.) X@newpage X@heading(Chapter @value(chapter) Summary) X XIn Chapter @value(chapter) introduced different ways to access the Xcomputers shell or command processor from within EMACS. The commands Xin the following table were covered in the chapter. X X@begin{verbatim} X X@u(Key Binding Keystroke Effect) XExecute-program @b(^X-$) Execute an external program X directly X XFilter-command @b(^X-#) Send the current buffer through X a shell filter X XI-shell @b(^X-C) Escape to a new shell X XPipe-command @b(^X-@@) Send the results of an external X shell command to a buffer X XShell-command @b(^X-!) Execute one shell command X XSuspend-emacs @b(^X-D) Place EMACS in the background X (some UNIX systems only) X@end{verbatim} X@chapter(Keyboard Macros) X XIn many applications, it may be necessary to repeat a series of Xcharacters or commands frequently. For example, a paper may require the Xfrequent repetition of a complex formula or a long name. You may also Xhave a series of EMACS commands that you invoke frequently. Keyboard Xmacros offer a convenient method of recording and repeating these Xcommands. X XImagine, for example, you are writing a scholarly paper on @i{Asplenium Xplatyneuron}, the spleenwort fern. Even the dedicated botanist would Xprobably find it a task bordering on the agonizing to type X@i{Asplenium platyneuron} frequently throughout the paper. An Xalternative method is 'record' the name in a keyboard macro. Try it Xyourself. X XThe command @b{^X-(} @i(begin-macro) @index(begin-macro) starts Xrecording the all the keystrokes and commands you input. After you've Xtyped it, enter @b{Asplenium platyneuron}. To stop recording, type X@b{^X-)} @i(end-macro) @index(end-macro). EMACS has stored all the Xkeystrokes between the two commands. To repeat the name you've stored, Xjust enter @b{^X-E} @i(execute-macro) @index(execute-macro), and the Xname "Asplenium platyneuron" appears. You can repeat this action as Xoften as you want, and of course as with any EMACS command, you may Xprecede it with a numerical argument. X XBecause EMACS records keystrokes, you may freely intermix commands and Xtext. Unfortunately, you can only store one macro at a time. Thus, if Xyou begin to record another macro, the previously defined macro is Xlost. Be careful to ensure that you've finished with one macro before Xdefining another. If you have a series of commands that you would like Xto 'record' for future use, use the macro or procedure facilities Xdetailed in chapter <X>. X@newpage X@heading(Chapter @value(chapter) Summary) X XChapter @value(chapter) covered keyboard macros. You learned how to Xrecord keystrokes and how to repeat the stored sequence. X X@begin{verbatim} X@u(Key Binding Keystroke Effect) X XStart-Macro @b{^X-(} Starts recording all keyboard input X XEnd-Macro @b{^X-)} Stops recording keystrokes for macro X XExecute-Macro @b{^X-E} Entire sequence of recorded X keystrokes is replayed X@end{verbatim} X@chapter(MicroEMACS Macros) X X Macros are programs that are used to customize the editor and to Xperform complicated editing tasks. They may be stored in files or Xbuffers and may be executed using an appropriate command, or bound to a Xparticular keystroke. Portions of the standard start-up file are Ximplemented via macros, as well as the example menu system. The X@i(execute-macro-<n>) @index(execute-macro-<n>) commands cause the Xmacro, numbered from 1 to 40, to be executed. The @i(execute-file) X@index(execute-file) command allows you to execute a macro stored in a Xdisk file, and the @i(execute-buffer) @index(execute-buffer) command Xallows you to execute a macro stored in a buffer. Macros are stored for Xeasy execution by executing files that contain the store-macro command. X X If you need more than 40 macros, named macroes, called X@b(procedures), @index(procedures) can be used. The @i(store-procedure) X@index(store-procedure) command takes a string argument which is the Xname of a procedure to store. These procedures than can be executed Xwith the @b(M-^E) @i(execute-procedure) @index(execute-procedure) or the X@i(run) @index(run) commands. X X There are many different aspects to the macro language within XMicroEMACS. Editor commands are the various commands that manipulate Xtext, buffers, windows, etc, within the editor. Directives are commands Xwhich control what lines get executed within a macro. Also there are Xvarious types of variables. Environmental variables both control and Xreport on different aspects of the editor. User variables hold string Xvalues which may be changed and inspected. Buffer variables allow text Xto be placed into variables. Interactive variable allow the program to Xprompt the user for information. Functions can be used to manipulate Xall these variables. X X@section(Constants) X X All constants and variable contents in EMACS are stored as Xstrings of characters. Numbers are stored digit by digit as characters. XThis allows EMACS to be "typeless", not having different variables types Xbe legal in different contexts. This has the disadvantage of forcing the Xuser to be more carefull about the context of the statements variables Xare placed in, but in turn gives them more flexibility in where they Xcan place variables. Needless to say, this also allows EMACS's expression Xevaluator to be both consice and quick. X X Wherever statements need to have arguments, it is legal to place Xconstants. A constant is a double quote character, followed by a string Xof characters, and terminated by another double quote character. To Xrepresent various special characters within a constant, the tilde (~) Xcharacter is used. The character following the tilde is interpeted Xaccording to the following table: X X@begin(verbatim) X@u(Sequence Result) X~n ^J linefeed/newline, (EMACS newline character) X~r ^M carraige return X~~ ~ X~b ^H backspace X~f ^L formfeed X~t ^I tab X~" " X@end(verbatim) X X Any character not in the table which follows a tilde will be Xpassed unmodified. This action is similar to the @b(^Q) X@i(quote-character) command available from the keyboard. X X The double quotes around constants are not needed if the Xconstant contains no internal whitespace and it also does not happen to Xmeet the rules for any other EMACS commands, directives, variables, or Xfunctions. This is reasonable useful for numeric constants. X X@section(Variables) X X Variables in MicroEMACS can be used to return values within Xexpressions, as repeat counts to editing commands, or as text to be Xinserted into buffers and messages. The value of these variables is set Xusing the set (^X-A) command. For example, to set the current fill Xcolumn to 64 characters, the following macro line would be used: X X set $fillcol 64 X X or to have the contents of @b(%name) inserted at the point in the Xcurrent buffer, the command to use would be: X X insert-string %name X@newpage X@subsection(Environmental Variables) X X "What good is a quote if you can't change it?" X X These variables are used to change different aspects of the way Xthe editor works. Also they will return the current settings if used as Xpart of an expression. All environmental variable names begin with a Xdollar sign ($) and are in lower case. X X@begin(description) X$acount@\The countdown of inserted characters until the next save-file. X X$asave@\The number of inserted characters between automatic file-saves Xin ASAVE mode. X X$cbufname@\Name of the current buffer X X$cfname@\File name of the current buffer X X$cmode@\Integer containing the mode of the current buffer. (See Appendix F Xfor values) X X$curchar@\Character currently at the point X X$curcol@\Current column of point in current buffer X X$curline@\Current line of point in current buffer X X$curwidth@\Number of columns used currently X X$cwline@\Current display line in current window X X$debug@\Flag to trigger macro debugging (try it... you'll like it!) X X$discmd@\Flag to disable the echoing of messages on the command line X X$disinp@\Flag to disable the echoing of characters during command line input X X$fillcol@\Current fill column X X$flicker@\Flicker Flag set to TRUE if IBM CGA set to FALSE for most others X X$gflags@\Global flags controlling some EMACS internal functions (See Xappendix G for details) X X$gmode@\Global mode flags. (See Appendix F for values) X X$lastkey@\[READ ONLY]Last keyboard character typed X X$line@\The current line in the current buffer can be retrieved and Xset with this environment variable X X$lwidth@\[READ ONLY]Returns the number of characters in the current line X X$match@\[READ ONLY]Last string matched in a magic mode search X X$pagelen@\Number of screen lines used currently X X$palette@\string used to control the palette register settings on Xgraphics versions. The usually form consists of groups of three octal Xdigits setting the red, green, and blue levels. X X$pending@\[READ ONLY]Flag to determine if there are user keystrokes Xwaiting to be processed. X X$progname@\[READ ONLY]Always contains the string "MicroEMACS" for Xstandard MicroEMACS. Could be something else if EMACS is incorporated Xas part of someone else's program X X$replace@\Current default replace string X X$rval@\This contains the return value from the last subprocess which was Xinvoked from EMACS X X$search@\Current default search string X X$seed@\Integer seed of the random number generator X X$sres@\Current screen resolution (CGA, MONO or EGA on the IBM-PC driver. XLOW, MEDIUM, HIGH or DENSE on the Atari ST1040, NORMAL on all others) X X$status@\[READ ONLY]Status of the success of the last command (TRUE or XFALSE). This is usually used with !force to check on the success of a Xsearch, or a file operation. X X$target@\Current target for line moves (setting this fool's EMACS into Xbelieving the last command was a line move) X X$tpause@\Controls the length of the pause to display a matched fence Xwhen the current buffer is in CMODE and a close fence has been typed X X$version@\[READ ONLY]Contains the current MicroEMACS version number X X$wline@\Number of display lines in current window X@end(description) X X Obviously, many more of these variables will be availible in Xfuture releases of MicroEMACS. (Yes, send a vote for your favorite new Xenvironmental variables today). X X@subsection(User variables) X X User variables allow you, the user, to store strings and Xmanipulate them. These strings can be pieces of text, numbers (in text Xform), or the logical values @b(TRUE) and @b(FALSE). These variables Xcan be combined, tested, inserted into buffers, and otherwise used to Xcontrol the way your macros execute. At the moment, up to 255 user Xvariables may be in use in one editing session. All users variable Xnames must begin with a percent sign (%) and may contain any printing Xcharacters. Only the first 10 characters are significant (ie Xdifferences beyond the tenth character are ignored). Most operators Xwill truncate strings to a length of 128 characters. X X@subsection(Buffer Variables) X X Buffer variables are special in that they can only be queried Xand cannot be set. What buffer variables are is a way to take text from Xa buffer and place it in a variable. For example, if I have a buffer by Xthe name of RIGEL2, and it contains the text: X X@begin(verbatim) X@begin(group) X Richmond X Lafayette X <*>Bloomington (where <*> is the current point) X Indianapolis X Gary X =* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt ===== X@end(group) X@end(verbatim) X X and within a command I reference #rigel2, like: X X insert-string #rigel2 X X MicroEMACS would start at the current point in the RIGEL2 Xbuffer and grab all the text up to the end of that line and pass that Xback. Then it would advance the point to the beginning of the next line. XThus, after our last command executes, the string "Bloomington" gets Xinserted into the current buffer, and the buffer RIGEL2 now looks like Xthis: X X@begin(verbatim) X@begin(group) X Richmond X Lafayette X Bloomington X <*>Indianapolis (where <*> is the current point) X Gary X =* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt ===== X@end(group) X@end(verbatim) X X as you have probably noticed, a buffer variable consists of the Xbuffer name, preceded by a pound sign (#). X X@subsection(Interactive variables) X X Interactive variables are actually a method to prompt the user Xfor a string. This is done by using an at sign (@@) followed either with Xa quoted string, or a variable containing a string. The string is the Xplaced on the bottom line, and the editor waits for the user to type in Xa string. Then the string typed in by the users is returned as the Xvalue of the interactive variable. For example: X X@begin(verbatim) X set %quest "What file? " X find-file @@%quest X@end(verbatim) X X will ask the user for a file name, and then attempt to find it. XNote also that complex expressions can be built up with these Xoperators, such as: X X@verbatim(@@&cat &cat "File to decode[" %default "]: ") X X which prompts the user with the concatinated string. X X@section(Functions) X X Functions can be used to manipulate variables in various ways. XFunctions can have one, two, or three arguments. These arguments will Xalways be placed after the function on the current command line. For Xexample, if we wanted to increase the current fill column by two, using Xemacs's set (^X-A) command, we would write: X X@begin(group) X@begin(verbatim) X set $fillcol &add $fillcol 2 X \ \ \ \ \____second operand X \ \ \ \_________first operand X \ \ \_______________function to execute X \ \_____________________variable to set X \___________________________set (^X-A) command X@end(verbatim) X@end(group) X X Function names always begin with the ampersand (&) character, Xand are only significant to the first three characters after the Xampersand. Functions will normal expect one of three types of Xarguments, and will automatically convert types when needed. X X@begin(description) X<num>@\an ascii string of digits which is interpeted as a numeric value. XAny string which does not start with a digit or a minus sign (-) will be Xconsidered zero. X X<str>@\An arbitrary string of characters. At the moment, strings are Xlimited to 128 characters in length. X X<log>@\A logical value consisting of the string "TRUE" or "FALSE". XNumeric strings will also evaluate to "FALSE" if they are equal to zero, Xand "TRUE" if they are non-zero. Arbitrary text strings will have the Xvalue of "FALSE". X@end(description) X X A list of the currently availible functions follows: (Once Xagain, send in those votes on what kind of functions you would like to Xsee added!) Functions are always used in lower case, the uppercase Xletters in the function table are the short form of the function (ie X&div for ÷). X X@begin(verbatim) XNumeric Functions: (returns <num>) X X&ADD <num> <num> Add two numbers X&SUB <num> <num> Subtract the second number from the first X&TIMes <num> <num> Multiply two numbers X&DIVide <num> <num> Divide the first number by the second X giving an integer result X&MOD <num> <num> Return the reminder of dividing the X first number by the second X&NEGate <neg> Multiply the arg by -1 X&LENgth <str> Returns length of string X&SINdex <str1> <str2> Finds the position of <str2> within X <str1>. Returns zero if not found. X&ASCii <str> Return the ascii code of the first X character in <str> X&RND <num> Returns a random integer between 1 and <num> X&ABS <num> Returns the absolute value of <num> X&BANd <num> <num> Bitwise AND function X&BOR <num> <num> Bitwise OR function X&BXOr <num> <num> Bitwise XOR function X&BNOt <num> Bitwise NOT function X XString manipulation functions: (returns <str>) X X&CAT <str> <str> Concatinate the two strings to form one X&LEFt <str> <num> return the <num> leftmost characters X from <str> X&RIGht <str> <num> return the <num> rightmost characters X from <str> X&MID <str> <num1> <num2> X Starting from <num1> position in <str>, X return <num2> characters. X&UPPer <str> Uppercase <str> X&LOWer <str> lowercase <str> X&CHR <num> return a string with the character X represented by ascii code <num> X>K return a string containing a single X keystroke from the user X&ENV <str> If the operating system is capable, this X returns the environment string associated X with <str> X&BIND <str> return the function name bound to the X keystroke <str> X&ENV <str> Returns the operating system value X attached to environmental variable <str> X&FINd <str> Find the named file <str> along the X path and return its full file specification X or an empty string if none exists X XLogical Testing functions: (returns <log>) X X&NOT <log> Return the opposite logical value X&AND <log1> <log2> Returns TRUE if BOTH logical arguments X are TRUE X&OR <log1> <log2> Returns TRUE if either argument X is TRUE X&EQUal <num> <num> If <num> and <num> are numerically X equal, return TRUE X&LESs <num1> <num2> If <num1> is less than <num2>, return X TRUE. X&GREater <num1> <num2> If <num1> is greater than, or equal to X <num2>, return TRUE. X&SEQual <str1> <str2> If the two strings are the same, return X TRUE. X&SLEss <str1> <str2> If <str1> is less alphabetically than X <str2>, return TRUE. X&SGReater <str1> <str2> If <str1> is alphabetically greater than X or equal to <str2>, return TRUE. X&FINd <str> Does the named file <str> exist? X XSpecial Functions: X X&INDirect <str> Evaluate <str> as a variable. X@end(verbatim) X X This last function deserves more explanation. The &IND function Xevaluates its argument, takes the resulting string, and then uses it as Xa variable name. For example, given the following code sequence: X X@begin(verbatim) X ; set up reference table X X set %one "elephant" X set %two "giraffe" X set %three "donkey" X X set %index "two" X insert-string &ind %index X@end(verbatim) X X the string "giraffe" would have been inserted at the point in Xthe current buffer. This indirection can be safely nested up to about X10 levels. X X@section(Directives) X X Directives are commands which only operate within an executing Xmacro, ie they do not make sense as a single command. As such, they Xcannot be called up singly or bound to keystroke. Used within macros, Xthey control what lines are executed and in what order. X X Directives always start with the exclamation mark (!) character Xand must be the first thing placed on a line. Directives executed Xinteractively (via the execute-command-line command) will be ignored. X X@subsection(!ENDM Directive) X X This directive is used to terminate a macro being stored. For Xexample, if a file is being executed contains the text: X X@begin(verbatim) X ; Read in a file in view mode, and make the window red X X 26 store-macro X find-file @@"File to view: " X add-mode "view" X add-mode "red" X !endm X X write-message "[Consult macro has been loaded]" X@end(verbatim) X X only the lines between the store-macro command and the !ENDM Xdirective are stored in macro 26. Both numbered macroes and named Xprocedures (via the @i(store-procedure) command) should be terminated with Xthis directive. X X@subsection(!FORCE Directive) X X When MicroEMACS executes a macro, if any command fails, the Xmacro is terminated at that point. If a line is preceeded by a !FORCE Xdirective, execution continues weather the command succeeds or not. For Xexample: X X@begin(verbatim) X ; Merge the top two windows X X save-window ;remember what window we are at X 1 next-window ;go to the top window X delete-window ;merge it with the second window X !force restore-window ;This will continue regardless X add-mode "red" X@end(verbatim) X X@subsection(!IF, !ELSE, and !ENDIF Directives) X X This directive allows statements only to be executed if a Xcondition specified in the directive is met. Every line following the X!IF directive, until the first !ELSE or !ENDIF directive, is only Xexecuted if the expression following the !IF directive evaluates to a XTRUE value. For example, the following macro segment creates the Xportion of a text file automatically. (yes believe me, this will be Xeasier to understand then that last explanation....) X X@begin(verbatim) X !if &sequal %curplace "timespace vortex" X insert-string "First, rematerialize~n" X !endif X !if &sequal %planet "earth" ;If we have landed on earth... X !if &sequal %time "late 20th century" ;and we are then X write-message "Contact U.N.I.T." X !else X insert-string "Investigate the situation....~n" X insert-string "(SAY 'stay here Sara')~n" X !endif X !else X set %conditions @@"Atmosphere conditions outside? " X !if &sequal %conditions "safe" X insert-string &cat "Go outside......" "~n" X insert-string "lock the door~n" X !else X insert-string "Dematerialize..try somewhen else" X newline X !endif X !endif X@end(verbatim) X X@subsection(!GOTO Directive) X X Flow can be controlled within a MicroEMACS macro using the !GOTO Xdirective. It takes as an argument a label. A label consists of a line Xstarting with an asterisk (*) and then an alphanumeric label. Only Xlabels in the currently executing macro can be jumped to, and trying to Xjump to a non-existing label terminates execution of a macro. For Xexample.. X X@begin(verbatim) X ;Create a block of DATA statements for a BASIC program X X insert-string "1000 DATA " X set %linenum 1000 X X *nxtin X update-screen ;make sure we see the changes X set %data @@"Next number: " X !if &equal %data 0 X !goto finish X !endif X X !if &greater $curcol 60 X 2 delete-previous-character X newline X set %linenum &add %linenum 10 X insert-string &cat %linenum " DATA " X !endif X X insert-string &cat %data ", " X !goto nxtin X X *finish X X 2 delete-previous-character X newline X@end(verbatim) X X@subsection(!WHILE and !ENDWHILE Directives) X X This directive allows you to set up repetitive tasks easily and Xefficiently. If a group of statements need to be executed while a Xcertain condition is true, enclose them with a while loop. For example, X X@begin(verbatim) X !while &less $curcol 70 X insert-string &cat &cat "[" #stuff "]" X !endwhile X@end(verbatim) X X places items from buffer "item" in the current line until the Xcursor is at or past column 70. While loops may be nested and can Xcontain and be the targets of !GOTOs with no ill effects. Using a while Xloop to enclose a repeated task will run much faster than the Xcorresponding construct using !IFs. X X@subsection(!BREAK Directive) X X This directive allows the user to abort out of the currently Xmost inner while loop, regardless of the condition. It is often used Xto abort processing for error conditions. For example: X X@begin(verbatim) X; Read in files and substitute "begining" with "beginning" X X set %filename #list X !while ¬ &seq %filename "<end>" X!force find-file %filename X !if &seq $status FALSE X write-message "[File read error]" X !break X !endif X beginning-of-file X replace-string "begining" "beginning" X save-file X set %filename #list X !endwhile X@end(verbatim) X X This while loop will process files until the list is exhausted Xor there is an error while reading a file. X X@subsection(!RETURN Directive) X X The !RETURN Directive causes the current macro to exit, either Xreturning to the caller (if any) or to interactive mode. For example: X X@begin(verbatim) X ; Check the monitor type and set %mtyp X X !if &sres "CGA" X set %mtyp 1 X !return X !else X set %mtyp 2 X !endif X X insert-string "You are on a MONOCHROME machine!~n" X@end(verbatim) X@appendix(MicroEMACS Command Line Switches and Startup Files) X X@index(startup files) X When EMACS first executes, it always searches for a file, Xcalled @b(.emacsrc) @i(under most UNIX systems) or @b(emacs.rc) @i(on Xmost other systems) @index(emacs.rc) @index(.emacsrc) which it will Xexecute as EMACS macros before it reads in the named source files. This Xfile normally contains EMACS macroes to bind the function keys to Xuseful functions and load various usefull macros. The contents of this Xfile will probably vary from system to system and can be modified by the Xuser as desired. X X When searching for this file, EMACS looks for it in this order. XFirst, it attempts to find a definition for "@b(HOME)" in the Xenvironment. It will look in that directory first. Therwuffersmacro)
nwd@j.cc.purdue.edu (Daniel Lawrence) (11/26/87)
Xall the directories listed in the "@b(PATH)" environment variable. Then Xit looks through a list of predefined standard directories which vary Xfrom system to system. Finally, failing all of these, it looks in the Xcurrent directory. This is also the same method EMACS uses to look up Xany files to execute, and to find it's help file @b(EMACS.HLP). X@index(PATH environment variable) @index(HOME environment variable) X@index(Help File) X X@index(switches) X On computers that call up EMACS via a command line process, such Xas MSDOS and UNIX, there are different things that can be added to the Xcommand line to control the way EMACS operates. These can be switches, Xwhich are a dash ('-') followed by a letter, and possible other Xparameters, or a startup file specifier, which is an at sign '@@' Xfollowed by a file name. X X@begin(description) X@@<file>@\This causes the named file to be executed instead of the Xstandard emacs.rc file before emacs reads in any other files. More than Xone of these can be placed on the command line, and they will be Xexecuted in the order that they appear. X X-A@\This flag causes emacs to automatically run the startup file X"error.cmd" instead of emacs.rc. This is used by various C compilers for Xerror processing (for example, Mark Williams C). @index(error parsing) X X-E@\The following source files on the command line can be edited (as Xopposed to being in VIEW mode). This is mainly used to cancel the Xeffects of the -v switch used previously in the same command line. X X-G<num>@\Upon entering EMACS, position the cursor at the <num> line of Xthe first file. X X-K<key>@\This key tells emacs to place the source files in CRYPT X@index(CRYPT mode) mode and read it in using <key> as the encryption Xkey. If no key is listed immediatly after the -K switch, EMACS will Xprompt for a key, and not echo it as it is typed. X X-R@\This places EMACS in "restricted mode"@index(restricted mode) X@index(BBS) where any commands allowing the user to read or write any Xfiles other than the ones listed on the command line are disabled. Also Xall commands allowing the user access to the operating system are Xdisabled. This makes EMACS very useful as a "safe" environment for use Xwithin other applications and especially used as a remote editor for a XBBS or electronic bulletin board system. X X-S<string>@\After EMACS is started, it automatically searches for X<string> in the first source file. X X-V@\This tells EMACS that all the following sources files on the command Xline should be in VIEW mode to prevent any changes being made to them. X@end(description) X@appendix(MicroEMACS commands) X X Below is a complete list of the commands in EMACS, the keys Xnormally used to do the command, and what the command does. Remember, Xon some computers there may also be additional ways of using a command X(cursor keys and special function keys for example). X X@begin(verbatim) X@u(Command Binding Meaning) Xabort-command ^G This allows the user to abort out of any X command that is waiting for input X Xadd-mode ^X-M Add a mode to the current buffer X Xadd-global-mode M-M Add a global mode for all new buffers X Xapropos M-A List out commands whose name contains X the string specified X Xbackward-character ^B Move one character to the left X Xbegin-macro ^X-( Begin recording a keyboard macro X Xbeginning-of-file M-< Move to the beginning of the file in X the current buffer X Xbeginning-of-line ^A Move to the beginning of the current line X Xbind-to-key M-K Bind a key to a function X Xbuffer-position ^X-= List the position of the cursor in the X current window on the command line X Xcase-region-lower ^X-^L Make a marked region all lower case X Xcase-region-upper ^X-^U Make a marked region all upper case X Xcase-word-capitalize M-C Capitalize the following word X Xcase-word-lower M-L Lower case the following word X Xcase-word-upper M-U Upper case the following word X Xchange-file-name ^X-N Change the name of the file in the X current buffer X Xchange-screen-size M-^S Change the number of lines of the screen X currently being used X Xchange-screen-width M-^T Change the number of columns of the X screen currently being used X Xclear-and-redraw ^L Clear the physical screen and redraw it X Xclear-message-line (none) Clear the command line X Xcopy-region M-W Copy the currently marked region into X the kill buffer X Xcount-words M-^C Count how many words, lines and X characters are in the current marked region X Xctlx-prefix ^X Change the key used as the ^X prefix X Xdelete-blank-lines ^X-^O Delete all blank lines around the cursor X Xdelete-buffer ^X-K Delete a buffer which is not being X currently displayed in a window X Xdelete-mode ^X-^M Turn off a mode in the current buffer X Xdelete-global-mode M-^M Turn off a global mode X Xdelete-next-character ^D Delete the character following the cursor X Xdelete-next-word M-D Delete the word following the cursor X Xdelete-other-windows ^X-1 Make the current window cover the entire X screen X Xdelete-previous-character^H Delete the character to the left of the X cursor X Xdelete-previous-word M-^H Delete the word to the left of the cursor X Xdelete-window ^X-0 Remove the current window from the screen X Xdescribe-bindings (none) Make a list of all legal commands X Xdescribe-key ^X-? Describe what command is bound to a X keystroke sequence X Xdetab-line ^X-^D Change all tabs in a line to the X equivelant spaces X Xend-macro ^X-) stop recording a keyboard macro X Xend-of-file M-> Move cursor to the end of the current buffer X Xend-of-line ^E Move to the end of the current line X Xentab-line ^X-^E Change multiple spaces to tabs where X possible X Xexchange-point-and-mark ^X-^X Move cursor to the last marked spot, X make the original position be marked X Xexecute-buffer (none) Execute a buffer as a macro X Xexecute-command-line (none) Execute a line typed on the command X line as a macro command X Xexecute-file FNB Execute a file as a macro X Xexecute-macro ^X-E Execute the keyboard macro (play back X the recorded keystrokes) Xexecute-macro-<n> (none) Execute numbered macro <N> where <N> is X an integer from 1 to 40 X Xexecute-named-command M-X Execute a command by name X Xexecute-procedure M-^E Execute a procedure by name X Xexecute-program ^X-$ Execute a program directly (not through X an intervening shell) X Xexit-emacs ^X-^C Exit EMACS. If there are unwritten, X changed buffers EMACS will ask to confirm X Xfill-paragraph M-Q Fill the current paragraph X Xfilter-buffer ^X-# Filter the current buffer through an X external filter X Xfind-file ^X-^F Find a file to edit in the current window X Xforward-character ^F Move cursor one character to the right X Xgoto-line M-G Goto a numbered line X Xgoto-matching-fence M-^F Goto the matching fence X Xgrow-window ^X-^ Make the current window larger X Xhandle-tab ^I Insert a tab or set tab stops X Xhunt-forward FN= Hunt for the next match of the last X search string X Xhunt-backward FN> Hunt for the last match of the last X search string X Xhelp M-? Read EMACS.HLP into a buffer and display it X Xi-shell ^X-C Shell up to a new command processor X Xincremental-search ^X-S Search for a string, incrementally X Xinsert-file ^X-^I insert a file at the cursor in the X current file X Xinsert-space ^C Insert a space to the right of the cursor X Xinsert-string (none) Insert a string at the cursor X Xkill-paragraph M-^W Delete the current paragraph X Xkill-region ^W Delete the current marked region, moving X it to the kill buffer X Xkill-to-end-of-line ^K Delete the rest of the current line X Xlist-buffers ^X-^B List all existing buffers X Xmeta-prefix <ESC> Key used to precede all META commands X Xmove-window-down ^X-^N Move all the lines in the current window down X Xmove-window-up ^X-^P Move all the lines in the current window up X Xname-buffer M-^N Change the name of the current buffer X Xnewline ^M Insert a <NL> at the cursor X Xnewline-and-indent ^J Insert a <NL> at the cursor and indent X the new line the same as the preceeding line X Xnext-buffer ^X-X Bring the next buffer in the list into X the current window X Xnext-line ^N Move the cursor down one line X Xnext-page ^V Move the cursor down one page X Xnext-paragraph M-N Move cursor to the next paragraph X Xnext-window ^X-O Move cursor to the next window X Xnext-word M-F Move cursor to the beginning of the X next word X Xnop M-FNC Does nothing X Xopen-line ^O Open a line at the cursor X Xoverwrite-string (none) Overwrite a string at the cursor X Xpipe-command ^X-@@ Execute an external command and place X its output in a buffer X Xprevious-line ^P Move cursor up one line X Xprevious-page ^Z Move cursor up one page X Xprevious-paragraph M-P Move back one paragraph X Xprevious-window ^X-P Move the cursor to the last window X Xprevious-word M-B Move the cursor to the beginning of the X word to the left of the cursor X Xquery-replace-string M-^R Replace all of one string with another X string, interactively querying the user X Xquick-exit M-Z Exit EMACS, writing out all changed buffers X Xquote-character ^Q Insert the next character literally X Xread-file ^X-^R Read a file into the current buffer X Xredraw-display M-^L Redraw the display, centering the X current line X Xresize-window ^X-W Change the number of lines in the X current window X Xrestore-window (none) Move cursor to the last saved window X Xreplace-string M-R Replace all occurences of one string X with another string from the cursor X to the end of the buffer X Xreverse-incremental-search^X-R Search backwards, incrementally X Xrun M-^E Execute a named procedure X Xsave-file ^X-^S Save the current buffer if it is changed X Xsave-window (none) Remember current window (to restore later) X Xscroll-next-up M-^Z Scroll the next window up X Xscroll-next-down M-^V Scroll the next window down X Xsearch-forward ^S Search for a string X Xsearch-reverse ^R Search backwards for a string X Xselect-buffer ^X-B Select a buffer to display in the X current window X Xset ^X-A Set a variable to a value X Xset-encryption-key M-E Set the encryption key of the current buffer X Xset-fill-column ^X-F Set the current fill column X Xset-mark Set the mark X Xshell-command ^X-! Causes an external shell to execute X a command X Xshrink-window ^X-^Z Make the current window smaller X Xsplit-current-window ^X-2 Split the current window in two X Xstore-macro (none) Store the following macro lines to a X numbered macro X Xstore-procedure (none) Store the following macro lines to a X named procedure X Xtranspose-characters ^T Transpose the character at the cursor X with the character to the left X Xtrim-line ^X-^T Trim any trailing whitespace from line X Xunbind-key M-^K Unbind a key from a function X Xuniversal-argument ^U Execute the following command 4 times X Xunmark-buffer M-~ Unmark the current buffer (so it is X no longer changed) X Xupdate-screen (none) Force a screen update during macro execution X Xview-file ^X-^V Find a file,and put it in view mode X Xwrap-word M-FNW Wrap the current word, this is an X internal function X Xwrite-file ^X-^W Write the current buffer under a new X file name X Xwrite-message (none) Display a string on the command line X Xyank ^Y yank the kill buffer into the current X buffer at the cursor X@end(verbatim) X@appendix(MicroEMACS Bindings) X X Below is a complete list of the key bindings used in MicroEMACS. XThis can be used as a wall chart reference for MicroEMACS commands. X X@begin(verbatim) X@center(@b[Default Key Bindings for MicroEmacs 3.9e]) X X ^A Move to start of line ESC A Apropos (list some commands) X ^B Move backward by characters ESC B Backup by words X ^C Insert space ESC C Initial capitalize word X ^D Forward delete ESC D Delete forward word X ^E Goto end of line ESC E Reset Encryption Key X ^F Move forward by characters ESC F Advance by words X ^G Abort out of things ESC G Go to a line X ^H Backward delete X ^I Insert tab/Set tab stops X ^J Insert <NL>, then indent X ^K Kill forward ESC K Bind Key to function X ^L Refresh the screen ESC L Lower case word X ^M Insert <NL> ESC M Add global mode X ^N Move forward by lines ESC N Goto End paragraph X ^O Open up a blank line X ^P Move backward by lines ESC P Goto Begining of paragraph X ^Q Insert literal ESC Q Fill current paragraph X ^R Search backwards ESC R Search and replace X ^S Search forward X ^T Transpose characters X ^U Repeat command four times ESC U Upper case word X ^V Move forward by pages ESC V Move backward by pages X ^W Kill region ESC W Copy region to kill buffer X ^Y Yank back from killbuffer ESC X Execute named command X ^Z Move backward by pages ESC Z Save all buffers and exit X X ESC ^C Count words in region ESC ~ Unmark current buffer X ESC ^E Execute named procedure X ESC ^F Goto matching fence ESC ! Reposition window X ESC ^H Delete backward word ESC < Move to start of buffer X ESC ^K Unbind Key from function ESC > Move to end of buffer X ESC ^L Reposition window ESC . Set mark X ESC ^M Delete global mode ESC space Set mark X ESC ^N Rename current buffer ESC rubout Delete backward word X ESC ^R Search & replace w/query rubout Backward delete X ESC ^S Change screen rows X ESC ^T Change screen columns X ESC ^V Scroll next window down X ESC ^W Delete Paragraph X ESC ^Z Scroll next window up X X ^X ? Describe a key ^X ! Run 1 command in a shell X ^X = Show the cursor position ^X @@ Pipe shell command to buffer X ^X ^ Enlarge display window ^X # Filter buffer thru shell filter X ^X 0 Delete current window ^X $ Execute an external program X ^X 1 Delete other windows ^X ( Begin macro X ^X 2 Split current window ^X ) End macro X ^X A Set variable value X ^X ^B Display buffer list ^X B Switch a window to a buffer X ^X ^C Exit MicroEMACS ^X C Start a new command processor X ^X ^D Detab line ^X D Suspend MicroEMACS (BSD4.2 only) X ^X ^E Entab line ^X E Execute macro X ^X ^F Find file ^X F Set fill column X ^X ^I Insert file X ^X K Delete buffer X ^X ^L Lower case region X ^X ^M Delete Mode ^X M Add a mode X ^X ^N Move window down ^X N Rename current filename X ^X ^O Delete blank lines ^X O Move to the next window X ^X ^P Move window up ^X P Move to the previous window X ^X ^R Get a file from disk ^X R Incremental reverse search X ^X ^S Save current file ^X S Incremental forward search X ^X ^T Trim line (Incremental search X ^X ^U Upper case region not always availible) X ^X ^V View file X ^X ^W Write a file to disk ^X W resize Window X ^X ^X Swap "." and mark ^X X Use next buffer X ^X ^Z Shrink window ^X Z Enlarge display window X X@u(Usable Modes) XWRAP Lines going past right margin "wrap" to a new line XVIEW Read-Only mode where no modifications are allowed XCMODE Change behavior of some commands to work better with C XEXACT Exact case matching on search strings XOVER Overwrite typed characters instead of inserting them XCRYPT Current buffer will be encrypted on write, decrypted on read XMAGIC Use regular expression matching in searches XASAVE Save the file every 256 inserted characters X XWHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK Sets foreground color Xwhite/cyan/magenta/yellow/blue/red/green/black Sets background color X@end(verbatim) X@newpage X@appendix(Supported machines) X X The following table lists all the hardware/compilers for which I Xcurrently support MicroEMACS. This is not exclusive of all machines Xwhich MicroEMACS will run on, but I have either run it myself, or had a Xfirst hand report of it running. X X@begin(verbatim) X@u(Hardware OS Compiler Comments) XVAX 780 UNIX V5 native X UNIX V7 native X BSD 4.2 native job control supported X *VMS native only some terminals supported X XNCR Tower UNIX V5 native X XFortune 32:16 UNIX V7 native X XIBM-PC MSDOS LATTICE 2.15 Large CODE/Large DATA X 2.0 & 3.2 AZTEC 3.4e Small CODE/Large DATA X TURBO C v1.00 LARGE memory model X *MSC 4.0 X *MWC 86 X SCO XENIX native X XHP150 MSDOS Lattice 2.15 Function key labels X for the touch screen X XHP110 MSDOS Lattice 2.15 X Aztec 3.4e X X*Data General 10 X MSDOS Lattice 2.15 X X*Texas Instruments Professional X MSDOS Lattice 2.15 X XAmiga Intuition Lattice 3.03 no mouse or menus yet X *Aztec 3 X XST520 TOS Mark Williams C Spawns under MSH X Lattice 3.10 (no shell commands) X X@u[Systems to be supported (ie some code is already written:)] XMacintosh Finder 5.0 Aztec X X*means that I do not own or have access to the listed compiler and/or X machine and must rely upon others to help support it. X@end(verbatim) X@newpage X@appendix(Machine Dependent Notes) X X This appendix lists some notes specific to individual Ximplementations of MicroEMACS. Every attempt has been made to allow XEMACS to be identical on all machines, but we have also tried to take Xadvantage of function keys, cursor keys, mice, and special screen modes Xwhere possible. X X@appendixsection(IBM-PC/XT/AT and its clones) X X The IBM-PC family of computers is supported with a variety of Xdifferent display adapters. EMACS will attempt to discover what adapter Xis connected and use the proper driver for it. Below is a list of the Xcurrently supported video adapters: X X@begin(verbatim) X@u(Adapter $sres Original mode used) XMonochrome Graphics Adapter MONO MONO XColor Graphics Adapter CGA CGA XEnhanced Graphics Adapter EGA CGA X@end(verbatim) X X EMACS also takes advantege of various function keys and the keys Xon the keypad on an IBM-PC. The function keys are initially not bound Xto any particular functions (except by the emacs.rc startup file), but Xthe keypad keys do default to the following: X X@begin(verbatim) X@u(Keypad key Function) XHome beginning-of-file XCSRS UP previous-line XPg Up previous-page XCSRS LEFT backward-character XCSRS RIGHT forward-character XEnd end-of-file XCSRS DOWN next-line XPg Dn Next-page X@end(verbatim) X X All these special keys are indicated in EMACS macroes by use of Xthe @b(FN) prefix. Below is a list of many of the keys and the codes Xused to specify them. Also the codes may be gotten by using the Xdescribe-key (^X ?) command on the suspect key. X@newpage X@begin(verbatim) X IBM PC function keys in MicroEmacs X X function Function ^function Alt-function X f1) FN; FNT FN^ FNh X f2) FN< FNU FN_ FNi X f3) FN= FNV FN` FNj X f4) FN> FNW FNa FNk X f5) FN? FNX FNb FNl X f6) FN@@ FNY FNc FNm X f7) FNA FNZ FNd FNn X f8) FNB FN[ FNe FNo X f9) FNC FN\ FNf FNp Xf10) FND FN] FNg FNq X Xhome) FNG FNw XCsUp) FNH XPgUp) FNI FNa(umlaut) {Alt 132} XCsLf) FNK FNs X 5 ) XCsRt) FNM FNt X End) FNO FNu XCsDn) FNP XPgDn) FNQ FNv X Ins) FNR X Del) FNS X@end(verbatim) X@newpage X@appendixsection(HP 150) X X This machine from Hewlett Packard is very unusual for an MSDOS Xmachine. It has a touch screen and is very function key oriented. An Xadditional command, @i(label-function-key)@index(label-function-key) Xallows you to place labels on the on screen function key labels. A Xnumeric argument indicates which function key to label (one through Xeight) and then the program prompts for a 16 character label, which will Xbe used as two lines of eight characters. To label function key three Xwith "save file" from a macro, you would use: X X@verbatim(3 label-function-key "save file") X X Notice the 4 spaces after "save". This forces "file" to begin on Xthe second line of the label. X@newpage X@appendixsection(Atari 520/1040ST) X X The ATARI ST family of computers have a dual personality. They Xmay use either a monochrome or a color screen. EMACS supports two Xscreen resolutions on each monitor. X X@begin(verbatim) X@u(Monitor $sres size #color $palette format) XColor LOW 40x25 16 000111222333444555666777 X MEDIUM 80x25 4 000111222333 XMono HIGH 80x25 2 000 X DENSE 80x50 2 000 X@end(verbatim) X X The $palette environment variable can be used to change what Xcolor is associated with each color name. With a color monitor, each Xgroup of three digits indicates an octal number specifying the RED, XGREEN and BLUE levels of that color. Each color digit can vary from 0 Xto 7. For example, the initial setting of $palette in LOW resolution is: X X@begin(verbatim) X 000700070770007707077777 X X which broken up is: X X 000 700 070 770 007 707 077 777 X X which means: X X 000 Black X 700 Red X 070 Green X 770 Yellow X 007 Blue X 707 Magenta X 077 Cyan X 777 White X@end(verbatim) X X Also the mouse generates FN prefix codes when moved, or when one Xof the two buttons is pressed. Initially the movement of the mouse is Xbound to movement of the cursor, and the left mouse button generates a Xset-mark (M-space) command. The cursor keys and the function keys are Xbound similarly to to IBM-PC. X X Files generated by EMACS on the ATARI ST have a single return Xcharacter at the end of each line, unlike the desktop files which want Xto have tow returns. This makes it display files strangly from GEM's X[SHOW] option, but makes the files port to other computers much nicer. X X Currently, when operating under the Mark Williams MSH program, XEMACS can shell out and perform external commands. This capability will Xbe added later for the Beckmeyer shell and under GEMDOS. X@newpage X@appendixsection(Amiga 1000) X X The Commodore AMIGA 1000 version of MicroEMACS does not have Xextensive support of the mouse or of pull down menus as of yet. It does Xhowever come up in a window, and it is possible to re-size it to run in Xdifferent sized windows. The @b(M-^S) @i(change-screen-size) X@index(change-screen-size) takes its numeric argument as the new number Xof lines for EMACS to use. The @b(M-^T) @i(change-screen-width) X@index(change-screen-width) command allows you to change the number of Xcolumns EMACS will use. The defaults for these are 23 lines and 77 Xcharacters across for a full screen window. X X@center(Note about Compiling MicroEMACS) X X@begin(quotation) X If you are compiling the sources on the AMIGA to produce an Xexecutable image, and you are using the Lattice compiler, be sure to Xgive the CLI command 'STACK 40000' before compiling to make sure the Xcompiler has sufficient stack space to successfully complete Xcompiliation. X@end(quotation) X@newpage X@appendixsection(UNIX V5, V7, and BSD4.[23]) X X MicroEMACS under UNIX utilizes the @b(TERMCAP) @index(termcap) Xlibrary to provide machine independent screen functions. Make sure that Xtermcap is availible and properly set on your account before attempting Xto use MicroEMACS. X X Under systems which support job control, you can use the X@b(^X-D) @i(suspend-emacs) @index(suspend-emacs) command to place EMACS Xinto the background. This carries a much smaller overhead than bringing Xup a new shell under EMACS. EMACS will properly redraw the screen when Xyou bring it back to the foreground. X X If the symbol VT100 has been set to 1 in the @i(estruct.h) Xoptions file, EMACS will recognize the key sequence <ESC>[ as the lead Xin sequence for the FN function key prefix. X X With the addition of some very machine/operating system specific Xcode, EMACS can prevent two or more people from modifying the same file Xat the same time. @index(file locking) The upper level of a set of Xfunctions to provide file locking exist in the source file @b(LOCK.C). XIt requires two machine specific functions written and linked into EMACS Xfor it to operate properly. X X@begin(verbatim) X char *dolock(fname) X X char *fname; X X dolock() locks a file, preventing others from modifying it. If X it succeeds, it returns NULL, otherwise it returns a pointer to X a string in the form "LOCK ERROR: explaination". X X char *undolock(fname) X X char *fname; X X undolock() unlocks a file, allowing others to modifying it. If X it succeeds, it returns NULL, otherwise it returns a pointer to X a string in the form "LOCK ERROR: explaination". X@end(verbatim) X@newpage X@appendix(Mode Flags) X X The two environment variables, $cmode and $gmode, contain a Xnumber the corresponds to the modes set for the current buffer and Xthe editor as a whole. These are encoded as the sum of the following Xnumbers for each of the possible modes: X X@begin(verbatim) XWRAP 1 Word wrap XCMODE 2 C indentation and fence match XSPELL 4 Interactive spell checking (Not Implemented Yet) XEXACT 8 Exact matching for searches XVIEW 16 Read-only buffer XOVER 32 Overwrite mode XMAGIC 64 Regular expressions in search XCRYPT 128 Encrytion mode active XASAVE 256 Auto-save mode X@end(verbatim) X X So, if you wished to set the current buffer to have CMODE, XEXACT, and MAGIC on, and all the others off, you would add up the values Xfor those three, CMODE 2 + EXACT 8 + MAGIC 64 = 74, and use a Xstatement like: X Xset $cmode 74 X X or, use the binary or operator to combine the different modes: X Xset $cmode &bor &bor 2 8 64 X X@flushleft(@big[Internal Flags]) X X Some of the ways EMACS controls its internal functions can be Xmodified by the value in the $gflags environment variable. Each bit in Xthis variable will be used to control a different function. X X@begin(verbatim) XGFFLAG 1 If this bit is set to zero, EMACS will not X automatically switch to the buffer of the X first file after executing the startup macros. X@end(verbatim) FRIDAY_NIGHT echo extracting - emacs.txt sed 's/^X//' > emacs.txt << 'FRIDAY_NIGHT' X X X X X X X X X X X X X X X X X X MicroEMACS X X Full Screen Text Editor X Reference Manual (preliminary draft) X X Version 3.9e X November 4, 1987 X X (C)opyright 1987 by Daniel M. Lawrence X Reference Manual (C)opyright 1987 X by Brian Straight and Daniel M. Lawrence X All Rights Reserved X X MicroEMACS 3.9e can be copied and distributed X freely X for any non-commercial purposes. MicroEMACS 3.9e X can X only be incorporated into commercial software X with X the permission of the current author. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Introduction X X MicroEMACS is a tool for creating and changing documents, X programs, and other text files. It is both relatively easy for X the novice to use, but also very powerful in the hands of an X expert. MicroEMACS can be extensively customized for the needs of X the individual user. X X MicroEMACS allows several files to be edited at the same X time. The screen can be split into different windows, and text X may be moved freely from one window to the next. Depending on X the type of file being edited, MicroEMACS can change how it X behaves to make editing simple. Editing standard text files, X program files and word processing documents are all possible at X the same time. X X There are extensive capabilities to make word processing X and editing easier. These include commands for string searching X and replacing, paragraph reformatting and deleting, automatic X word wrapping, word move and deletes, easy case controlling, and X automatic word counts. X X For complex and repetitive editing tasks editing macroes X can be written. These macroes allow the user a great degree of X flexibility in determining how MicroEMACS behaves. Also, any and X all the commands can be used by any keystroke by changing, or X rebinding, what commands various keys are connected, or bound, X to. X X Special features are also available to perform a diverse X set of operations such as file encryption, automatic backup file X generation, entabbing and detabbing lines, executing of DOS X commands and filtering of text through other programs (like SORT X to allow sorting text). X X History X X EMACS was originally a text editor written by Richard X Stahlman at MIT in the early 1970s for Digital Equipment X computers. Various versions, rewrites and clones have made an X appearence since. X X This version of MicroEMACS is derived from code written X by Dave G. Conroy in 1985. Later modifications were performed by X Steve Wilhite and George Jones. In December of 1985 Daniel X Lawrence picked up the then current source (version 2.0) and made X extensive modifications and additions to it over the course of X the next two years. Updates and support for the current version X are still availible. The current program author can be contacted X by writing to: X X USMAIL: Daniel Lawrence X 617 New York St X Lafayette, IN 47901 X X X X X X X X X X X X UUCP: ihnp4!pur-ee!pur-phy!duncan!lawrence X ARPA: nwd@j.cc.purdue.edu X FIDO: Fido 201/2 The Programmer's Room (317) 742-5533 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Basic Concepts MicroEMACS Reference Manual X X X X X X X X X Chapter 1 X X Basic Concepts X X X The current version of MicroEMACS is 3.9e (Third major X re-write, ninth public release, fifth minor edit), and for the X rest of this document, we shall simply refer to this version as X "EMACS". Any modifications for later versions will be listed in X the appendixes at the end of this manual. X X X 1.1 Keys and the Keyboard X X X Many times throughout this manual we will be talking X about commands and the keys on the keyboard needed to use them. X There are a number of "special" keys which can be used and are X listed here: X X <NL> NewLine which is also called RETURN or ENTER, this X key is used to end different commands. X X ^ The control key can be used before any alphabetic X character and some symbols. For example, ^C means X to hold down the <CONTROL> key and type the C key X at the same time. X X ^X The CONTROL-X key is used at the beginning of many X different commands. X X META or M- This is a special EMACS key used to begin many X commands as well. This key is pressed and then X released before typing the next character. On X most systems, this is the <ESC> key, but it can be X changed. (consult appendix E to learn what key is X used for META on your computer). X X Whenever a command is described, the manual will list the X actual keystrokes needed to execute it in boldface using the X above conventions, and also the name of the command in italics. X X X 1.2 Getting Started X X X In order to use EMACS, you must call it up from your X system or computer's command prompt. On UNIX and MSDOS machines, X X X 1 X X X X X X X MicroEMACS Reference Manual Basic Concepts X X X just type "emacs" from the main command prompt and follow it with X the <RETURN> or <ENTER> key (we will refer to this key as <NL> X for "new-line" for the remainder of this manual). On the X Macintosh, the Amiga, the ATARI ST and other icon based operating X systems, double click on the uEMACS icon. Shortly after this, a X screen similar to the one below should appear. X X X 1.3 Parts and Pieces X X X The screen is divided into a number of areas or windows. X On some systems the top window contains a function list of X unshifted and shifted function keys. We will discuss these keys X later. Below them is an EMACS mode line which, as we will see, X informs you of the present mode of operation of the editor--for X example "(WRAP)" if you set EMACS to wrap at the end of each X line. Under the mode line is the text window where text appears X and is manipulated. Since each window has its own mode line, X below the text window is it's mode line. The last line of the X screen is the command line where EMACS takes commands and reports X on what it is doing. X X =============================================================================== X f1 search-> f2 <-search | MicroEMACS: Text Editor X f3 hunt-> f4 <-hunt | X f5 fkeys f6 help | Available function key Pages include: X f7 nxt wind f8 pg[ ] | WORD PROG BOX X f9 save f10 exit | [use the f8 key to load Pages] X =============================================================================== X -- MicroEMACS 3.9e () -- Function Keys X --------------------------------------- X =============================================================================== X X X X X X X X X X X X X =============================================================================== X -- MicroEMACS 3.9e () -- Main X ------------------------------------------------ X =============================================================================== X X X X X X X X 2 X X X X X X X Basic Concepts MicroEMACS Reference Manual X X X Fig 1: EMACS screen on an IBM-PC X X X 1.4 Entering Text X X X Entering text in EMACS is simple. Type the following X sentence fragment: X X Fang Rock lighthouse, center of a series of mysterious X and X X The text is displayed at the top of the text window. Now type: X X terrifying events at the turn of the century X X Notice the text to the left of the cursor disappears and X a '$' sign appears. Don't panic--your text is safe!!! You've X just discovered that EMACS doesn't "wrap" text to the next line X like most word processors unless you hit <NL>. But since EMACS X is used for both word processing, and text editing, it has a bit X of a dual personality. You can change the way it works by X setting various modes. In this case, you need to set WRAP mode, X using the add-mode command, by typing ^X-M. The command line at X the base of the screen will prompt you for the mode you wish to X add. Type wrap followed by the <NL> key and any text you now X enter will be wrapped. However, the command doesn't wrap text X already entered. To get rid of the truncated line, delete X characters with the <BACKSPACE> key until the '$' goes away. Now X type in the words you deleted, watch how EMACS goes down to the X next line at the right time. (In some versions of EMACS, WRAP is X a default mode in which case you don't have to worry about the X instructions relating to adding this mode.) X X Now let's type a longer insert. Hit <NL> a couple of X times to tab down from the text you just entered. Now type the X following paragraphs. Press <NL> twice to indicate a paragraph X break. X X Fang Rock lighthouse, center of a series of mysterious X and terrifying events at the turn of the century, is X built on a rocky island a few miles of the Channel X coast. So small is the island that wherever you stand X its rocks are wet with sea spray. X X The lighthouse tower is in the center of the island. A X steep flight of steps leads to the heavy door in its X base. Winding stairs lead up to the crew room. X X X X X X X X X 3 X X X X X X X MicroEMACS Reference Manual Basic Concepts X X X 1.5 Basic cursor movement X X X Now let's practice moving around in this text. To move X the cursor back to the word "Winding," enter M-B previous-word. X This command moves the cursor backwards by one word at a time. X Note you have to press the key combination every time the cursor X steps back by one word. Continuously pressing META and toggling X B produces an error message. To move forward to the word X "stairs" enter M-F, which moves the cursor forward by one word at X a time. X X Notice that EMACS commands are usually mnemonic--F for X forward, B for backward, for example. X X To move the cursor up one line, enter ^P previous-line, X down one line ^N next-line. Practice this movement by moving the X cursor to the word "terrifying" in the second line. X X The cursor may also be moved forward or backward in X smaller increments. To move forward by one character, enter ^F X forward-character, to move backward, ^B backward-character. X EMACS also allows you to specify a number which is normally used X to tell a command to execute many times. To repeat most X commands, press META and then the number before you enter the X command. Thus, the command META 5 ^F (M-5^F) will move the X cursor forward by five characters. Try moving around in the text X by using these commands. For extra practice, see how close you X can come to the word "small" in the first paragraph by giving an X argument to the commands listed here. X X Two other simple cursor commands that are useful to help X us move around in the text are M-N next-paragraph which moves the X cursor to the second paragraph, and M-P previous-paragraph which X moves it back to the previous paragraph. The cursor may also be X moved rapidly from one end of the line to the other. Move the X cursor to the word "few" in the second line. Press ^A beginning- X of-line. Notice the cursor moves to the word "events" at the X beginning of the line. Pressing ^E end-of-line moves the cursor X to the end of the line. X X Finally, the cursor may be moved from any point in the X file to the end or beginning of the file. Entering M-> end-of- X file moves the cursor to the end of the buffer, M-< beginning-of- X file to the first character of the file. X X On the IBM-PC, the ATARI ST and many other machines, the X cursor keys can also be used to move the cursor about. Also, if X there is one available, moving the mouse will move the cursor. X X Practice moving the cursor in the text until you are X comfortable with the commands we've explored in this chapter. X X X X X 4 X X X X X X X Basic Concepts MicroEMACS Reference Manual X X X 1.6 Saving your text X X X When you've finished practicing cursor movement, save X your file. Your file currently resides in a BUFFER. The buffer X is a temporary storage area for your text, and is lost when the X computer is turned off. You can save the buffer to a file by X entering ^X-^S save-file. Notice that EMACS informs you that X your file has no name and will not let you save it. X X To save your buffer to a file with a different name than X it's current one (which is empty), press ^X^W write-file. EMACS X will prompt you for the filename you wish to write. Enter the X name fang.txt and press return. On a micro, the drive light will X come on, and EMACS will inform you it is writing the file. When X it finishes, it will inform you of the number of lines it has X written to the disk. X X Congratulations!! You've just saved your first EMACS X file! X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 5 X X X X X X X MicroEMACS Reference Manual Basic Concepts X X X X X X X Chapter 1 Summary X X X In chapter 1, you learned how to enter text, how to use X wrap mode, how to move the cursor, and to save a buffer. The X following is a table of the commands covered in this chapter and X their corresponding key bindings: X X Key Binding Keystroke Effect X X abort-command ^G aborts current command X X add-mode ^XM allows addition of EMACS X mode such as WRAP X X backward-character ^B moves cursor left one character X X beginning-of-file M-< moves cursor to beginning of file X X beginning-of-line ^A moves cursor to beginning of line X X end-of-file M-> moves cursor to end of file X X end-of-line ^E moves cursor to end of line X X forward-character ^F moves cursor right one character X X next-line ^N moves cursor to next line X X next-paragraph M-N moves cursor to next paragraph X X next-word M-F moves cursor forward one word X X previous-line ^P moves cursor backward by one line X X previous-paragraph M-P moves cursor to previous paragraph X X previous-word M-B moves cursor backward by one word X X save-file ^X-^S saves current buffer to a file X X write-file ^X-^W save current buffer under a new X name X X X X X X X X X X 6 X X X X X X X Basic Editing--Simple Insertions and Deletions MicroEMACS X Reference Manual X X X X X X X X X Chapter 2 X X Basic Editing--Simple Insertions and Deletions X X X 2.1 A Word About Windows, Buffers, Screens, and Modes X X X In the first chapter, you learned how to create and save X a file in EMACS. Let's do some more editing on this file. Call X up emacs by typing in the following command. X X emacs fang.txt X X On icon oriented systems, double click on the uEMACS X icon, usually a file dialog box of some sort will appear. Choose X FANG.TXT from the appropriate folder. X X Shortly after you invoke EMACS, the text should appear on X the screen ready for you to edit. The text you are looking at X currently resides in a buffer. A buffer is a temporary area of X computer memory which is the primary unit internal to EMACS -- X this is the place where EMACS goes to work. The mode line at the X bottom of the screen lists the buffer name, FANG.TXT and the name X of the file with which this buffer is associated, FANG.TXT X X The computer talks to you through the use of its screen. X This screen usually has an area of 24 lines each of 80 characters X across. You can use EMACS to subdivide the screen into several X separate work areas, or windows, each of which can be 'looking X into' different files or sections of text. Using windows, you X can work on several related texts at one time, copying and moving X blocks of text between windows with ease. To keep track of what X you are editing, each window is identified by a mode line on the X last line of the window which lists the name of the buffer which X it is looking into, the file from which the text was read, and X how the text is being edited. X X An EMACS mode tells EMACS how to deal with user input. X As we have already seen, the mode 'WRAP' controls how EMACS deals X with long lines (lines with over 79 characters) while the user is X typing them in. The 'VIEW' mode, allows you to read a file X without modifying it. Modes are associated with buffers and not X with files; hence, a mode needs to be explicitly set or removed X every time you edit a file. A new file read into a buffer with a X previously specified mode will be edited under this mode. If you X X X X 7 X X X X X X X MicroEMACS Reference Manual Basic Editing--Simple Insertions and X Deletions X X X use specific modes frequently, EMACS allows you to set the modes X which are used by all new buffers, called global modes. X X X 2.2 Insertions X X X Your previously-saved text should look like this: X X Fang Rock lighthouse, center of a series of mysterious X and terrifying events at the turn of the century, is X built on a rocky island a few miles of the Channel X coast. So small is the island that wherever you stand X its rocks are wet with sea spray. X X The lighthouse tower is in the center of the island. A X steep flight of steps leads to the heavy door in its X base. Winding stairs lead up to the crew room. X X Let's assume you want to add a sentence in the second X paragraph after the word "base." Move the cursor until it is on X the "W" of "Winding". Now type the following: X X This gives entry to the lower floor where the big steam X generator throbs steadily away, providing power for the X electric lantern. X X If the line fails to wrap and you end up with a '$' sign X in the right margin, just enter M-Q fill-paragraph to reformat X the paragraph. This new command attempts to fill out a X paragraph. Long lines are divided up, and words are shuffled X around to make the paragraph look nicer. X X Notice that all visible EMACS characters are self- X inserting -- all you had to do was type the characters to insert X and the existing text made space for it. With a few exceptions X discussed later, all non-printing characters (such as control or X escape sequences) are commands. To insert spaces, simply use the X space bar. Now move to the first line of the file and type ^O X open-line (Oh, not zero). You've just learned how to insert a X blank line in your text. X X X 2.3 Deletions X X X EMACS offers a number of deletion options. For example, X move the cursor until it's under the period at the end of the X insertion you just did. Press the backspace key. Notice the "n" X on "lantern" disappeared. The backspace implemented on EMACS is
nwd@j.cc.purdue.edu (Daniel Lawrence) (11/26/87)
X called a destructive backspace--it removes text immediately X before the current cursor position from the buffer. Now type ^H X X X X 8 X X X X X X X Basic Editing--Simple Insertions and Deletions MicroEMACS X Reference Manual X X X delete-previous-character. Notice that the cursor moves back and X obliterates the "r"--either command will backspace the cursor. X X Type in the two letters you erased to restore your text X and move the cursor to the beginning of the buffer M-> beginning- X of-file. Move the cursor down one line to the beginning of the X first paragraph. X X To delete the forward character, type ^D delete-next- X character. The "F" of "Fang" disappears. Continue to type ^D X until the whole word is erased EMACS also permits the deletion of X larger elements of text. Move the cursor to the word "center" in X the first line of text. Pressing M-<backspace> delete-previous- X word kills the word immediately before the cursor. M-^H has the X same effect. X X Notice that the commands are very similar to the control X commands you used to delete individual letters. As a general X rule in EMACS, control sequences affect small areas of text, META X sequences larger areas. The word forward of the cursor position X can therefore be deleted by typing M-D delete-next-word. Now X let's take out the remainder of the first line by typing ^K kill- X to-end-of-line. You now have a blank line at the top of your X screen. Typing ^K again or ^X-^O delete-blank-lines deletes the X blank line and flushes the second line to the top of the text. X Now exit EMACS by typing ^X-^C exit-emacs . Notice EMACS reminds X you that you have not saved your buffer. Ignore the warning and X exit. This way you can exit EMACS without saving any of the X changes you just made. X X X X X Chapter 2 Summary X X X In Chapter 2, you learned about the basic 'building X blocks' of an EMACS text file--buffers, windows, and files. X X Key binding Keystroke Effect X delete-previous-character X ^H deletes character immediately X before X the current cursor position X X delete-next-character ^D deletes character immediately after X current cursor position X X delete-previous-word M-^H deletes word immediately before X current cursor position X X delete-next-word M-D deletes word immediately after X current cursor position X X X 9 X X X X X X X MicroEMACS Reference Manual Basic Editing--Simple Insertions and X Deletions X X X kill-to-end-of-line ^K deletes from current cursor X position to end of line X X insert-space ^C inserts a space to right of cursor X X open-line ^O inserts blank line X X delete-blank-lines ^X-^O removes blank line X X exit-emacs ^X-^C exits emacs X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 10 X X X X X X X Using Regions MicroEMACS Reference Manual X X X X X X X X X Chapter 3 X X Using Regions X X X 3.1 Defining and Deleting a Region X X X At this point its time to familiarize ourselves with two X more EMACS terms--the point and the mark. The point is located X directly behind the current cursor position. The mark (as we X shall see shortly) is user defined. These two elements together X are called the current region and limit the region of text on X which EMACS performs many of its editing functions. X X Let's begin by entering some new text. Don't forget to X add wrap mode if its not set on this buffer. Start EMACS and X open a file called PUBLISH.TXT. Type in the following text: X X One of the largest growth areas in personal computing X is electronic publishing. There are packages available X for practically every machine from elegantly simple X programs for the humble Commodore 64 to sophisticated X professional packages for PC and Macintosh computers. X X Electronic publishing is as revolutionary in its way as X the Gutenburg press. Whereas the printing press X allowed the mass production and distribution of the X written word, electronic publishing puts the means of X production in the hands of nearly every individual. X From the class magazine to the corporate report, X electronic publishing is changing the way we produce X and disseminate information. X X Personal publishing greatly increases the utility of X practically every computer. Thousands of people who X joined the computer revolution of this decade only to X hide their machines unused in closets have discovered a X new use for them as dedicated publishing workstations. X X Now let's do some editing. The last paragraph seems a X little out of place. To see what the document looks like without X it we can cut it from the text by moving the cursor to the X beginning of the paragraph. Enter M-<space> set-mark. EMACS X will respond with "[Mark set]". Now move the cursor to the end X of the paragraph. You have just defined a region of text. To X remove this text from the screen, type ^W kill-region. The X paragraph disappears from the screen. X X X 11 X X X X X X X MicroEMACS Reference Manual Using Regions X X X On further consideration, however, perhaps the paragraph X we cut wasn't so bad after all. The problem may have been one of X placement. If we could tack it on to the end of the first X paragraph it might work quite well to support and strengthen the X argument. Move the cursor to the end of the first paragraph and X enter ^Y yank. Your text should now look like this: X X One of the largest growth areas in personal computing X is electronic publishing. There are packages available X for practically every machine from elegantly simple X programs for the humble Commodore 64 to sophisticated X professional packages for PC and Macintosh computers. X Personal publishing greatly increases the utility of X practically every computer. Thousands of people who X joined the computer revolution of this decade only to X hide their machines unused in closets have discovered a X new use for them as dedicated publishing workstations. X X Electronic publishing is as revolutionary in its way as X the Gutenburg press. Whereas the printing press X allowed the mass production and distribution of the X written word, electronic publishing puts the means of X production in the hands of nearly every individual. X From the class magazine to the corporate report, X electronic publishing is changing the way we produce X and disseminate information. X X X 3.2 Yanking a Region X X X The text you cut initially didn't simply just disappear, X it was cut into a buffer that retains the 'killed' text X appropriately called the kill buffer. ^Y "yanks" the text back X from this buffer into the current buffer. If you have a long line X (indicated, remember, by the "$" sign), simply hit M-Q to X reformat the paragraph. X X There are other uses to which the kill buffer can be put. X Using the method we've already learned, define the last paragraph X as a region. Now type M-W copy-region. Nothing seems to have X happened; the cursor stays blinking at the point. But things X have changed, even though you may not be able to see any X alteration. X X To see what has happened to the contents of the kill X buffer, move the cursor down a couple of lines and "yank" the X contents of the kill buffer back with ^Y. Notice the last X paragraph is now repeated. The region you defined is "tacked on" X to the end of your file because M-W copies a region to the kill X buffer while leaving the original text in your working buffer. X Some caution is needed however, because the contents of the kill X buffer are updated when you delete any regions, lines or words. X If you are moving large quantities of text, complete the X X X 12 X X X X X X X Using Regions MicroEMACS Reference Manual X X X operation before you do any more deletions or you could find that X the text you want to move has been replaced by the most recent X deletion. Remember--a buffer is a temporary area of computer X memory that is lost when the machine is powered down or switched X off. In order to make your changes permanent, they must be saved X to a file before you leave EMACS. Let's delete the section of X text we just added and save the file to disk. X X X X X Chapter 3 Summary X X X In Chapter 3, you learned how to achieve longer X insertions and deletions. The EMACS terms point and mark were X introduced and you learned how to manipulate text with the kill X buffer. X X Key Binding Keystroke Effect X X Delete-Region ^W Deletes region between point and mark and X places it in KILL buffer X X Copy-Region M-W Copies text between point and mark into X KILL buffer X X Yank-Text ^Y Inserts a copy of the KILL buffer into X current buffer at point X X X X X X X X X X X X X X X X X X X X X X X X X X X X 13 X X X X X X X MicroEMACS Reference Manual Search and Replace X X X X X X X X X Chapter 4 X X Search and Replace X X X 4.1 Forward Search X X X Load EMACS and bring in the file you just saved. Your X file should look like the one below. X X One of the largest growth areas in personal computing X is electronic publishing. There are packages available X for practically every machine from elegantly simple X programs for the humble Commodore 64 to sophisticated X professional packages for PC and Macintosh computers. X Personal publishing greatly increases the utility of X practically every computer. Thousands of people who X joined the computer revolution of this decade only to X hide their machines unused in closets have discovered a X new use for them as dedicated publishing workstations. X X Electronic publishing is as revolutionary in its way as X the Gutenburg press. Whereas the printing press X allowed the mass production and distribution of the X written word, electronic publishing puts the means of X production in the hands of nearly every individual. X From the class magazine to the corporate report, X electronic publishing is changing the way we produce X and disseminate information. X X Let's use EMACS to search for the word "revolutionary" in X the second paragraph. Because EMACS searches from the current X cursor position toward the end of buffers, and we intend to X search forward, move the cursor to the beginning of the text. X Enter ^S search-forward. Note that the command line now reads X X "Search [] <META>:" X X EMACS is prompting you to enter the search string -- the X text you want to find. Enter the word revolutionary and hit the X META key. The cursor moves to the end of the word X "revolutionary." X X Notice that you must enter the <META> key to start the X search. If you simply press <NL> the command line responds with X "<NL>". Although this may seem infuriating to users who are used X to pressing the return key to execute any command, EMACS' use of X X X 14 X X X X X X X Search and Replace MicroEMACS Reference Manual X X X <META> to begin searches allows it to pinpoint text with great X accuracy. After every line wrap or carriage return, EMACS 'sees' X a new line character (<NL>). If you need to search for a word at X the end of a line, you can specify this word uniquely in EMACS. X X In our sample text for example, the word "and" occurs a X number of times, but only once at the end of a line. To search X for this particular occurence of the word, move the cursor to the X beginning of the buffer and type ^S. Notice that EMACS stores X the last specified search string as the default string. If you X press <META> now, EMACS will search for the default string, in X this case, "revolutionary." X X To change this string so we can search for our specified X "and" simply enter the word and followed by <NL>. The command X line now shows: X X "search [and<NL>]<META>:" X X Press <META> and the cursor moves to "and" at the end of X the second last line. X X X 4.2 Exact Searches X X X If the mode EXACT is active in the current buffer, EMACS X searches on a case sensitive basis. Thus, for example you could X search for Publishing as distinct from publishing. X X X 4.3 Backward Search X X X Backward searching is very similar to forward searching X except that it is implemented in the reverse direction. To X implement a reverse search, type ^R search-reverse. Because X EMACS makes no distinction between forward and backward stored X search strings, the last search item you entered appears as the X default string. Try searching back for any word that lies X between the cursor and the beginning of the buffer. Notice that X when the item is found, the point moves to the beginning of the X found string (i.e., the cursor appears under the first letter of X the search item). X X Practice searching for other words in your text. X X X 4.4 Searching and Replacing X X X Searching and replacing is a powerful and quick way of X making changes to your text. Our sample text is about electronic X publishing, but the correct term is 'desktop' publishing. To X X X 15 X X X X X X X MicroEMACS Reference Manual Search and Replace X X X make the necessary changes we need to replace all occurences of X the word "electronic" with "desktop." First, move the cursor to X the top of the current buffer with the M-< command. Then type M- X R replace-string. The command line responds: X X "Replace []<META>:" X X where the square brackets enclose the default string. X Type the word electronic and hit <META>. The command line X responds: X X "with []<META>" X X type desktop<META>. EMACS replaces all instances of the X original word with your revision. Of course, you will have to X capitalize the first letter of "desktop" where it occurs at the X beginning of a sentence. X X You have just completed an unconditional replace. In X this operation, EMACS replaces every instance of the found string X with the replacement string. X X X 4.5 Query-Replace X X X You may also replace text on a case by case basis. The X M-^R query-replace-string command causes EMACS to pause at each X instance of the found string. X X For example, assume we want to replace some instances of X the word "desktop" with the word "personal." Go back to the X beginning of the current buffer and enter the M-^R query-replace X command. The procedure is very similar to that which you X followed in the unconditional search/replace option. When the X search begins however, you will notice that EMACS pauses at each X instance of "publishing" and asks whether you wish to replace it X with the replacement string. You have a number of options X available for response: X X Response Effect X Y(es) Make the current replacement and skip to the next X occurence of the search string X X N(o) Do not make this replacement but continue X X ! Do the rest of the replacements with no more queries X X U(ndo) Undo just the last replacement and query for it X again (This can only go back ONE time) X X ^G Abort the replacement command (This action does not X undo previously-authorized replacements X X X X 16 X X X X X X X Search and Replace MicroEMACS Reference Manual X X X . Same effect as ^G, but cursor returns to the point at X which the replacement command was given X X ? This lists help for the query replacement command X X Practice searching and searching and replacing until you X feel comfortable with the commands and their effects. X X X X X Chapter 4 Summary X X X In this chapter, you learned how to search for specified X strings of text in EMACS. The chapter also dealt with searching X for and replacing elements within a buffer. X X Key Binding Keystroke Effect X X Search-Forward ^S Searches from point to end of buffer. X Point is moved from current location to X the end of the found string X X Search-Backward ^R Searches from point to beginning of buffer. X Point is moved from current location to X beginning of found string X X Replace M-R Replace ALL ocurrences of search string with X specified (null) string from point to the X end of the current buffer X X Query-Replace M-^R As above, but pause at each found string X and query for action X X X X X X X X X X X X X X X X X X X X X X X 17 X X X X X X X MicroEMACS Reference Manual Windows X X X X X X X X X Chapter 5 X X Windows X X X 5.1 Creating Windows X X X We have already met windows in an earlier chapter. In X this chapter, we will explore one of EMACS' more powerful X features -- text manipulation through multiple windowing. X Windows offer you a powerful and easy way to edit text. By X manipulating a number of windows and buffers on the screen X simultaneously, you can perform complete edits and revisions on X the computer screen while having your draft text or original data X available for reference in another window. X X You will recall that windows are areas of buffer text X that you can see on the screen. Because EMACS can support X several screen windows simultaneously you can use them to look X into different places in the same buffer. You can also use them X to look at text in different buffers. In effect, you can edit X several files at the same time. X X Let's invoke EMACS and pull back our file on desktop X publishing by typing X X emacs publish.txt X X When the text appears, type the ^X-2 split-window X command. The window splits into two windows. The window where X the cursor resides is called the current window -- in this case X the bottom window. Notice that each window has a text area and a X mode line. The command line is however, common to all windows on X the screen. X X The two windows on your screen are virtually mirror X images of each other because the new window is opened into the X same buffer as the one you are in when you issue the open-window X command. All commands issued to EMACS are executed on the X current buffer in the current window. X X To move the cursor to the upper window (i.e., to make X that window the current window, type ^X-P previous-window. X Notice the cursor moves to the upper or previous window. X Entering ^X-O next-window moves to the next window. Practice X moving between windows. You will notice that you can also move X into the Function Key menu by entering these commands. X X X 18 X X X X X X X Windows MicroEMACS Reference Manual X X X Now move to the upper window. Let's open a new file. On X the EMACS disk is a tutorial file. Let's call it into the upper X window by typing: X X ^X-^F X X and press return. X X Enter the filename emacs.tut. X X In a short time, the tutorial file will appear in the X window. We now have two windows on the screen, each looking into X different buffers. We have just used the ^X-^F find-file command X to find a file and bring it into our current window. X X You can scroll any window up and down with the cursor X keys, or with the commands we've learned so far. However, because X the area of visible text in each window is relatively small, you X can scroll the current window a line at a time. X X Type ^X-^N move-window-down X X The current window scrolls down by one line -- the top X line of text scrolls out of view, and the bottom line moves X towards the top of the screen. You can imagine, if you like, the X whole window slowly moving down to the end of the buffer in X increments of one line. The command ^X-^P move-window-up scrolls X the window in the opposite direction. X X As we have seen, EMACS editing commands are executed in X the current window, but the program does support a useful feature X that allows you to scroll the next window. M-^Z scroll-next-up X scrolls the next window up, M-^V scroll-next-down scrolls it X downward. From the tutorial window, practice scrolling the X window with the desktop publishing text in it up and down. X X When you're finished, exit EMACS without saving any X changes in your files. X X X Experiment with splitting the windows on your screen. X Open windows into different buffers and experiment with any other X files you may have. Try editing the text in each window, but X don't forget to save any changes you want to keep -- you still X have to save each buffer separately. X X X 5.2 Deleting Windows X X X Windows allow you to perform complex editing tasks with ease. X However, they become an inconvenience when your screen is X cluttered with open windows you have finished using. The X simplest solution is to delete unneeded windows. The command X X X 19 X X X X X X X MicroEMACS Reference Manual Windows X X X ^X-0 delete-window will delete the window you are currently X working in and move you to the next window. X X If you have a number of windows open, you can delete all X but the current window by entering ^X-1 delete-other-windows. X X X 5.3 Resizing Windows X X X During complex editing tasks, you will probably find it X convenient to have a number of windows on the screen X simultaneously. However this situation may present X inconveniences because the more windows you have on the screen X the smaller they are; in some cases, a window may show only a X couple of lines of text. To increase the flexibility and utility X of the window environment, EMACS allows you to resize the window X you are working in (called, as you will recall, the current X window) to a convenient size for easier editing, and then shrink X it when you no longer need it to be so large. X X Let's try an example. Load in any EMACS text file and X split the current window into two. Now type ^X-^(Shift-6), grow- X window. Your current window should be the lower one on the X screen. Notice that it increases in size upwards by one line. X If you are in the upper window, it increases in size in a X downward direction. The command ^X-^Z, shrink-window X correspondingly decreases window size by one line at a time. X X EMACS also allows you to resize a window more precisely X by entering a numeric argument specifying the size of the window X in lines. To resize the window this way, press the META key and X enter a numeric argument (remember to keep it smaller than the X number of lines on your screen display) then press ^X-W resize- X window. The current window will be enlarged or shrunk to the X number of lines specified in the numeric argument. For example X entering: X X M-8 ^X-W X X will resize the current window to 8 lines. X X X 5.4 Repositioning within a Window X X X The cursor may be centered within a window by entering X M-! or M-^L redraw-display. This command is especially useful in X allowing you to quickly locate the cursor if you are moving X frequently from window to window. You can also use this command X to move the line containing the cursor to any position within the X current window. This is done by using a numeric argument before X the command. Type M-<n> M-^L where <n> is the number of the line X within the window that you wish the current line to be displayed. X X X 20 X X X X X X X MicroEMACS Reference Manual Windows X X X The ^L Refresh-screen command is useful for 'cleaning up' X a 'messy' screen that can result of using EMACS on a mainframe X system and being interupted by a system message. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 22 X X X X X X X Windows MicroEMACS Reference Manual X X X Chapter 5 summary X X In Chapter 5 you learned how to manipulate windows and X the editing flexibility they offer. X X Key Binding Keystroke Effect X X Open-Window ^X-2 Splits current window into two windows if X space available X X Close-Windows ^X-1 Closes all windows except current window X X Next-Window ^X-O[oh] Moves point into next (i.e. downward) X window X X Previous-Window ^XP Moves point to previous (i.e. upward) X window X X Move-Window-Down ^X-^N Scrolls current window down one line X X Move-Window-Up ^X-^P Scrolls current window up one line X X Redraw-display M ! or Window is moved so line with point X M ^L (with cursor) is at center of window X X Grow-Window M-X ^ or Current window is enlarged by one X M ^L line and nearest window is shrunk by X one line X X Shrink-Window ^X-^Z Current window is shrunk by one line X and nearest window is enlarged by one line X X Clear-and-redraw ^L Screen is blanked and redrawn. Keeps X screen updates in sync with your commands X X Scroll-Next-Up M-^Z Scrolls next window up by one line X X Scroll-Next-Down M-^V Scrolls next window down by one line X X Delete-Window ^X-0 Deletes current window X X Delete-Other-Windows ^X-1 Deletes all but current window X X Resize-Window ^X-^W Resizes window to a given numeric argument X X X X X X X X X X X X X 23 X X X X X X X MicroEMACS Reference Manual Buffers X X X X X X X X X Chapter 6 X X Buffers X X X We have already learned a number of things about X buffers. As you will recall, they are the major internal X entities in EMACS -- the place where editing commands are X executed. They are characterized by their names, their modes, X and by the file with which they are associated. Each buffer also X "remembers" its mark and point. This convenient feature allows X you to go to other buffers and return to the original location in X the "current" buffer. X X Advanced users of EMACS frequently have a number of X buffers in the computer's memory simultaneously. In the last X chapter, for example, you opened at least two buffers -- one into X the text you were editing, and the other into the EMACS on-line X tutorial. If you deal with complex text files -- say, sectioned X chapters of a book, you may have five or six buffers in the X computer's memory. You could select different buffers by simply X calling up the file with ^X-^F find-file, and let EMACS open or X reopen the buffer. However, EMACS offers fast and sophisticated X buffering techniques that you will find easy to master and much X more convenient to use. X X Let's begin by opening three buffers. You can open any X three you choose, for example call the following files into X memory: fang.txt, publish.txt, and emacs.tut in the order listed X here. When you've finished this process, you'll be looking at a X screen showing the EMACS tutorial. Let's assume that you want to X move to the fang.txt buffer. Enter: X X ^X-X next-buffer X X This command moves you to the next buffer. Because EMACS X cycles through the buffer list, which is alphabetized, you will X now be in the fang.txt buffer. Using ^X-X again places you in the X publish.txt buffer. If you are on a machine that supports X function keys, using ^X-X again places you in the Function Keys X buffer. Using ^X-X one last time cycles you back to the beginning X of the list. X X If you have a large number of buffers to deal with, this X cycling process may be slow and inconvenient. The command ^X-B X select-buffer allows you to specify the buffer you wish to be X switched to. When the command is entered, EMACS prompts, "Use X X X X 24 X X X X X X X Buffers MicroEMACS Reference Manual X X X buffer:". Simply enter the buffer name (NOT the file name), and X that buffer will then become the current buffer. X X Multiple buffer manipulation and editing is a complex X activity, and you will probably find it very inconvenient to re- X save each buffer as you modify it. The command ^X-^B list- X buffers creates a new window that gives details about all the X buffers currently known to EMACS. Buffers that have been X modified are identified by the "buffer changed" indicator (an X asterisk in the second column). You can thus quickly and easily X identify buffers that need to be saved to files before you exit X EMACS. The buffer window also provides other information -- X buffer specific modes, buffer size, and buffer name are also X listed. To close this window, simply type the close-windows X command, ^X-1. X X To delete any buffer, type ^X-K delete-buffer. EMACS X prompts you "Kill buffer:". Enter the buffer name you want to X delete. As this is destructive command, EMACS will ask for X confirmation if the buffer was changed and not saved. Answer X Y(es) or N(o). As usual ^G cancels the command. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 25 X X X X X X X MicroEMACS Reference Manual Buffers X X X X X X X Chapter 6 Summary X X X In Chapter 6 you learned how to manipulate buffers. X X Key Binding Keystroke Effect X Next-Buffer ^X-^X Switch to the next buffer in the X buffer list X X Select-Buffer ^X-B Switch to a particular buffer X X List-Buffers ^X-^B List all buffers X X Delete-Buffer ^X-K delete a particular buffer if it X is off-screen X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 26 X X X X X X X Modes MicroEMACS Reference Manual X X X X X X X X X Chapter 7 X X Modes X X X EMACS allows you to change the way it works in order to X customized it to the style of editing you are using. It does X this by providing a number of different modes . These modes can X effect either a single buffer, or any new buffer that is created. X To add a mode to the current buffer, type ^X-M add-mode. EMACS X will then prompt you for the name of a mode to add. When you X type in a legal mode name, and type a <NL>, EMACS will add the X mode name to the list of current mode names in the modeline of X the current buffer. X X To remove an existing mode, typing the ^X-^M delete-mode X will cause EMACS to prompt you for the name of a mode to delete X from the current buffer. This will remove that mode from the X mode list on the current modeline. X X Global modes are the modes which are inherited by any new X buffers which are created. For example, if you wish to always do X string searching with character case being significant, you would X want global mode EXACT to be set so that any new files read in X inherent the EXACT mode. Global modes are set with the M-M add- X global-mode command, and unset with the M-^M delete-global-mode X command. Also, the current global modes are displayed in the X first line of a ^X-^B list-buffers command. X X On machines which are capable of displaying colors, the X mode commands can also set the background and foreground X character colors. Using add-mode or delete-mode with a lowercase X color will set the background color in the current window. An X uppercase color will set the foreground color in the current X window. Colors that EMACS knows about are: white, cyan, magenta, X yellow, blue, red, green, and black. If the computer you are X running on does not have eight colors, EMACS will attempt to make X some intelligent guess at what color to use when you ask for one X which is not there. X X X 7.1 ASAVE mode X X X Automatic Save mode tells EMACS to automatically write X out the current buffer to its associated file on a regular basis. X Normally this will be every 256 characters typed into the file. X The environment variable $ACOUNT counts down to the next auto- X X X 27 X X X X X X X MicroEMACS Reference Manual Modes X X X save, and $ASAVE is the value used to reset $ACOUNT after a save X occurs. X X X 7.2 CMODE mode X X X CMODE is useful to C programmers. When CMODE is active, X EMACS will try to assist the user in a number of ways. This mode X is set automatically with files that have a .c or .h extension. X X The <NL> key will normally attempt to return the user to X the next line at the same level of indentation as the current X line, unless the current line ends with a open brace ({) in which X case the new line will be further indented by one tab position. X X A close brace (}) will delete one tab position preceeding X itself as it is typed. This should line up the close brace with X its matching IF, FOR or WHILE statement. X X A pound sign (#) with only leading whitespace will delete X all the whitespace preceeding itself. This will always bring X preprocessor directives flush to the left margin. X X Whenever any close fence is typed, ie )]>}, if the X matching open fence is on screen in the current window, the X cursor will briefly flash to it, and then back. This makes X balancing expressions, and matching blocks much easier. X X X 7.3 CRYPT mode X X X When a buffer is in CRYPT mode, it is encrypted whenever X it is written to a file, and decrypted when it is read from the X file. The encryption key can be specified on the command line X with the -k switch, or with the M-E set-encryption-key command. X If you attempt to read or write a buffer in crypt mode and now X key has not been set, EMACS will execute set-encryption-key X automatically, prompting you for the needed key. Whenever EMACS X prompts you for a key, it will not echo the key to your screen as X you type it (ie make SURE you get it right when you set it X originally). X X The encryption algorithm used changes all characters into X normal printing characters, thus the resulting file is suitable X for sending via electronic mail. All version of MicroEMACS X should be able decrypt the resulting file regardless of what X machine encrypted it. Also available with EMACS is the stand X alone program, MicroCRYPT, which can en/decrypt the files X produced by CRYPT mode in EMACS. X X X X X X 28 X X X X X X X Modes MicroEMACS Reference Manual X X X 7.4 EXACT mode X X X All string searches and replacements will take X upper/lower case into account. Normally the case of a string X during a search or replace is not taken into account. X X X 7.5 MAGIC mode X X X In the MAGIC mode certain characters gain special X meanings when used in a search pattern. Collectively they are X know as regular expressions, and a limited number of them are X supported in MicroEmacs. They grant greater flexibility when X using the search command. However, they do not affect the X incremental search command. X X The symbols that have special meaning in MAGIC mode are X ^, $, ., &, *, [ (and ], used with it), and \. X X The characters ^ and $ fix the search pattern to the X beginning and end of line, respectively. The ^ character must X appear at the beginning of the search string, and the $ must X appear at the end, otherwise they loose their meaning and are X treated just like any other character. For example, in MAGIC X mode, searching for the pattern "t$" would put the cursor at the X end of any line that ended with the letter 't'. Note that this X is different than searching for "t<NL>", that is, 't' followed by X a newline character. The character $ (and ^, for that matter) X matches a position, not a character, so the cursor remains at the X end of the line. But a newline is a character that must be X matched, just like any other character, which means that the X cursor is placed just after it - on the beginning of the next X line. X X The character . has a very simple meaning -- it matches X any single character, except the newline. Thus a search for X "bad.er" could match "badger", "badder" (slang), or up to the 'r' X of "bad error". X X The character * is known as closure, and means that zero X or more of the preceding character will match. If there is no X character preceding, * has no special meaning, and since it will X not match with a newline, * will have no special meaning if X preceded by the beginning of line symbol ^ or the literal newline X character <NL>. X X The notion of zero or more characters is important. If, X for example, your cursor was on the line X X This line is missing two vowels. X X X X X 29 X X X X X X X MicroEMACS Reference Manual Modes X X X and a search was made for "a*", the cursor would not X move, because it is guaranteed to match no letter 'a' , which X satifies the search conditions. If you wanted to search for one X or more of the letter 'a', you would search for "aa*", which X would match the letter a, then zero or more of them. X X The character [ indicates the beginning of a character X class. It is similar to the 'any' character ., but you get to X choose which characters you want to match. The character class X is ended with the character ]. So, while a search for "ba.e" X will match "bane", "bade", "bale", "bate", et cetera, you can X limit it to matching "babe" and "bake" by searching for X "ba[bk]e". Only one of the characters inside the [ and ] will X match a character. If in fact you want to match any character X except those in the character class, you can put a ^ as the first X character. It must be the first character of the class, or else X it has no special meaning. So, a search for [^aeiou] will match X any character except a vowel, but a search for [aeiou^] will X match any vowel or a ^. X X If you have a lot of characters in order that you want to X put in the character class, you may use a dash (-) as a range X character. So, [a-z] will match any letter (or any lower case X letter if EXACT mode is on), and [0-9a-f] will match any digit or X any letter 'a' through 'f', which happen to be the characters for X hexadecimal numbers. If the dash is at the beginning or end of a X character class, it is taken to be just a dash. X X The character & (ampersand) is a replacement character, X and represents the characters which matched the search string. X When used in the M-R replace-string or the M-^R query-replace- X string commands, the & will be substituted for the search string. X X The escape character \ is for those times when you want X to be in MAGIC mode, but also want to use a regular expression X character to be just a character. It turns off the special X meaning of the character. So a search for "it\." will search for X a line with "it.", and not "it" followed by any other character. X The escape character will also let you put ^, -, or ] inside a X character class with no special side effects. X X X 7.6 OVER mode X X X OVER mode stands for overwrite mode. When in this mode, X when characters are typed, instead of simply inserting them into X the file, EMACS will attempt to overwrite an existing character X past the point. This is very useful for adjusting tables and X diagrams. X X X X X X X 30 X X X X X X
nwd@j.cc.purdue.edu (Daniel Lawrence) (11/26/87)
X Modes MicroEMACS Reference Manual X X X 7.7 WRAP mode X X X Wrap mode is used when typing in continuous text. X Whenever the cursor is past the currently set fill column (72 by X default) and the user types a space or a <NL>, the last word of X the line is brought down to the beginning of the next line. X Using this, one just types a continuous stream of words and EMACS X automatically inserts <NL>s at appropriate places. X X NOTE to programmers: X X EMACS actually calls up the function bound to the X illegal keystroke M-FNW. This is bound to the function X wrap-word by default, but can be re-bound to activate X different functions and macros at wrap time. X X X 7.8 VIEW mode X X X VIEW mode disables all commands which can change the X current buffer. EMACS will display an error message and ring the X bell every time you attempt to change a buffer in VIEW mode. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 31 X X X X X X X MicroEMACS Reference Manual Modes X X X X X X X Chapter 7 Summary X X X In Chapter 7 you learned about modes and their effects. X X Key Binding Keystroke Effect X Add-Mode ^X-M Add a mode to the current buffer X X Delete-Mode ^X-^M Delete a mode from the current X buffer X X Add-Global-Mode M-M Add a global mode to the X current buffer X X Delete-Global-Mode M-^M Delete a global mode from the X current buffer X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 32 X X X X X X X Files MicroEMACS Reference Manual X X X X X X X X X Chapter 8 X X Files X X X A file is simply a collection of related data. In EMACS X we are dealing with text files -- named collections of text X residing on a disk (or some other storage medium). You will X recall that the major entities EMACS deals with are buffers. X Disk-based versions of files are only active in EMACS when you X are reading into or writing out of buffers. As we have already X seen, buffers and physical files are linked by associated file X names. For example, the buffer "ch7.txt" which is associated X with the physical disk file "ch7.txt." You will notice that the X file is usually specified by the drive name or (in the case of a X hard drive) a path. Thus you can specify full file names in X EMACS, X X e.g. disk:\directories\filename.extension X X If you do not specify a disk and directories, the default X disk is used. X X IMPORTANT -- If you do not explicitly save your buffer to X a file, all your edits will be lost when you leave EMACS X (although EMACS will prompt you when you are about to lose edits X by exiting). In addition, EMACS does not protect your disk-based X files from overwriting when it saves files. Thus when you X instruct EMACS to save a file to disk, it will create a file if X the specified file doesn't exist, or it will overwrite the X previously saved version of the file thus replacing it. Your old X version is gone forever. X X If you are at all unsure about your edits, or if (for any X reason) you wish to keep previous versions of a file, you can X change the name of the associated file with the command ^X-N. X When this file is saved to disk, EMACS will create a new physical X file under the new name. The earlier disk file will be X preserved. X X For example, let's load the file fang.txt into EMACS. X Now, type ^X-N. The EMACS command line prompts "name:". Enter a X new name for the file -- say new.txt and press <NL>. The file X will be saved under the new filename, and your disk directory X will show both fang.txt and new.txt. X X An alternative method is to write the file directly to X disk under a new filename. Let's pull our "publish.txt" file X X X 33 X X X X X X X MicroEMACS Reference Manual Files X X X into EMACS. To write this file under another filename, type ^X- X ^W. EMACS will prompt you "write file:". Enter an alternate X filename -- desktop.txt. Your file will be saved as the physical X file "desktop.txt". X X Note that in the examples above, although you have X changed the names of the related files, the buffer names remain X the same. However, when you pull the physical file back into X EMACS, you will find that the buffer name now relates to the X filename. X X For example -- You are working with a buffer "fang.txt" X with the related file "fang.txt". You change the name of the X file to "new.txt". EMACS now shows you working with the buffer X "fang.txt" and the related file "new.txt". Now pull the file X "new.txt" into EMACS. Notice that the buffer name has now X changed to "new.txt". X X If for any reason a conflict of buffer names occurs,(if X you have files of the same name on different drives for example) X EMACS will prompt you "use buffer:". Enter an alternative buffer X name if you need to. X X For a list of file related commands (including some we`ve X already seen), see the summary page. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 34 X X X X X X X Files MicroEMACS Reference Manual X X X X X X X Chapter 8 Summary X X X In Chapter 8 you learned some of the more advanced X concepts of file naming and manipulation. The relationship X between files and buffers was discussed in some detail. X X Key Binding Keystroke Effect X X Save-file ^X-^S Saves contents of current buffer with X associated filename on default disk/ X directory (if not specified) X X Write-File ^X-^W Current buffer contents will be X saved under specified name X X Change-File-name X ^X-N The associated filename is changed X (or associated if not previously X specified) as specified X X Find-File ^X-^F Reads specified file into buffer and X switches you to that buffer, or switches X to buffer in which the file has previously X been read X X Read-File ^X-^R Reads file into buffer thus overwriting X buffer contents. If file has already X been read into another buffer, you will X be switched to it X X View-File ^X-^V The same as read-file except the buffer X is automatically put into VIEW mode thus X preventing any changes from being made X X X X X X X X X X X X X X X X X X X 35 X X X X X X X MicroEMACS Reference Manual Screen Formatting X X X X X X X X X Chapter 9 X X Screen Formatting X X X 9.1 Wrapping Text X X X As we learned in the introduction, EMACS is not a word X processor, but an editor. Some simple formatting options are X available however, although in most cases they will not affect X the appearence of the finished text when it is run through the X formatter. We have already encountered WRAP mode which wraps X lines longer than a certain length (default is 75 characters). X You will recall that WRAP is enabled by entering ^X-M and X responding to the command line prompt with wrap. X X You can also set your own wrap margin with the command X ^X-F set-fill-column. Notice EMACS responds "[Fill column is X 1]." Now try typing some text. You'll notice some very strange X things happening -- your text wraps at every word!! This effect X occurs because the set wrap margin command must be preceeded by a X numeric argument or EMACS sets it to the first column. Thus any X text you type that extends past the first column will wrap at the X most convenient line break. X X To reset the wrap column to 72 characters, press the X <META> key and enter 72. EMACS will respond "Arg: 72". Now X press ^X-F. EMACS will respond "[Fill column is 72]". Your text X will again wrap at the margin you've been using up to this point. X X X 9.2 Reformatting Paragraphs X X X After an intensive editing session, you may find that you X have paragraphs containing lines of differing lengths. Although X this disparity will not affect the formatted text, aesthetic and X technical concerns may make it desirable to have consistent X paragraph blocks on the screen. If you are in WRAP mode, you can X reformat a paragraph with the command M-Q fill-paragraph. This X command 'fills' the current paragraph reformatting it so all the X lines are filled and wrap logically. The process is complex, and X (especially with longer paragraphs) may take a little time. X X X X X X X 36 X X X X X X X Screen Formatting MicroEMACS Reference Manual X X X 9.3 Changing Case X X X There may be occasions when you find it necessary to X change the case of the text you've entered. EMACS allows you to X change the case of even large amounts of text with ease. Let's X try and convert a few of the office traditionalists to the joy of X word processing. Type in the following text: X X Throw away your typewriter and learn to use a word X processor. Word processing is relatively easy to learn X and will increase your productivity enormously. Enter X the Computer Age and find out just how much fun it can X be!! X X Let's give it a little more impact by capitalizing the X first four words. The first step is to define the region of text X just as you would if you were doing an extensive deletion. Set X the mark at the beginning of the paragraph with M-<space> set- X mark and move the cursor to the space beyond "typewriter." Now X enter ^X-^U case-region-upper. Your text should now look like X this: X X THROW AWAY YOUR TYPEWRITER and learn to use a word X processor. Word processing is relatively easy to learn X and will increase your productivity enormously. Enter X the Computer Age and find out just how much fun it can X be!! X X If you want to change the text back to lower case, type X ^X-^L case-region-lower. You can also capitalize individual X words. To capitalize the word "fun", position the cursor in X front of the word and type M-U case-word-upper. The word is now X capitalized. To change it back to lower case, move the cursor X back to the beginning of the word and type M-L case-word-lower. X X You may also capitalize individual letters in EMACS. The X command M-C case-word-capitalize capitalizes the first letter X after the point. This command would normally be issued with the X cursor positioned in front of the first letter of the word you X wish to capitalize. If you issue it in the middle of a word, you X can end up with some strAnge looking text. X X X 9.4 Tabs X X X Unless your formatter is instructed to take screen text X literally (as MicroSCRIBE does in the 'verbatim' environment for X example), tabs in EMACS generally affect screen formatting only. X X When EMACS is first started, it sets the default tab to X every eighth column. As long as you stay with default, every X time you press the tab key a tab character, ^I is inserted. This X X X 37 X X X X X X X MicroEMACS Reference Manual Screen Formatting X X X character, like other control characters, is invisible -- but it X makes a subtle and significant difference to your file and X editing. X X For example, in default mode, press the tab key and then X type the word Test. "Test" appears at the eighth column. Move X your cursor to the beginning of the word and delete the backward X character. The word doesn't move back just one character, but X flushes to the left margin. The reason for this behavior is X easily explained. In tab default, EMACS inserts a 'real' tab X character when you press the tab key. This character is inserted X at the default position, but NO SPACES are inserted between the X tab character and the margin (or previous tab character). As you X will recall, EMACS only recognizes characters (such as spaces or X letters) and thus when the tab character is removed, the text X beyond the tab is flushed back to the margin or previous tab X mark. X X This situation changes if you alter the default X configuration. The default value may be changed by entering a X numeric argument before pressing the tab key. As we saw earlier, X pressing the META key and entering a number allows you to specify X how EMACS performs a given action. In this case, let's specify X an argument of 10 and hit the tab key. X X Now hit the tab key again and type Test. Notice the word X now appears at the tenth column. Now move to the beginning of X the word and delete the backward character. "Test" moves back by X one character. X X EMACS behaves differently in these circumstances because X the ^I handle-tab function deals with tabbing in two distinct X ways. In default conditions, or if the numeric argument of zero X is used, handle-tab inserts a true tab character. If, however, a X non-zero numeric argument is specified, handle-tab inserts the X correct number of spaces needed to position the cursor at the X next specified tab position. It does NOT insert the single tab X character and hence any editing functions should take account of X the number of spaces between tabbed columns. X X Many times you would like to take a line which has been X created using the tab character and change it to use just spaces. X The command ^X-^D detab-line changes any tabs from the point to X the end of the current line into the right number of spaces so X the line does not change. This is very useful for times when the X file must be printed or transfered to a machine which does not X understand tabs. X X Also, the inverse command, ^X-^E entab-lines changes X multiple spaces to tabs where possible. This is a good way to X shrink the size of large documents, especially with data tables. X Both of these commands can take a numeric argument which will be X interpeted as the number of lines to en/detab. X X X X 38 X X X X X X X Screen Formatting MicroEMACS Reference Manual X X X X X X X Chapter 9 Summary X X X In Chapter 9 introduced some of the formatting features X of EMACS. Text-wrap, paragraph reformatting, and tabs were X discussed in some detail. The commands in the following table X were covered in the chapter. X X X Key Binding Keystroke Effect X Add-Mode/WRAP ^X-M[WRAP] Add wrap mode to current buffer X X Delete-Mode/WRAP ^X-^M[WRAP] Remove wrap mode from current X buffer X X Set-Fill-Column ^X-F Set fill column to given numeric X argument X X Fill-Paragraph M-Q Logically reformats the current X paragraph X X Case-Word-Upper M-U Text from point to end of the X current word is changed to X uppercase X X Case-Word-Lower M-L Text from point to end of the X current word is changed to X lowercase X X Case-Word-Capitalize M-C First word (or letter) after the X point is capitalized X X Case-Region-Upper ^X-^U The current region is uppercased X X Case-Region-Lower ^X-^L The current region is lowercased X X Handle-Tab ^I Tab interval is set to the given X numeric argument X Entab-Line ^X-^E Changes multiple spaces to tabs X characters where possible X Detab-Line ^X-^D Changes tab characters to the X appropriate number of spaces X X X X X X X X X X X 39 X X X X X X X MicroEMACS Reference Manual Access to the Outside World X X X X X X X X X Chapter 10 X X Access to the Outside World X X X EMACS has the ability to interface to other programs and X the environment of the computer outside of itself. It does this X through a series of commands that allow it to talk to the X computer's command processor or shell. Just what this is varies X between different computers. Under MSDOS or PCDOS this is the X command.com command processor. Under UNIX it is the csh shell. X On the Atari ST is can be the Mark Williams MSH or the Beckmeyer X shell. In each case, it is the part of the computer's operating X system that is responcable for determining what programs are X executed, and when. X X The ^X-! shell-command command prompts the user for a X command line to send out to the shell to execute. This can be X very useful for doing file listings and changing the current X directory or folder. EMACS gives control to the shell, which X executed the command, and then types [END] and waits for the user X to type a character before redrawing the screen and resuming X editing. If the shell-command command is used from within the X macro language, there is no pause. X X ^X-@ pipe-command command allows EMACS to execute a shell X command, and if the particular computer allows it, send the X results into a buffer which is automatically displayed on the X screen. The resulting buffer, called "command" can be manipulated X just like any other editing buffer. Text can be copied out of it X or rearanged as needed. This buffer is originally created in VIEW X mode, so remember to ^X-^Mview<NL> in order to change it. X X Many computers provide tools which will allow you to X filter text, making some modifications to it along the way. A X very common tool is the SORT program which accepts a file, sorts X it, and prints the result out. The EMACS command, ^X-# filter- X buffer sends the current buffer through such a filter. X Therefore, if you wished to sort the current buffer on a system X which supplied a sort filter, you would type ^X-#sort<NL>. You X can also create your own filters by writing programs and X utilities which read text from the keyboard and display the X results. EMACS will use any of these which would normally be X available from the current shell. X X If you would like to execute another program directly, X without the overhead of an intervening shell, you can use the X ^X-$ execute-program command. It will prompt you for an external X X X 40 X X X X X X X Access to the Outside World MicroEMACS Reference Manual X X X program and its arguments and attempt to execute it. Like when X EMACS looks for command files, EMACS will look first in the HOME X directory, then down the execute PATH, and finally in the current X directory for the named program. On some systems, it will X automatically tack the proper extension on the file name to X indicate it is a program. On some systems that don't support this X function, ^X-$ will be equivalent to ^X-! shell-command. X X Sometimes, you would like to get back to the shell and X execute other commands, without losing the current contents of X EMACS. The ^X-C i-shell command shells out of EMACS, leaving X EMACS in the computer and executing another command shell. Most X systems would allow you to return to EMACS with the "exit" X command. X X On some systems, mainly advanced versions of UNIX, you X can X direct EMACS to "go into the background" with the ^X-D suspend- X emacs command. This places EMACS in the background returning you X to the original command shell. EMACS can then be returned to at X any time with the "fg" foreground command. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 41 X X X X X X X MicroEMACS Reference Manual Access to the Outside World X X X X X X X Chapter 10 Summary X X X In Chapter 10 introduced different ways to access the X computers shell or command processor from within EMACS. The X commands in the following table were covered in the chapter. X X X Key Binding Keystroke Effect X Execute-program ^X-$ Execute an external program X directly X X Filter-command ^X-# Send the current buffer through X a shell filter X X I-shell ^X-C Escape to a new shell X X Pipe-command ^X-@ Send the results of an external X shell command to a buffer X X Shell-command ^X-! Execute one shell command X X Suspend-emacs ^X-D Place EMACS in the background X (some UNIX systems only) X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 42 X X X X X X X Keyboard Macros MicroEMACS Reference Manual X X X X X X X X X Chapter 11 X X Keyboard Macros X X X In many applications, it may be necessary to repeat a X series of characters or commands frequently. For example, a X paper may require the frequent repetition of a complex formula or X a long name. You may also have a series of EMACS commands that X you invoke frequently. Keyboard macros offer a convenient method X of recording and repeating these commands. X X Imagine, for example, you are writing a scholarly paper X on Asplenium platyneuron, the spleenwort fern. Even the X dedicated botanist would probably find it a task bordering on the X agonizing to type Asplenium platyneuron frequently throughout the X paper. An alternative method is 'record' the name in a keyboard X macro. Try it yourself. X X The command ^X-( begin-macro starts recording the all the X keystrokes and commands you input. After you've typed it, enter X Asplenium platyneuron. To stop recording, type ^X-) end-macro. X EMACS has stored all the keystrokes between the two commands. To X repeat the name you've stored, just enter ^X-E execute-macro, and X the name "Asplenium platyneuron" appears. You can repeat this X action as often as you want, and of course as with any EMACS X command, you may precede it with a numerical argument. X X Because EMACS records keystrokes, you may freely intermix X commands and text. Unfortunately, you can only store one macro X at a time. Thus, if you begin to record another macro, the X previously defined macro is lost. Be careful to ensure that X you've finished with one macro before defining another. If you X have a series of commands that you would like to 'record' for X future use, use the macro or procedure facilities detailed in X chapter <X>. X X X X X X X X X X X X X X X 43 X X X X X X X MicroEMACS Reference Manual Keyboard Macros X X X X X X X Chapter 11 Summary X X X Chapter 11 covered keyboard macros. You learned how to X record keystrokes and how to repeat the stored sequence. X X Key Binding Keystroke Effect X X Start-Macro ^X-( Starts recording all keyboard input X X End-Macro ^X-) Stops recording keystrokes for X macro X X Execute-Macro ^X-E Entire sequence of recorded X keystrokes is replayed X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 44 X X X X X X X MicroEMACS Macros MicroEMACS Reference Manual X X X X X X X X X Chapter 12 X X MicroEMACS Macros X X X Macros are programs that are used to customize the editor X and to perform complicated editing tasks. They may be stored in X files or buffers and may be executed using an appropriate X command, or bound to a particular keystroke. Portions of the X standard start-up file are implemented via macros, as well as the X example menu system. The execute-macro-<n> commands cause the X macro, numbered from 1 to 40, to be executed. The execute-file X command allows you to execute a macro stored in a disk file, and X the execute-buffer command allows you to execute a macro stored X in a buffer. Macros are stored for easy execution by executing X files that contain the store-macro command. X X If you need more than 40 macros, named macroes, called X procedures, can be used. The store-procedure command takes a X string argument which is the name of a procedure to store. These X procedures than can be executed with the M-^E execute-procedure X or the run commands. X X There are many different aspects to the macro language X within MicroEMACS. Editor commands are the various commands that X manipulate text, buffers, windows, etc, within the editor. X Directives are commands which control what lines get executed X within a macro. Also there are various types of variables. X Environmental variables both control and report on different X aspects of the editor. User variables hold string values which X may be changed and inspected. Buffer variables allow text to be X placed into variables. Interactive variable allow the program to X prompt the user for information. Functions can be used to X manipulate all these variables. X X X 12.1 Constants X X X All constants and variable contents in EMACS are stored X as strings of characters. Numbers are stored digit by digit as X characters. This allows EMACS to be "typeless", not having X different variables types be legal in different contexts. This X has the disadvantage of forcing the user to be more carefull X about the context of the statements variables are placed in, but X in turn gives them more flexibility in where they can place X variables. Needless to say, this also allows EMACS's expression X evaluator to be both consice and quick. X X X 45 X X X X X X X MicroEMACS Reference Manual MicroEMACS Macros X X X Wherever statements need to have arguments, it is legal X to place constants. A constant is a double quote character, X followed by a string of characters, and terminated by another X double quote character. To represent various special characters X within a constant, the tilde (~) character is used. The character X following the tilde is interpeted according to the following X table: X X Sequence Result X ~n ^J linefeed/newline, (EMACS newline character) X ~r ^M carraige return X ~~ ~ X ~b ^H backspace X ~f ^L formfeed X ~t ^I tab X ~" " X X Any character not in the table which follows a tilde will X be passed unmodified. This action is similar to the ^Q quote- X character command available from the keyboard. X X The double quotes around constants are not needed if the X constant contains no internal whitespace and it also does not X happen to meet the rules for any other EMACS commands, X directives, variables, or functions. This is reasonable useful X for numeric constants. X X X 12.2 Variables X X X Variables in MicroEMACS can be used to return values X within expressions, as repeat counts to editing commands, or as X text to be inserted into buffers and messages. The value of X these variables is set using the set (^X-A) command. For X example, to set the current fill column to 64 characters, the X following macro line would be used: X X set $fillcol 64 X X or to have the contents of %name inserted at the point in X the current buffer, the command to use would be: X X insert-string %name X X X X X X X X X X X X X 46 X X X X X X X MicroEMACS Macros MicroEMACS Reference Manual X X X X 12.2.1 Environmental Variables X X X "What good is a quote if you can't change it?" X X These variables are used to change different aspects of X the way the editor works. Also they will return the current X settings if used as part of an expression. All environmental X variable names begin with a dollar sign ($) and are in lower X case. X X $acount The countdown of inserted characters until the X next save-file. X X $asave The number of inserted characters between X automatic file-saves in ASAVE mode. X X $cbufname Name of the current buffer X X $cfname File name of the current buffer X X $cmode Integer containing the mode of the current buffer. X (See Appendix F for values) X X $curchar Character currently at the point X X $curcol Current column of point in current buffer X X $curline Current line of point in current buffer X X $curwidth Number of columns used currently X X $cwline Current display line in current window X X $debug Flag to trigger macro debugging (try it... you'll X like it!) X X $discmd Flag to disable the echoing of messages on the X command line X X $disinp Flag to disable the echoing of characters during X command line input X X $fillcol Current fill column X X $flicker Flicker Flag set to TRUE if IBM CGA set to FALSE X for most others X X $gflags Global flags controlling some EMACS internal X functions (See appendix G for details) X X $gmode Global mode flags. (See Appendix F for values) X X X X 47 X X X X X X X MicroEMACS Reference Manual MicroEMACS Macros X X X $lastkey [READ ONLY]Last keyboard character typed X X $line The current line in the current buffer can be X retrieved and set with this environment variable X X $lwidth [READ ONLY]Returns the number of characters in the X current line X X $match [READ ONLY]Last string matched in a magic mode X search X X $pagelen Number of screen lines used currently X X $palette string used to control the palette register X settings on graphics versions. The usually form X consists of groups of three octal digits setting X the red, green, and blue levels. X X $pending [READ ONLY]Flag to determine if there are user X keystrokes waiting to be processed. X X $progname [READ ONLY]Always contains the string "MicroEMACS" X for standard MicroEMACS. Could be something else X if EMACS is incorporated as part of someone else's X program X X $replace Current default replace string X X $rval This contains the return value from the last X subprocess which was invoked from EMACS X X $search Current default search string X X $seed Integer seed of the random number generator X X $sres Current screen resolution (CGA, MONO or EGA on the X IBM-PC driver. LOW, MEDIUM, HIGH or DENSE on the X Atari ST1040, NORMAL on all others) X X $status [READ ONLY]Status of the success of the last X command (TRUE or FALSE). This is usually used X with !force to check on the success of a search, X or a file operation. X X $target Current target for line moves (setting this fool's X EMACS into believing the last command was a line X move) X X $tpause Controls the length of the pause to display a X matched fence when the current buffer is in CMODE X and a close fence has been typed X X $version [READ ONLY]Contains the current MicroEMACS version X number X X X 48 X X X X X X X MicroEMACS Macros MicroEMACS Reference Manual X X X $wline Number of display lines in current window X X Obviously, many more of these variables will be availible X in future releases of MicroEMACS. (Yes, send a vote for your X favorite new environmental variables today). X X X 12.2.2 User variables X X X User variables allow you, the user, to store strings and X manipulate them. These strings can be pieces of text, numbers X (in text form), or the logical values TRUE and FALSE. These X variables can be combined, tested, inserted into buffers, and X otherwise used to control the way your macros execute. At the X moment, up to 255 user variables may be in use in one editing X session. All users variable names must begin with a percent sign X (%) and may contain any printing characters. Only the first 10 X characters are significant (ie differences beyond the tenth X character are ignored). Most operators will truncate strings to X a length of 128 characters. X X X 12.2.3 Buffer Variables X X X Buffer variables are special in that they can only be X queried and cannot be set. What buffer variables are is a way to X take text from a buffer and place it in a variable. For example, X if I have a buffer by the name of RIGEL2, and it contains the X text: X X Richmond X Lafayette X <*>Bloomington (where <*> is the current point) X Indianapolis X Gary X =* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt ===== X X and within a command I reference #rigel2, like: X X insert-string #rigel2 X X MicroEMACS would start at the current point in the RIGEL2 X buffer and grab all the text up to the end of that line and pass X that back. Then it would advance the point to the beginning of X the next line. Thus, after our last command executes, the string X "Bloomington" gets inserted into the current buffer, and the X buffer RIGEL2 now looks like this: X X X X X X X X 49 X X X X X X X MicroEMACS Reference Manual MicroEMACS Macros X X X Richmond X Lafayette X Bloomington X <*>Indianapolis (where <*> is the current point) X Gary X =* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt ===== X X as you have probably noticed, a buffer variable consists X of the buffer name, preceded by a pound sign (#). X X X 12.2.4 Interactive variables X X X Interactive variables are actually a method to prompt the X user for a string. This is done by using an at sign (@) followed X either with a quoted string, or a variable containing a string. X The string is the placed on the bottom line, and the editor waits X for the user to type in a string. Then the string typed in by X the users is returned as the value of the interactive variable. X For example: X X set %quest "What file? " X find-file @%quest X X will ask the user for a file name, and then attempt to X find it. Note also that complex expressions can be built up with X these operators, such as: X X @&cat &cat "File to decode[" %default "]: " X X which prompts the user with the concatinated string. X X X 12.3 Functions X X X Functions can be used to manipulate variables in various X ways. Functions can have one, two, or three arguments. These X arguments will always be placed after the function on the current X command line. For example, if we wanted to increase the current X fill column by two, using emacs's set (^X-A) command, we would X write: X X set $fillcol &add $fillcol 2 X \ \ \ \ \____second operand X \ \ \ \_________first operand X \ \ \_______________function to execute X \ \_____________________variable to set X \___________________________set (^X-A) command X X Function names always begin with the ampersand (&) X character, and are only significant to the first three characters X after the ampersand. Functions will normal expect one of three X X X 50 X X X X X X X MicroEMACS Macros MicroEMACS Reference Manual X X X types of arguments, and will automatically convert types when X needed. X X <num> an ascii string of digits which is interpeted as a X numeric value. Any string which does not start X with a digit or a minus sign (-) will be X considered zero. X X <str> An arbitrary string of characters. At the moment, X strings are limited to 128 characters in length. X X <log> A logical value consisting of the string "TRUE" or X "FALSE". Numeric strings will also evaluate to X "FALSE" if they are equal to zero, and "TRUE" if X they are non-zero. Arbitrary text strings will X have the value of "FALSE". X X A list of the currently availible functions follows: X (Once again, send in those votes on what kind of functions you X would like to see added!) Functions are always used in lower X case, the uppercase letters in the function table are the short X form of the function (ie &div for ÷). X X Numeric Functions: (returns <num>) X X &ADD <num> <num> Add two numbers X &SUB <num> <num> Subtract the second number from the first X &TIMes <num> <num> Multiply two numbers X &DIVide <num> <num> Divide the first number by the second X giving an integer result X &MOD <num> <num> Return the reminder of dividing the X first number by the second X &NEGate <neg> Multiply the arg by -1 X &LENgth <str> Returns length of string X &SINdex <str1> <str2> Finds the position of <str2> within X <str1>. Returns zero if not found. X &ASCii <str> Return the ascii code of the first X character in <str> X &RND <num> Returns a random integer between 1 and X <num> X &ABS <num> Returns the absolute value of <num> X &BANd <num> <num> Bitwise AND function X &BOR <num> <num> Bitwise OR function X &BXOr <num> <num> Bitwise XOR function X &BNOt <num> Bitwise NOT function X X String manipulation functions: (returns <str>) X X &CAT <str> <str> Concatinate the two strings to form one X &LEFt <str> <num> return the <num> leftmost characters X from <str> X &RIGht <str> <num> return the <num> rightmost characters X from <str> X X X X 51 X X X X X X X MicroEMACS Reference Manual MicroEMACS Macros X X X &MID <str> <num1> <num2> X Starting from <num1> position in <str>, X return <num2> characters. X &UPPer <str> Uppercase <str> X &LOWer <str> lowercase <str> X &CHR <num> return a string with the character X represented by ascii code <num> X >K return a string containing a single X keystroke from the user X &ENV <str> If the operating system is capable, this X returns the environment string associated X with <str> X &BIND <str> return the function name bound to the X keystroke <str> X &ENV <str> Returns the operating system value X attached to environmental variable <str> X &FINd <str> Find the named file <str> along the X path and return its full file specification X or an empty string if none exists X X Logical Testing functions: (returns <log>) X X &NOT <log> Return the opposite logical value X &AND <log1> <log2> Returns TRUE if BOTH logical arguments X are TRUE X &OR <log1> <log2> Returns TRUE if either argument X is TRUE X &EQUal <num> <num> If <num> and <num> are numerically X equal, return TRUE X &LESs <num1> <num2> If <num1> is less than <num2>, return X TRUE. X &GREater <num1> <num2> If <num1> is greater than, or equal to X <num2>, return TRUE. X &SEQual <str1> <str2> If the two strings are the same, return X TRUE.
nwd@j.cc.purdue.edu (Daniel Lawrence) (11/26/87)
X &SLEss <str1> <str2> If <str1> is less alphabetically than X <str2>, return TRUE. X &SGReater <str1> <str2> If <str1> is alphabetically greater than X or equal to <str2>, return TRUE. X &FINd <str> Does the named file <str> exist? X X Special Functions: X X &INDirect <str> Evaluate <str> as a variable. X X This last function deserves more explanation. The &IND X function evaluates its argument, takes the resulting string, and X then uses it as a variable name. For example, given the X following code sequence: X X ; set up reference table X X set %one "elephant" X set %two "giraffe" X X X 52 X X X X X X X MicroEMACS Macros MicroEMACS Reference Manual X X X set %three "donkey" X X set %index "two" X insert-string &ind %index X X the string "giraffe" would have been inserted at the X point in the current buffer. This indirection can be safely X nested up to about 10 levels. X X X 12.4 Directives X X X Directives are commands which only operate within an X executing macro, ie they do not make sense as a single command. X As such, they cannot be called up singly or bound to keystroke. X Used within macros, they control what lines are executed and in X what order. X X Directives always start with the exclamation mark (!) X character and must be the first thing placed on a line. X Directives executed interactively (via the execute-command-line X command) will be ignored. X X X 12.4.1 !ENDM Directive X X X This directive is used to terminate a macro being stored. X For example, if a file is being executed contains the text: X X ; Read in a file in view mode, and make the window red X X 26 store-macro X find-file @"File to view: " X add-mode "view" X add-mode "red" X !endm X X write-message "[Consult macro has been loaded]" X X only the lines between the store-macro command and the X !ENDM directive are stored in macro 26. Both numbered macroes X and named procedures (via the store-procedure command) should be X terminated with this directive. X X X 12.4.2 !FORCE Directive X X X When MicroEMACS executes a macro, if any command fails, X the macro is terminated at that point. If a line is preceeded by X a !FORCE directive, execution continues weather the command X succeeds or not. For example: X X X 53 X X X X X X X MicroEMACS Reference Manual MicroEMACS Macros X X X ; Merge the top two windows X X save-window ;remember what window we are at X 1 next-window ;go to the top window X delete-window ;merge it with the second window X !force restore-window ;This will continue regardless X add-mode "red" X X X 12.4.3 !IF, !ELSE, and !ENDIF Directives X X X This directive allows statements only to be executed if a X condition specified in the directive is met. Every line X following the !IF directive, until the first !ELSE or !ENDIF X directive, is only executed if the expression following the !IF X directive evaluates to a TRUE value. For example, the following X macro segment creates the portion of a text file automatically. X (yes believe me, this will be easier to understand then that last X explanation....) X X !if &sequal %curplace "timespace vortex" X insert-string "First, rematerialize~n" X !endif X !if &sequal %planet "earth" ;If we have landed on earth... X !if &sequal %time "late 20th century" ;and we are then X write-message "Contact U.N.I.T." X !else X insert-string "Investigate the situation....~n" X insert-string "(SAY 'stay here Sara')~n" X !endif X !else X set %conditions @"Atmosphere conditions outside? " X !if &sequal %conditions "safe" X insert-string &cat "Go outside......" "~n" X insert-string "lock the door~n" X !else X insert-string "Dematerialize..try somewhen else" X newline X !endif X !endif X X X 12.4.4 !GOTO Directive X X X Flow can be controlled within a MicroEMACS macro using X the !GOTO directive. It takes as an argument a label. A label X consists of a line starting with an asterisk (*) and then an X alphanumeric label. Only labels in the currently executing macro X can be jumped to, and trying to jump to a non-existing label X terminates execution of a macro. For example.. X X ;Create a block of DATA statements for a BASIC program X X X 54 X X X X X X X MicroEMACS Macros MicroEMACS Reference Manual X X X insert-string "1000 DATA " X set %linenum 1000 X X *nxtin X update-screen ;make sure we see the changes X set %data @"Next number: " X !if &equal %data 0 X !goto finish X !endif X X !if &greater $curcol 60 X 2 delete-previous-character X newline X set %linenum &add %linenum 10 X insert-string &cat %linenum " DATA " X !endif X X insert-string &cat %data ", " X !goto nxtin X X *finish X X 2 delete-previous-character X newline X X X 12.4.5 !WHILE and !ENDWHILE Directives X X X This directive allows you to set up repetitive tasks X easily and efficiently. If a group of statements need to be X executed while a certain condition is true, enclose them with a X while loop. For example, X X !while &less $curcol 70 X insert-string &cat &cat "[" #stuff "]" X !endwhile X X places items from buffer "item" in the current line until X the cursor is at or past column 70. While loops may be nested X and can contain and be the targets of !GOTOs with no ill effects. X Using a while loop to enclose a repeated task will run much X faster than the corresponding construct using !IFs. X X X 12.4.6 !BREAK Directive X X X This directive allows the user to abort out of the X currently most inner while loop, regardless of the condition. It X is often used to abort processing for error conditions. For X example: X X ; Read in files and substitute "begining" with "beginning" X X X 55 X X X X X X X MicroEMACS Reference Manual MicroEMACS Macros X X X set %filename #list X !while ¬ &seq %filename "<end>" X !force find-file %filename X !if &seq $status FALSE X write-message "[File read error]" X !break X !endif X beginning-of-file X replace-string "begining" "beginning" X save-file X set %filename #list X !endwhile X X This while loop will process files until the list is X exhausted or there is an error while reading a file. X X X 12.4.7 !RETURN Directive X X X The !RETURN Directive causes the current macro to exit, X either returning to the caller (if any) or to interactive mode. X For example: X X ; Check the monitor type and set %mtyp X X !if &sres "CGA" X set %mtyp 1 X !return X !else X set %mtyp 2 X !endif X X insert-string "You are on a MONOCHROME machine!~n" X X X X X X X X X X X X X X X X X X X X X X X 56 X X X X X X X MicroEMACS Command Line Switches and Startup Files MicroEMACS X Reference Manual X X X X X X X X X Appendix A X X MicroEMACS Command Line Switches and Startup Files X X X When EMACS first executes, it always searches for a file, X called .emacsrc under most UNIX systems or emacs.rc on most other X systems which it will execute as EMACS macros before it reads in X the named source files. This file normally contains EMACS macroes X to bind the function keys to useful functions and load various X usefull macros. The contents of this file will probably vary X from system to system and can be modified by the user as desired. X X When searching for this file, EMACS looks for it in this X order. First, it attempts to find a definition for "HOME" in the X environment. It will look in that directory first. Then it X searches all the directories listed in the "PATH" environment X variable. Then it looks through a list of predefined standard X directories which vary from system to system. Finally, failing X all of these, it looks in the current directory. This is also X the same method EMACS uses to look up any files to execute, and X to find it's help file EMACS.HLP. X X On computers that call up EMACS via a command line X process, such as MSDOS and UNIX, there are different things that X can be added to the command line to control the way EMACS X operates. These can be switches, which are a dash ('-') followed X by a letter, and possible other parameters, or a startup file X specifier, which is an at sign '@' followed by a file name. X X @<file> This causes the named file to be executed instead X of the standard emacs.rc file before emacs reads X in any other files. More than one of these can be X placed on the command line, and they will be X executed in the order that they appear. X X -A This flag causes emacs to automatically run the X startup file "error.cmd" instead of emacs.rc. This X is used by various C compilers for error X processing (for example, Mark Williams C). X X -E The following source files on the command line can X be edited (as opposed to being in VIEW mode). This X is mainly used to cancel the effects of the -v X switch used previously in the same command line. X X X X X 57 X X X X X X X MicroEMACS Reference Manual MicroEMACS Command Line Switches and X Startup Files X X X -G<num> Upon entering EMACS, position the cursor at the X <num> line of the first file. X X -K<key> This key tells emacs to place the source files in X CRYPT mode and read it in using <key> as the X encryption key. If no key is listed immediatly X after the -K switch, EMACS will prompt for a key, X and not echo it as it is typed. X X -R This places EMACS in "restricted mode" where any X commands allowing the user to read or write any X files other than the ones listed on the command X line are disabled. Also all commands allowing the X user access to the operating system are disabled. X This makes EMACS very useful as a "safe" X environment for use within other applications and X especially used as a remote editor for a BBS or X electronic bulletin board system. X X -S<string> After EMACS is started, it automatically searches X for <string> in the first source file. X X -V This tells EMACS that all the following sources X files on the command line should be in VIEW mode X to prevent any changes being made to them. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 58 X X X X X X X MicroEMACS commands MicroEMACS Reference Manual X X X X X X X X X Appendix B X X MicroEMACS commands X X X Below is a complete list of the commands in EMACS, the X keys normally used to do the command, and what the command does. X Remember, on some computers there may also be additional ways of X using a command (cursor keys and special function keys for X example). X X Command Binding Meaning X abort-command ^G This allows the user to abort out of any X command that is waiting for input X X add-mode ^X-M Add a mode to the current buffer X X add-global-mode M-M Add a global mode for all new buffers X X apropos M-A List out commands whose name contains X the string specified X X backward-character ^B Move one character to the left X X begin-macro ^X-( Begin recording a keyboard macro X X beginning-of-file M-< Move to the beginning of the file in X the current buffer X X beginning-of-line ^A Move to the beginning of the current line X X bind-to-key M-K Bind a key to a function X X buffer-position ^X-= List the position of the cursor in the X current window on the command line X X case-region-lower ^X-^L Make a marked region all lower case X X case-region-upper ^X-^U Make a marked region all upper case X X case-word-capitalize M-C Capitalize the following word X X case-word-lower M-L Lower case the following word X X case-word-upper M-U Upper case the following word X X change-file-name ^X-N Change the name of the file in the X current buffer X X X 59 X X X X X X X MicroEMACS Reference Manual MicroEMACS commands X X X change-screen-size M-^S Change the number of lines of the screen X currently being used X X change-screen-width M-^T Change the number of columns of the X screen currently being used X X clear-and-redraw ^L Clear the physical screen and redraw it X X clear-message-line (none) Clear the command line X X copy-region M-W Copy the currently marked region into X the kill buffer X X count-words M-^C Count how many words, lines and X characters are in the current marked region X X ctlx-prefix ^X Change the key used as the ^X prefix X X delete-blank-lines ^X-^O Delete all blank lines around the cursor X X delete-buffer ^X-K Delete a buffer which is not being X currently displayed in a window X X delete-mode ^X-^M Turn off a mode in the current buffer X X delete-global-mode M-^M Turn off a global mode X X delete-next-character ^D Delete the character following the cursor X X delete-next-word M-D Delete the word following the cursor X X delete-other-windows ^X-1 Make the current window cover the entire X screen X X delete-previous-character^H Delete the character to the left of the X cursor X X delete-previous-word M-^H Delete the word to the left of the cursor X X delete-window ^X-0 Remove the current window from the screen X X describe-bindings (none) Make a list of all legal commands X X describe-key ^X-? Describe what command is bound to a X keystroke sequence X X detab-line ^X-^D Change all tabs in a line to the X equivelant spaces X X end-macro ^X-) stop recording a keyboard macro X X end-of-file M-> Move cursor to the end of the current X buffer X X X X 60 X X X X X X X MicroEMACS commands MicroEMACS Reference Manual X X X end-of-line ^E Move to the end of the current line X X entab-line ^X-^E Change multiple spaces to tabs where X possible X X exchange-point-and-mark ^X-^X Move cursor to the last marked spot, X make the original position be marked X X execute-buffer (none) Execute a buffer as a macro X X execute-command-line (none) Execute a line typed on the command X line as a macro command X X execute-file FNB Execute a file as a macro X X execute-macro ^X-E Execute the keyboard macro (play back X the recorded keystrokes) X execute-macro-<n> (none) Execute numbered macro <N> where <N> is X an integer from 1 to 40 X X execute-named-command M-X Execute a command by name X X execute-procedure M-^E Execute a procedure by name X X execute-program ^X-$ Execute a program directly (not through X an intervening shell) X X exit-emacs ^X-^C Exit EMACS. If there are unwritten, X changed buffers EMACS will ask to confirm X X fill-paragraph M-Q Fill the current paragraph X X filter-buffer ^X-# Filter the current buffer through an X external filter X X find-file ^X-^F Find a file to edit in the current window X X forward-character ^F Move cursor one character to the right X X goto-line M-G Goto a numbered line X X goto-matching-fence M-^F Goto the matching fence X X grow-window ^X-^ Make the current window larger X X handle-tab ^I Insert a tab or set tab stops X X hunt-forward FN= Hunt for the next match of the last X search string X X hunt-backward FN> Hunt for the last match of the last X search string X X help M-? Read EMACS.HLP into a buffer and display it X X X 61 X X X X X X X MicroEMACS Reference Manual MicroEMACS commands X X X i-shell ^X-C Shell up to a new command processor X X incremental-search ^X-S Search for a string, incrementally X X insert-file ^X-^I insert a file at the cursor in the X current file X X insert-space ^C Insert a space to the right of the cursor X X insert-string (none) Insert a string at the cursor X X kill-paragraph M-^W Delete the current paragraph X X kill-region ^W Delete the current marked region, moving X it to the kill buffer X X kill-to-end-of-line ^K Delete the rest of the current line X X list-buffers ^X-^B List all existing buffers X X meta-prefix <ESC> Key used to precede all META commands X X move-window-down ^X-^N Move all the lines in the current window X down X X move-window-up ^X-^P Move all the lines in the current window up X X name-buffer M-^N Change the name of the current buffer X X newline ^M Insert a <NL> at the cursor X X newline-and-indent ^J Insert a <NL> at the cursor and indent X the new line the same as the preceeding X line X X next-buffer ^X-X Bring the next buffer in the list into X the current window X X next-line ^N Move the cursor down one line X X next-page ^V Move the cursor down one page X X next-paragraph M-N Move cursor to the next paragraph X X next-window ^X-O Move cursor to the next window X X next-word M-F Move cursor to the beginning of the X next word X X nop M-FNC Does nothing X X open-line ^O Open a line at the cursor X X overwrite-string (none) Overwrite a string at the cursor X X X 62 X X X X X X X MicroEMACS commands MicroEMACS Reference Manual X X X pipe-command ^X-@ Execute an external command and place X its output in a buffer X X previous-line ^P Move cursor up one line X X previous-page ^Z Move cursor up one page X X previous-paragraph M-P Move back one paragraph X X previous-window ^X-P Move the cursor to the last window X X previous-word M-B Move the cursor to the beginning of the X word to the left of the cursor X X query-replace-string M-^R Replace all of one string with another X string, interactively querying the user X X quick-exit M-Z Exit EMACS, writing out all changed buffers X X quote-character ^Q Insert the next character literally X X read-file ^X-^R Read a file into the current buffer X X redraw-display M-^L Redraw the display, centering the X current line X X resize-window ^X-W Change the number of lines in the X current window X X restore-window (none) Move cursor to the last saved window X X replace-string M-R Replace all occurences of one string X with another string from the cursor X to the end of the buffer X X reverse-incremental-search^X-R Search backwards, incrementally X X run M-^E Execute a named procedure X X save-file ^X-^S Save the current buffer if it is changed X X save-window (none) Remember current window (to restore later) X X scroll-next-up M-^Z Scroll the next window up X X scroll-next-down M-^V Scroll the next window down X X search-forward ^S Search for a string X X search-reverse ^R Search backwards for a string X X select-buffer ^X-B Select a buffer to display in the X current window X X X X 63 X X X X X X X MicroEMACS Reference Manual MicroEMACS commands X X X set ^X-A Set a variable to a value X X set-encryption-key M-E Set the encryption key of the current X buffer X X set-fill-column ^X-F Set the current fill column X X set-mark Set the mark X X shell-command ^X-! Causes an external shell to execute X a command X X shrink-window ^X-^Z Make the current window smaller X X split-current-window ^X-2 Split the current window in two X X store-macro (none) Store the following macro lines to a X numbered macro X X store-procedure (none) Store the following macro lines to a X named procedure X X transpose-characters ^T Transpose the character at the cursor X with the character to the left X X trim-line ^X-^T Trim any trailing whitespace from line X X unbind-key M-^K Unbind a key from a function X X universal-argument ^U Execute the following command 4 times X X unmark-buffer M-~ Unmark the current buffer (so it is X no longer changed) X X update-screen (none) Force a screen update during macro X execution X X view-file ^X-^V Find a file,and put it in view mode X X wrap-word M-FNW Wrap the current word, this is an X internal function X X write-file ^X-^W Write the current buffer under a new X file name X X write-message (none) Display a string on the command line X X yank ^Y yank the kill buffer into the current X buffer at the cursor X X X X X X X X 64 X X X X X X X MicroEMACS Bindings MicroEMACS Reference Manual X X X X X X X X X Appendix C X X MicroEMACS Bindings X X X Below is a complete list of the key bindings used in X MicroEMACS. This can be used as a wall chart reference for X MicroEMACS commands. X X Default Key Bindings for MicroEmacs 3.9e X X ^A Move to start of line ESC A Apropos (list some commands) X ^B Move backward by characters ESC B Backup by words X ^C Insert space ESC C Initial capitalize word X ^D Forward delete ESC D Delete forward word X ^E Goto end of line ESC E Reset Encryption Key X ^F Move forward by characters ESC F Advance by words X ^G Abort out of things ESC G Go to a line X ^H Backward delete X ^I Insert tab/Set tab stops X ^J Insert <NL>, then indent X ^K Kill forward ESC K Bind Key to function X ^L Refresh the screen ESC L Lower case word X ^M Insert <NL> ESC M Add global mode X ^N Move forward by lines ESC N Goto End paragraph X ^O Open up a blank line X ^P Move backward by lines ESC P Goto Begining of paragraph X ^Q Insert literal ESC Q Fill current paragraph X ^R Search backwards ESC R Search and replace X ^S Search forward X ^T Transpose characters X ^U Repeat command four times ESC U Upper case word X ^V Move forward by pages ESC V Move backward by pages X ^W Kill region ESC W Copy region to kill buffer X ^Y Yank back from killbuffer ESC X Execute named command X ^Z Move backward by pages ESC Z Save all buffers and exit X X ESC ^C Count words in region ESC ~ Unmark current buffer X ESC ^E Execute named procedure X ESC ^F Goto matching fence ESC ! Reposition window X ESC ^H Delete backward word ESC < Move to start of buffer X ESC ^K Unbind Key from function ESC > Move to end of buffer X ESC ^L Reposition window ESC . Set mark X ESC ^M Delete global mode ESC space Set mark X ESC ^N Rename current buffer ESC rubout Delete backward word X ESC ^R Search & replace w/query rubout Backward delete X ESC ^S Change screen rows X ESC ^T Change screen columns X X X 65 X X X X X X X MicroEMACS Reference Manual MicroEMACS Bindings X X X ESC ^V Scroll next window down X ESC ^W Delete Paragraph X ESC ^Z Scroll next window up X X ^X ? Describe a key ^X ! Run 1 command in a shell X ^X = Show the cursor position ^X @ Pipe shell command to buffer X ^X ^ Enlarge display window ^X # Filter buffer thru shell filter X ^X 0 Delete current window ^X $ Execute an external program X ^X 1 Delete other windows ^X ( Begin macro X ^X 2 Split current window ^X ) End macro X ^X A Set variable value X ^X ^B Display buffer list ^X B Switch a window to a buffer X ^X ^C Exit MicroEMACS ^X C Start a new command processor X ^X ^D Detab line ^X D Suspend MicroEMACS (BSD4.2 only) X ^X ^E Entab line ^X E Execute macro X ^X ^F Find file ^X F Set fill column X ^X ^I Insert file X ^X K Delete buffer X ^X ^L Lower case region X ^X ^M Delete Mode ^X M Add a mode X ^X ^N Move window down ^X N Rename current filename X ^X ^O Delete blank lines ^X O Move to the next window X ^X ^P Move window up ^X P Move to the previous window X ^X ^R Get a file from disk ^X R Incremental reverse search X ^X ^S Save current file ^X S Incremental forward search X ^X ^T Trim line (Incremental search X ^X ^U Upper case region not always availible) X ^X ^V View file X ^X ^W Write a file to disk ^X W resize Window X ^X ^X Swap "." and mark ^X X Use next buffer X ^X ^Z Shrink window ^X Z Enlarge display window X X Usable Modes X WRAP Lines going past right margin "wrap" to a new line X VIEW Read-Only mode where no modifications are allowed X CMODE Change behavior of some commands to work better with C X EXACT Exact case matching on search strings X OVER Overwrite typed characters instead of inserting them X CRYPT Current buffer will be encrypted on write, decrypted on read X MAGIC Use regular expression matching in searches X ASAVE Save the file every 256 inserted characters X X WHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK Sets foreground color X white/cyan/magenta/yellow/blue/red/green/black Sets background color X X X X X X X X X X X X X 66 X X X X X X X Supported machines MicroEMACS Reference Manual X X X X X X X X X Appendix D X X Supported machines X X X The following table lists all the hardware/compilers for X which I currently support MicroEMACS. This is not exclusive of X all machines which MicroEMACS will run on, but I have either run X it myself, or had a first hand report of it running. X X Hardware OS Compiler Comments X VAX 780 UNIX V5 native X UNIX V7 native X BSD 4.2 native job control supported X *VMS native only some terminals X supported X X NCR Tower UNIX V5 native X X Fortune 32:16 UNIX V7 native X X IBM-PC MSDOS LATTICE 2.15 Large CODE/Large DATA X 2.0 & 3.2 AZTEC 3.4e Small CODE/Large DATA X TURBO C v1.00 LARGE memory model X *MSC 4.0 X *MWC 86 X SCO XENIX native X X HP150 MSDOS Lattice 2.15 Function key labels X for the touch screen X X HP110 MSDOS Lattice 2.15 X Aztec 3.4e X X *Data General 10 X MSDOS Lattice 2.15 X X *Texas Instruments Professional X MSDOS Lattice 2.15 X X Amiga Intuition Lattice 3.03 no mouse or menus yet X *Aztec 3 X X ST520 TOS Mark Williams C Spawns under MSH X Lattice 3.10 (no shell commands) X X Systems to be supported (ie some code is already written:) X Macintosh Finder 5.0 Aztec X X X 67 X X X X X X X MicroEMACS Reference Manual Supported machines X X X *means that I do not own or have access to the listed compiler and/or X machine and must rely upon others to help support it. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 68 X X X X X X X Machine Dependent Notes MicroEMACS Reference Manual X X X X X X X X X Appendix E X X Machine Dependent Notes X X X This appendix lists some notes specific to individual X implementations of MicroEMACS. Every attempt has been made to X allow EMACS to be identical on all machines, but we have also X tried to take advantage of function keys, cursor keys, mice, and X special screen modes where possible. X X X E.1 IBM-PC/XT/AT and its clones X X X The IBM-PC family of computers is supported with a X variety of different display adapters. EMACS will attempt to X discover what adapter is connected and use the proper driver for X it. Below is a list of the currently supported video adapters: X X Adapter $sres Original mode used X Monochrome Graphics Adapter MONO MONO X Color Graphics Adapter CGA CGA X Enhanced Graphics Adapter EGA CGA X X EMACS also takes advantege of various function keys and X the keys on the keypad on an IBM-PC. The function keys are X initially not bound to any particular functions (except by the X emacs.rc startup file), but the keypad keys do default to the X following: X X Keypad key Function X Home beginning-of-file X CSRS UP previous-line X Pg Up previous-page X CSRS LEFT backward-character X CSRS RIGHT forward-character X End end-of-file X CSRS DOWN next-line X Pg Dn Next-page X X All these special keys are indicated in EMACS macroes by X use of the FN prefix. Below is a list of many of the keys and X the codes used to specify them. Also the codes may be gotten by X using the describe-key (^X ?) command on the suspect key. X X X X X X 69 X X X X X X X MicroEMACS Reference Manual Machine Dependent Notes X X X IBM PC function keys in MicroEmacs X X function Function ^function Alt-function X f1) FN; FNT FN^ FNh X f2) FN< FNU FN_ FNi X f3) FN= FNV FN` FNj X f4) FN> FNW FNa FNk X f5) FN? FNX FNb FNl X f6) FN@ FNY FNc FNm X f7) FNA FNZ FNd FNn X f8) FNB FN[ FNe FNo X f9) FNC FN\ FNf FNp X f10) FND FN] FNg FNq X X home) FNG FNw X CsUp) FNH X PgUp) FNI FNa(umlaut) {Alt 132} X CsLf) FNK FNs X 5 ) X CsRt) FNM FNt X End) FNO FNu X CsDn) FNP X PgDn) FNQ FNv X Ins) FNR X Del) FNS X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 70 X X X X X X X Machine Dependent Notes MicroEMACS Reference Manual X X X X X E.2 HP 150 X X X This machine from Hewlett Packard is very unusual for an X MSDOS machine. It has a touch screen and is very function key X oriented. An additional command, label-function-key allows you X to place labels on the on screen function key labels. A numeric X argument indicates which function key to label (one through X eight) and then the program prompts for a 16 character label, X which will be used as two lines of eight characters. To label X function key three with "save file" from a macro, you would use: X X 3 label-function-key "save file" X X Notice the 4 spaces after "save". This forces "file" to X begin on the second line of the label. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 71 X X X X X X X MicroEMACS Reference Manual Machine Dependent Notes X X X X X E.3 Atari 520/1040ST X X X The ATARI ST family of computers have a dual personality. X They may use either a monochrome or a color screen. EMACS X supports two screen resolutions on each monitor. X X Monitor $sres size #color $palette format X Color LOW 40x25 16 000111222333444555666777 X MEDIUM 80x25 4 000111222333 X Mono HIGH 80x25 2 000 X DENSE 80x50 2 000 X X The $palette environment variable can be used to change X what color is associated with each color name. With a color X monitor, each group of three digits indicates an octal number X specifying the RED, GREEN and BLUE levels of that color. Each X color digit can vary from 0 to 7. For example, the initial X setting of $palette in LOW resolution is: X X 000700070770007707077777 X X which broken up is: X X 000 700 070 770 007 707 077 777 X X which means: X X 000 Black X 700 Red X 070 Green X 770 Yellow X 007 Blue X 707 Magenta X 077 Cyan X 777 White X X Also the mouse generates FN prefix codes when moved, or X when one of the two buttons is pressed. Initially the movement of X the mouse is bound to movement of the cursor, and the left mouse X button generates a set-mark (M-space) command. The cursor keys X and the function keys are bound similarly to to IBM-PC. X X Files generated by EMACS on the ATARI ST have a single X return character at the end of each line, unlike the desktop X files which want to have tow returns. This makes it display files X strangly from GEM's [SHOW] option, but makes the files port to X other computers much nicer. X X Currently, when operating under the Mark Williams MSH X program, EMACS can shell out and perform external commands. This X X X X 72 X X X X X X X Machine Dependent Notes MicroEMACS Reference Manual X X X capability will be added later for the Beckmeyer shell and under X GEMDOS. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 73 X X X X X X X MicroEMACS Reference Manual Machine Dependent Notes X X X X X E.4 Amiga 1000 X X X The Commodore AMIGA 1000 version of MicroEMACS does not X have extensive support of the mouse or of pull down menus as of X yet. It does however come up in a window, and it is possible to X re-size it to run in different sized windows. The M-^S change- X screen-size takes its numeric argument as the new number of lines X for EMACS to use. The M-^T change-screen-width command allows X you to change the number of columns EMACS will use. The defaults X for these are 23 lines and 77 characters across for a full screen X window. X X Note about Compiling MicroEMACS X X If you are compiling the sources on the AMIGA X to produce an executable image, and you are using the X Lattice compiler, be sure to give the CLI command X 'STACK 40000' before compiling to make sure the X compiler has sufficient stack space to successfully X complete compiliation. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 74 X X X X X X X Machine Dependent Notes MicroEMACS Reference Manual X X X X X E.5 UNIX V5, V7, and BSD4.[23] X X X MicroEMACS under UNIX utilizes the TERMCAP library to X provide machine independent screen functions. Make sure that X termcap is availible and properly set on your account before X attempting to use MicroEMACS. X X Under systems which support job control, you can use the X ^X-D suspend-emacs command to place EMACS into the background. X This carries a much smaller overhead than bringing up a new shell X under EMACS. EMACS will properly redraw the screen when you X bring it back to the foreground. X X If the symbol VT100 has been set to 1 in the estruct.h X options file, EMACS will recognize the key sequence <ESC>[ as the X lead in sequence for the FN function key prefix. X X With the addition of some very machine/operating system X specific code, EMACS can prevent two or more people from X modifying the same file at the same time. The upper level of a X set of functions to provide file locking exist in the source file X LOCK.C. It requires two machine specific functions written and X linked into EMACS for it to operate properly. X X char *dolock(fname) X X char *fname; X X dolock() locks a file, preventing others from modifying it. If X it succeeds, it returns NULL, otherwise it returns a pointer to X a string in the form "LOCK ERROR: explaination". X X char *undolock(fname) X X char *fname; X X undolock() unlocks a file, allowing others to modifying it. If X it succeeds, it returns NULL, otherwise it returns a pointer to X a string in the form "LOCK ERROR: explaination". X X X X X X X X X X X X X X X 75 X X X X X X X MicroEMACS Reference Manual Mode Flags X X X X X X X X X Appendix F X X Mode Flags X X X The two environment variables, $cmode and $gmode, contain X a number the corresponds to the modes set for the current buffer X and the editor as a whole. These are encoded as the sum of the X following numbers for each of the possible modes: X X WRAP 1 Word wrap X CMODE 2 C indentation and fence match X SPELL 4 Interactive spell checking (Not Implemented Yet) X EXACT 8 Exact matching for searches X VIEW 16 Read-only buffer X OVER 32 Overwrite mode X MAGIC 64 Regular expressions in search X CRYPT 128 Encrytion mode active X ASAVE 256 Auto-save mode X X So, if you wished to set the current buffer to have X CMODE, EXACT, and MAGIC on, and all the others off, you would add X up the values for those three, CMODE 2 + EXACT 8 + MAGIC 64 = X 74, and use a statement like: X X set $cmode 74 X X or, use the binary or operator to combine the different X modes: X X set $cmode &bor &bor 2 8 64 X X Internal Flags X X Some of the ways EMACS controls its internal functions X can be modified by the value in the $gflags environment variable. X Each bit in this variable will be used to control a different X function. X X GFFLAG 1 If this bit is set to zero, EMACS will not X automatically switch to the buffer of the X first file after executing the startup macros. X X X X X X X X X 76 X X X X X X X Index MicroEMACS Reference Manual X X X X X X X X X Index X X X .emacsrc 57 delete-mode 27 X <NL> 14 delete-next- X character 9 X A delete-next-word 9 X add-global-mode 27 delete-previous- X add-mode 3, 27 character 8 X ASAVE mode 27 delete-previous-word X 9 X B detab-line 38 X backward-character 4 X BBS 58 E X begin-macro 43 emacs.rc 57 X beginning-of-file 4, encryption 28 X 9 end-macro 43 X beginning-of-line 4 end-of-file 4 X buffer 5, 7, 24 end-of-line 4 X entab-lines 38 X C error parsing 57 X case-region-lower 37 EXACT mode 29 X case-word-capitalize execute-buffer 45 X 37 execute-file 45 X case-word-lower 37 execute-macro 43 X case-word-upper 37 execute-macro-<n> 45 X change-screen-size execute-procedure 45 X 74 execute-program 40 X change-screen-width exit-emacs 9 X 74 X CMODE mode 28 F X color 27 file locking 75 X command.com 40 fill-paragraph 8, 36 X command line 18 fill column 31 X command processor 40 filter 40 X control-x 1 find-file 19, 24 X control key 1 forward-character 4 X copy-region 12 X CRYPT mode 28, 58 G X cshell 40 grow-window 20 X cursor keys 4 X H X D handle-tab 38 X default string 15 Help File 57 X delete-blank-lines 9 HOME environment X delete-buffer 25 variable 57 X delete-global-mode X 27 X X X 77 X X X X X X X MicroEMACS Reference Manual Index X X X refresh-screen 21 X I replace-string 16, X i-shell 41 30 X resize-window 20 X K restricted mode 58 X kill-region 11 run 45 X kill-to-end-of-line X 9 S X kill buffer 12 save-file 5 X screen 7 X L scroll-next-down 19 X label-function-key scroll-next-up 19 X 71 search-forward 14 X list-buffers 25, 27 search-reverse 15 X select-buffer 24 X M set-encryption-key X MAGIC mode 29 28 X mark 11 set-fill-column 36 X meta key 1 set-mark 11 X mode line 2, 7 shell 40 X modes 3, 27 shell-command 40 X move-window-down 19 shrink-window 20 X move-window-up 19 special keys 1 X split-window 18 X N startup files 57 X newline 1 store-procedure 45 X next-buffer 24 suspend-emacs 41, 75 X next-line 4 switches 57 X next-paragraph 4 X T X O tab handling 38 X open-line 8 termcap 75 X open-window 18 text window 2 X OVER mode 30 X V X P VIEW mode 31 X PATH environment X variable 57 W X pipe-command 40 window 7 X point 11 windows 2, 18 X previous-line 4 Creating 18 X previous-paragraph 4 Deleting 19 X previous-window 18 Resizing 20 X previous-word 4 wrap-word 31 X procedures 45 WRAP mode 31 X wrapping text 36 X Q write-file 5 X query-replace 16 X query-replace-string Y X 16, 30 yank 12 X X R X redraw-display 20 X X X X 78 X X X X X X X X X X X X X Table of Contents X X X X X X Chapter 1 Basic Concepts 1 X 1.1 Keys and the Keyboard . . . . . . . . . . . . 1 X 1.2 Getting Started . . . . . . . . . . . . . . . 1 X 1.3 Parts and Pieces . . . . . . . . . . . . . . 2 X 1.4 Entering Text . . . . . . . . . . . . . . . . 3 X 1.5 Basic cursor movement . . . . . . . . . . . . 3 X 1.6 Saving your text . . . . . . . . . . . . . . 5 X X Chapter 2 Basic Editing--Simple Insertions and X Deletions 7 X 2.1 A Word About Windows, Buffers, Screens, and X Modes . . . . . . . . . . . . . . . . . . . . . . 7 X 2.2 Insertions . . . . . . . . . . . . . . . . . 8 X 2.3 Deletions . . . . . . . . . . . . . . . . . . 8 X X Chapter 3 Using Regions 11 X 3.1 Defining and Deleting a Region . . . . . . 11 X 3.2 Yanking a Region . . . . . . . . . . . . . 12 X X Chapter 4 Search and Replace 14 X 4.1 Forward Search . . . . . . . . . . . . . . 14 X 4.2 Exact Searches . . . . . . . . . . . . . . 15 X 4.3 Backward Search . . . . . . . . . . . . . . 15 X 4.4 Searching and Replacing . . . . . . . . . . 15 X 4.5 Query-Replace . . . . . . . . . . . . . . . 16 X X Chapter 5 Windows 18 X 5.1 Creating Windows . . . . . . . . . . . . . 18 X 5.2 Deleting Windows . . . . . . . . . . . . . 19 X 5.3 Resizing Windows . . . . . . . . . . . . . 20 X 5.4 Repositioning within a Window . . . . . . . 20 X X Chapter 6 Buffers 24 X X Chapter 7 Modes 27 X 7.1 ASAVE mode . . . . . . . . . . . . . . . . 27 X 7.2 CMODE mode . . . . . . . . . . . . . . . . 28 X 7.3 CRYPT mode . . . . . . . . . . . . . . . . 28 X 7.4 EXACT mode . . . . . . . . . . . . . . . . 29 X 7.5 MAGIC mode . . . . . . . . . . . . . . . . 29 X 7.6 OVER mode . . . . . . . . . . . . . . . . . 30 X 7.7 WRAP mode . . . . . . . . . . . . . . . . . 31 X 7.8 VIEW mode . . . . . . . . . . . . . . . . . 31 X X X X X i X X X X X X X X X X Chapter 8 Files 33 X X Chapter 9 Screen Formatting 36 X 9.1 Wrapping Text . . . . . . . . . . . . . . . 36 X 9.2 Reformatting Paragraphs . . . . . . . . . . 36 X 9.3 Changing Case . . . . . . . . . . . . . . . 37 X 9.4 Tabs . . . . . . . . . . . . . . . . . . . 37 X X Chapter 10 Access to the Outside World 40 X X Chapter 11 Keyboard Macros 43 X X Chapter 12 MicroEMACS Macros 45 X 12.1 Constants . . . . . . . . . . . . . . . . 45 X 12.2 Variables . . . . . . . . . . . . . . . . 46 X 12.2.1 Environmental Variables . . . . . . . 47 X 12.2.2 User variables . . . . . . . . . . . 49 X 12.2.3 Buffer Variables . . . . . . . . . . 49 X 12.2.4 Interactive variables . . . . . . . . 50 X 12.3 Functions . . . . . . . . . . . . . . . . 50 X 12.4 Directives . . . . . . . . . . . . . . . . 53 X 12.4.1 !ENDM Directive . . . . . . . . . . . 53 X 12.4.2 !FORCE Directive . . . . . . . . . . 53 X 12.4.3 !IF, !ELSE, and !ENDIF Directives . . 54 X 12.4.4 !GOTO Directive . . . . . . . . . . . 54 X 12.4.5 !WHILE and !ENDWHILE Directives . . . 55 X 12.4.6 !BREAK Directive . . . . . . . . . . 55 X 12.4.7 !RETURN Directive . . . . . . . . . . 56 X X Appendix A MicroEMACS Command Line Switches and X Startup Files 57 X X Appendix B MicroEMACS commands 59 X X Appendix C MicroEMACS Bindings 65 X X Appendix D Supported machines 67 X X Appendix E Machine Dependent Notes 69 X E.1 IBM-PC/XT/AT and its clones . . . . . . . . 69 X E.2 HP 150 . . . . . . . . . . . . . . . . . . 71 X E.3 Atari 520/1040ST . . . . . . . . . . . . . 72 X E.4 Amiga 1000 . . . . . . . . . . . . . . . . 74 X E.5 UNIX V5, V7, and BSD4.[23] . . . . . . . . 75 X X Appendix F Mode Flags 76 X X X X X X X X X X X ii X X X FRIDAY_NIGHT