Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!uwvax!rutgers!ames!necntc!ncoast!allbery From: nwd@j.cc.purdue.edu (Daniel Lawrence) Newsgroups: comp.sources.misc Subject: MicroEmacs 3.9 Manual (4 of 6) Message-ID: <5817@ncoast.UUCP> Date: Wed, 25-Nov-87 23:16:09 EST Article-I.D.: ncoast.5817 Posted: Wed Nov 25 23:16:09 1987 Date-Received: Mon, 30-Nov-87 01:00:58 EST Sender: allbery@ncoast.UUCP Lines: 1398 Approved: allbery@ncoast.UUCP X-Archive: comp.sources.misc/8711/15 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- 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- 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 [] :" 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 key to start the X search. If you simply press the command line responds with X "". 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 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 (). 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 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 . The command X line now shows: X X "search [and]:" X X Press 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 []:" X X where the square brackets enclose the default string. X Type the word electronic and hit . The command line X responds: X X "with []" X X type desktop. 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- M-^L where 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 , 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 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", 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 . 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