home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8707 / 1 next >
Encoding:
Internet Message Format  |  1990-07-13  |  57.3 KB

  1. From: paul@cgh.UUCP (Paul Homchick)
  2. Newsgroups: comp.sources.misc
  3. Subject: MicroEMACS 3.8i Documentation (Scribe format) 1 of 2
  4. Message-ID: <2761@ncoast.UUCP>
  5. Date: 3 Jul 87 00:07:35 GMT
  6. Sender: allbery@ncoast.UUCP
  7. Lines: 1313
  8. Approved: allbery@ncoast.UUCP
  9. X-Archive: comp.sources.misc/8707/1
  10.  
  11. MicroEmacs 3.8i Documentation in MicroSCRIBE format.
  12.               +++ Part One of Two +++
  13. (Differs from the original uEmacs distribution by fixing some spelling
  14.  errors and formattating problems)
  15. -----snip-----snip-----snip-----snip-----snip-----snip-----snip-----snip-----
  16. @style(indent 8 chars, linewidth 72 chars, spacing 1 lines)
  17. @pagefooting()
  18.  
  19.         @b(MicroEMACS)
  20.  
  21.         Full Screen Text Editor
  22.         Reference Manual (preliminary draft)
  23.  
  24.         Version 3.8i
  25.         April 27, 1987
  26.  
  27.         (C)opyright 1987 by Daniel M. Lawrence
  28.         Reference Manual (C)opyright 1987
  29.             by Brian Straight and Daniel M. Lawrence
  30.         All Rights Reserved
  31.  
  32.         @i(MicroEMACS 3.8i can be copied and distributed freely
  33.         for any non-commercial purposes. MicroEMACS 3.8i can
  34.         only be incorporated into commercial software with
  35.         the permission of the current author.)
  36. @newpage
  37. @flushleft(@b[Introduction])
  38.  
  39.     MicroEMACS is a tool for creating and changing documents,
  40. programs, and other text files.  It is both relatively easy for the
  41. novice to use, but also very powerful in the hands of an expert.
  42. MicroEMACS can be extensively customized for the needs of the
  43. individual user.
  44.  
  45.     MicroEMACS allows several files to be edited at the same time.
  46. The screen can be split into different windows, and text may be moved
  47. freely from one window to the next.  Depending on the type of file being
  48. edited, MicroEMACS can change how it behaves to make editing simple. 
  49. Editing standard text files, program files and word processing documents
  50. are all possible at the same time.
  51.  
  52.     There are extensive capabilities to make word processing and
  53. editing easier.  These include commands for string searching and
  54. replacing, paragraph reformatting and deleting, automatic word wrapping,
  55. word move and deletes, easy case controlling, and automatic word counts.
  56.  
  57.     For complex and repetitive editing tasks editing macros can be
  58. written.  These macros allow the user a great degree of flexibility in
  59. determining how MicroEMACS behaves.  Also any and all the commands can
  60. be used by any keystroke by changing, or rebinding, what commands
  61. various keys are connected, or bound, to. 
  62.  
  63.     Special features are also available to perform a diverse set of
  64. operations such as file encryption, automatic backup file generation,
  65. entabbing and detabbing lines, executing of DOS commands and filtering
  66. of text through other programs (like SORT to allow sorting text).
  67.  
  68. @flushleft(@b[History])
  69.  
  70.     EMACS was originally a text editor written by Richard Stahlman
  71. at MIT in the early 1970s for Digital Equipment computers. Various
  72. versions, rewrites and clones have made an appearance since.
  73.  
  74.     This version of MicroEMACS is derived from code written by Dave
  75. G.  Conroy in 1985.  Later modifications were performed by Steve Wilhite
  76. and George Jones.  In December of 1985 Daniel Lawrence picked up the
  77. then current source (version 2.0) and has made extensive modifications
  78. and additions to it over the course of the next two years.  Updates and
  79. support for the current version is still in progress.  The current
  80. program author can be contacted by writing to:
  81.  
  82. @begin(verbatim)
  83.     USMAIL:    Daniel Lawrence
  84.         617 New York St
  85.         Lafayette, IN 47901
  86.  
  87.     UUCP:    ihnp4!pur-ee!pur-phy!duncan!lawrence
  88.     ARPA:    nwd@@j.cc.purdue.edu
  89.     FIDO:    Fido 201/2 The Programmer's Room (317) 742-5533
  90. @end(verbatim)
  91. @string(ChapterTitle="")
  92. @set(page = 0)
  93. @pageheading(even, left "@title[Chapter]", right "MicroEMACS Reference Manual")
  94. @pageheading(odd, left "MicroEMACS Reference Manual", right "@title[Chapter]")
  95. @pagefooting(even, left="@value(page)")
  96. @pagefooting(odd, right="@value(page)")
  97. @chapter(Basic Concepts)
  98.  
  99.     The current version of MicroEMACS is 3.8i (Third major re-write,
  100. eighth public release, Ith (or ninth) minor release), and for the rest of
  101. this document, we shall simply refer to this version as "EMACS".  Any
  102. modifications for later versions will be listed in the appendixes at the
  103. end of this manual. 
  104.  
  105. @section(Keys and the Keyboard)
  106.  
  107.     Many times throughout this manual we will be talking about
  108. @index(special keys) commands and the keys on the keyboard needed use
  109. them.  There are a number of "special" keys which can be used and are
  110. listed here:
  111.  
  112. @begin(description)
  113. <NL>@\NewLine which is also called RETURN or ENTER, this key is used to
  114. @index(newline) end different commands. 
  115.  
  116. ^@\The control key can be used before any alphabetic character and some
  117. symbols.  For example, ^C means to hold down the <CONTROL> key and type
  118. @index(control key) the C key at the same time. 
  119.  
  120. ^X@\The CONTROL-X key is used at the beginning of many different
  121. @index(control-x) commands. 
  122.  
  123. META or M-@\This is a special EMACS key used to begin many commands as
  124. @index(meta key) well.  This key is pressed, and then released before
  125. typing the next character.  On most systems, this is the <ESC> key, but
  126. it can be changed.  (consult appendix D to learn what key is used for
  127. META on your computer).
  128. @end(description)
  129.  
  130. Whenever a command is described, the manual will list the actual
  131. keystrokes needed to execute it in @b(boldface) using the above
  132. conventions, and also the name of the command in @i(italics).
  133. @section(Getting Started)
  134.  
  135.     In order to use EMACS, you must call it up from your system's or
  136. computer's command prompt.  On UNIX and MSDOS machines, just type
  137. "emacs" from the main command prompt and follow it with the <RETURN> or
  138. <ENTER> key (we will refer to this key as <NL> for "new-line" for the
  139. remainder of this manual).  On the Macintosh, the Amiga, the ATARI ST
  140. and other icon based operating systems, double click on the uEMACS icon.
  141. Shortly after this, a screen similar to the one below should appear.
  142.  
  143. @section(Parts and Pieces)
  144.  
  145.     The screen is divided into a number of areas or @b<windows>.  On
  146. some systems the top window contains a function list of unshifted and
  147. @index(windows) shifted function keys.  We will discuss these keys later. 
  148. @index(mode line) Below them is an EMACS @b<mode line> which, as we will
  149. see, informs you of the present mode of operation of the editor--for
  150. example "(WRAP)" if you set EMACS to wrap at the end of each line. 
  151. @index(text window) Under the mode line is the @b<text window> where text
  152. appears and is manipulated.  Since each window has its own mode line,
  153. below the text window is it's mode line.  The last line of the screen is
  154. the @b(command line) where EMACS takes commands and reports on what it
  155. is doing. 
  156.  
  157. @begin(verbatim)
  158. ===============================================================================
  159. f1 search      f2 search back : F1 toggle function list F2 toggle help file
  160. f3 hunt        f4 hunt back   : F3 find command/apropos F4 describe key
  161. f5 next window f6 exec macro  : F5 reformat paragraph    F6 ref undented region 
  162. f7 find file   f8 exec file   : F7 indent region    F8 undent region
  163. f9 save file  f10 exit emacs  : F9 execute DOS command F10 shell up
  164. ===============================================================================
  165. -- MicroEMACS 3.8i () -- Function Keys ---------------------------------------
  166. ===============================================================================
  167.  
  168. ===============================================================================
  169. -- MicroEMACS 3.8i () -- Main ------------------------------------------------
  170. ===============================================================================
  171.         Fig 1:    EMACS screen on an IBM-PC
  172. @end(verbatim)
  173.  
  174. @section(Entering Text)
  175.  
  176. Entering text in EMACS is simple.  Type the following sentence fragment:
  177.  
  178. @quotation<Fang Rock lighthouse, center of a series of mysterious and>
  179.  
  180. @flushleft(The text is displayed at the top of the text window.  Now type:)
  181.  
  182. @quotation<terrifying events at the turn of the century>
  183.  
  184. Notice the text to the left of the cursor disappears and a '$' sign
  185. appears.  Don't panic--your text is safe!!! You've just discovered that
  186. EMACS doesn't "wrap" text to the next line like most word processors
  187. unless you hit <NL>.  But since EMACS is used for both word processing,
  188. and text editing, it has a bit of a dual personality.  You can change
  189. @index(modes) the way it works by setting various @b(modes).  In this
  190. case, you need to set @b(WRAP) mode, using the @i(add-mode)
  191. @index(add-mode) command, by typing @b(^X-M).  The command line at the
  192. base of the screen will prompt you for the mode you wish to add.  Type
  193. @b<wrap> followed by the <NL> key and any text you now enter will be
  194. wrapped.  However, the command doesn't wrap text already entered.  To
  195. get rid of the truncated line, delete characters with the <BACKSPACE>
  196. key until the '$' goes away.  Now type in the words you deleted, watch
  197. how EMACS goes down to the next line at the right time.  @i{(In some
  198. versions of EMACS, @b<WRAP> is a default mode in which case you don't
  199. have to worry about the instructions relating to adding this mode.)}
  200.  
  201. Now let's type a longer insert.  Hit <NL> a couple of times to tab
  202. down from the text you just entered.  Now type the following paragraphs. 
  203. Press <NL> twice to indicate a paragraph break. 
  204.  
  205. @quotation<Fang Rock lighthouse, center of a series of mysterious and
  206. terrifying events at the turn of the century, is built on a rocky island
  207. a few miles of the Channel coast.  So small is the island that wherever
  208. you stand its rocks are wet with sea spray. 
  209.  
  210. The lighthouse tower is in the center of the island.  A steep flight of
  211. steps leads to the heavy door in its base.  Winding stairs lead up to
  212. the crew room.>
  213.  
  214. @section<Basic cursor movement>
  215.  
  216. Now let's practice moving around in this text.  To move the cursor back
  217. to the word "Winding," enter @b<M-B> @i(previous-word)
  218. @index(previous-word).  This command moves the cursor backwards by one
  219. word at a time.  Note you have to press the key combination every time
  220. the cursor steps back by one word.  Continuously pressing META and
  221. toggling B produces an error message.  To move forward to the word
  222. "stairs" enter @b<M-F>, which moves the cursor forward by one word at a
  223. time. 
  224.  
  225. Notice that EMACS commands are usually mnemonic--F for forward, B for
  226. backward, for example.
  227.  
  228. To move the cursor up one line, enter @b<^P> @i(previous-line)
  229. @index(previous-line), down one line @b<^N> @i(next-line)
  230. @index(next-line).  Practice this movement by moving the cursor to the
  231. word "terrifying" in the second line. 
  232.  
  233. The cursor may also be moved forward or backward in smaller increments. 
  234. To move forward by one character, enter @b<^F> @i(forward-character)
  235. @index(forward-character), to move backward, @b<^B>
  236. @i(backward-character) @index(backward-character).  EMACS also allows
  237. you to specify a number which is normally used to tell a command to
  238. execute many times.  To repeat most commands, press META and then the
  239. number before you enter the command.  Thus, the command META 5 ^F
  240. (@b<M-5^F>) will move the cursor forward by five characters.  Try moving
  241. around in the text by using these commands.  For extra practice, see how
  242. close you can come to the word "small" in the first paragraph by giving
  243. an argument to the commands listed here. 
  244.  
  245. Two other simple cursor commands that are useful to help us move around
  246. in the text are @b<M-N> @i(next-paragraph) @index(next-paragraph) which
  247. moves the cursor to the second paragraph, and @b<M-P>
  248. @i(previous-paragraph) @index(previous-paragraph) which moves it back to
  249. the previous paragraph.  The cursor may also be moved rapidly from one
  250. end of the line to the other.  Move the cursor to the word "few" in the
  251. second line.  Press @b<^A> @i(beginning-of-line)
  252. @index(beginning-of-line).  Notice the cursor moves to the word "events"
  253. at the beginning of the line.  Pressing @b<^E> @i(end-of-line)
  254. @index(end-of-line) moves the cursor to the end of the line. 
  255.  
  256. Finally, the cursor may be moved from any point in the file to the end
  257. or beginning of the file.  Entering @b{M->} @i(end-of-file)
  258. @index(end-of-file) moves the cursor to the end of the buffer, @b{M-<}
  259. @i(beginning-of-file) @index(beginning-of-file) to the first character
  260. of the file. 
  261.  
  262. @i(On the IBM-PC, the ATARI ST and many other machines, the cursor keys
  263. @index(cursor keys) can also be used to move the cursor about.  Also, if
  264. there is one available, moving the mouse will move the cursor.)
  265.  
  266. Practice moving the cursor in the text until you are comfortable with
  267. the commands we've explored in this chapter.
  268.  
  269. @section(Saving your text)
  270.  
  271. When you've finished practicing cursor movement, save your file.  Your
  272. @index(buffer) file currently resides in a @b<BUFFER>.  The buffer is a
  273. temporary storage area for your text, and is lost when the computer is
  274. turned off.  You can save the buffer to a file by entering @b<^X-^S>
  275. @i(save-file) @index(save-file).  Notice that EMACS informs you that
  276. your file has no name and will not let you save it. 
  277.  
  278. To save your buffer to a file with a different name than it's current
  279. one (which is empty), press @b<^X^W> @i(write-file) @index(write-file). 
  280. EMACS will prompt you for the filename you wish to write.  Enter the
  281. name @b<fang.txt> and press return.  On a micro, the drive light will
  282. come on, and EMACS will inform you it is writing the file.  When it
  283. finishes, it will inform you of the number of lines it has written to
  284. the disk. 
  285.  
  286. Congratulations!! You've just saved your first EMACS file!
  287. @newpage
  288. @heading(Chapter @value(chapter) Summary)
  289.  
  290.     In chapter @value(chapter), you learned how to enter text, how
  291. to use wrap mode, how to move the cursor, and to save a buffer.  The
  292. following is a table of the commands covered in this chapter and their
  293. corresponding key bindings:
  294.  
  295. @begin{verbatim}
  296. @u(Key Binding        Keystroke    Effect)
  297.  
  298. abort-command        @b<^G>        aborts current command
  299.  
  300. add-mode        @b<^XM>        allows addition of EMACS
  301.                     mode such as @b(WRAP)
  302.  
  303. backward-character    @b<^B>        moves cursor left one character
  304.  
  305. beginning-of-file    @b{M-<}        moves cursor to beginning of file
  306.  
  307. beginning-of-line    @b<^A>        moves cursor to beginning of line
  308.  
  309. end-of-file        @b{M->}        moves cursor to end of file
  310.  
  311. end-of-line        @b<^E>        moves cursor to end of line
  312.  
  313. forward-character    @b<^F>        moves cursor right one character
  314.  
  315. next-line        @b<^N>        moves cursor to next line
  316.  
  317. next-paragraph        @b<M-N>        moves cursor to next paragraph
  318.  
  319. next-word        @b<M-F>        moves cursor forward one word
  320.  
  321. previous-line        @b<^P>        moves cursor backward by one line
  322.  
  323. previous-paragraph    @b<M-P>        moves cursor to previous paragraph
  324.  
  325. previous-word        @b<M-B>        moves cursor backward by one word
  326.  
  327. save-file        @b<^X-^S>    saves current buffer to a file
  328.  
  329. write-file        @b<^X-^W>    save current buffer under a new name
  330. @end(verbatim)
  331. @newpage
  332. @chapter(Basic Editing--Simple Insertions and Deletions)
  333.  
  334. @section<A Word About Windows, Buffers, Screens, and Modes>
  335.  
  336. In the first chapter, you learned how to create and save a file in
  337. EMACS.    Let's do some more editing on this file.  Call up emacs by
  338. typing in the following command.
  339.  
  340. @b<emacs fang.txt>
  341.  
  342. @i(On icon oriented systems, double click on the uEMACS icon, usually a
  343. file dialog box of some sort will appear.  Choose @b(FANG.TXT) from the
  344. appropriate folder.)
  345.  
  346. Shortly after you invoke EMACS, the text should appear on the screen
  347. ready for you to edit.  The text you are looking at currently resides in
  348. a @b<buffer>.  A buffer is a temporary area of computer memory which is
  349. @index(buffer) the primary unit internal to EMACS -- this is the place
  350. where EMACS goes to work.  The mode line at the bottom of the screen
  351. lists the buffer name, @b<FANG.TXT> and the name of the file with which
  352. this buffer is associated, @b<FANG.TXT>
  353.  
  354. The computer talks to you through the use of its @b(screen).  This
  355. @index(screen) screen usually has an area of 24 lines each of 80
  356. characters across.  You can use EMACS to subdivide the screen into
  357. several separate work areas, or @b(windows), each of which can be
  358. @index(window) 'looking into' different files or sections of text.  Using
  359. windows, you can work on several related texts at one time, copying and
  360. moving blocks of text between windows with ease.  To keep track of what
  361. you are editing, each window is identified by a @b(mode line) on the
  362. @index(mode line) @index(buffer) last line of the window which lists the
  363. name of the @b(buffer) which it is looking into, the file from which the
  364. text was read, and how the text is being edited. 
  365.  
  366. An EMACS @b<mode> tells EMACS how to deal with user input.  As we have
  367. already seen, the mode 'WRAP' controls how EMACS deals with long lines
  368. (lines with over 79 characters) while the user is typing them in.  The
  369. 'VIEW' mode, allows you to read a file without modifying it.  Modes are
  370. associated with buffers and not with files; hence, a mode needs to be
  371. explicitly set or removed every time you edit a file.  A new file read
  372. into a buffer with a previously specified mode will be edited under this
  373. mode.  If you use specific modes frequently, EMACS allows you to set
  374. the modes which are used by all new buffers, called @b<global> modes. 
  375.  
  376. @section<Insertions>
  377.  
  378. Your previously-saved text should look like this:
  379.  
  380. @quotation<Fang Rock lighthouse, center of a series of mysterious and
  381. terrifying events at the turn of the century, is built on a rocky island
  382. a few miles of the Channel coast.  So small is the island that wherever
  383. you stand its rocks are wet with sea spray. 
  384.  
  385. The lighthouse tower is in the center of the island.  A steep flight of
  386. steps leads to the heavy door in its base.  Winding stairs lead up to
  387. the crew room.>
  388.  
  389. Let's assume you want to add a sentence in the second paragraph after
  390. the word "base."  Move the cursor until it is on the "W" of "Winding".
  391. Now type the following:
  392.  
  393. @quotation<This gives entry to the lower floor where the big steam
  394. generator throbs steadily away, providing power for the electric
  395. lantern.>
  396.  
  397. If the line fails to wrap and you end up with a '$' sign in the right
  398. margin, just enter @b{M-Q} @i(fill-paragraph) @index(fill-paragraph) to
  399. reformat the paragraph.  This new command attempts to fill out a
  400. paragraph.  Long lines are divided up, and words are shuffled around to
  401. make the paragraph look nicer. 
  402.  
  403. Notice that all visible EMACS characters are self-inserting -- all you
  404. had to do was type the characters to insert and the existing text made
  405. space for it.  With a few exceptions discussed later, all non-printing
  406. characters (such as control or escape sequences) are commands.  To
  407. insert spaces, simply use the space bar.  Now move to the first line of
  408. the file and type @b{^O} @i(open-line) @index(open-line) (Oh, not zero). 
  409. You've just learned how to insert a blank line in your text. 
  410.  
  411. @section<Deletions>
  412.  
  413. EMACS offers a number of deletion options.  For example, move the cursor
  414. until it's under the period at the end of the insertion you just did. 
  415. Press the backspace key.  Notice the "n" on "lantern" disappeared.  The
  416. backspace implemented on EMACS is called a @b<destructive> backspace--it
  417. removes text immediately before the current cursor position from the
  418. buffer.  Now type @b<^H> @i(delete-previous-character)
  419. @index(delete-previous-character).  Notice that the cursor moves back
  420. and obliterates the "r"--either command will backspace the cursor. 
  421.  
  422. Type in the two letters you erased to restore your text and move the
  423. cursor to the beginning of the buffer @b{M->} @i(beginning-of-file)
  424. @index(beginning-of-file).  Move the cursor down one line to the
  425. beginning of the first paragraph. 
  426.  
  427. To delete the forward character, type @b{^D} @i(delete-next-character)
  428. @index(delete-next-character).  The "F" of "Fang" disappears.  Continue
  429. to type @b{^D} until the whole word is erased EMACS also permits the
  430. deletion of larger elements of text.  Move the cursor to the word
  431. "center" in the first line of text.  Pressing @b{M-<backspace>}
  432. @i(delete-previous-word) @index(delete-previous-word) kills the word
  433. immediately before the cursor.  @b{M-^H} has the same effect. 
  434.  
  435. Notice that the commands are very similar to the control commands you
  436. used to delete individual letters.  As a general rule in EMACS, control
  437. sequences affect small areas of text, META sequences larger areas.  The
  438. word forward of the cursor position can therefore be deleted by typing
  439. @b{M-D} @i(delete-next-word) @index(delete-next-word).  Now let's take
  440. out the remainder of the first line by typing @b{^K}
  441. @i(kill-to-end-of-line) @index(kill-to-end-of-line).  You now have a
  442. blank line at the top of your screen.  Typing @b{^K} again or @b{^X-^O}
  443. @i(delete-blank-lines) @index(delete-blank-lines) deletes the blank line
  444. and flushes the second line to the top of the text.  Now exit EMACS by
  445. typing @b{^X-^C} @i(exit-emacs) @index(exit-emacs).  Notice EMACS
  446. reminds you that you have not saved your buffer.  Ignore the warning and
  447. exit.  This way you can exit EMACS without saving any of the changes you
  448. just made. 
  449.  
  450. @heading(Chapter @value(chapter) Summary)
  451.  
  452. In Chapter @value(chapter), you learned about the basic 'building
  453. blocks' of an EMACS text file--buffers, windows, and files. 
  454.  
  455. @begin{verbatim}
  456. @u(Key binding        Keystroke    Effect)
  457. delete-previous-character
  458.             @b{^H}        deletes character immediately before
  459.                     the current cursor position
  460.  
  461. delete-next-character    @b{^D}        deletes character immediately after     
  462.                     current cursor position
  463.  
  464. delete-previous-word    @b{M-^H}    deletes word immediately before
  465.                     current cursor position
  466.  
  467. delete-next-word    @b{M-D}        deletes word immediately after
  468.                     current cursor position
  469.  
  470. kill-to-end-of-line    @b<^K>        deletes from current cursor
  471.                     position to end of line
  472.  
  473. insert-space        @b<^C>        inserts a space to right of cursor
  474.  
  475. open-line        @b{^O}        inserts blank line
  476.  
  477. delete-blank-lines    @b{^X-^O}    removes blank line
  478.  
  479. exit-emacs        @b{^X-^C}    exits emacs
  480. @end(verbatim)
  481. @chapter(Using Regions)
  482.  
  483. @section(Defining and Deleting a Region)
  484.  
  485. At this point its time to familiarize ourselves with two more EMACS
  486. terms--the @b<point> and the @b<mark>.  The point is located directly
  487. @index(point) @index(mark) behind the current cursor position.  The mark
  488. (as we shall see shortly) is user defined.  These two elements together
  489. are called the current @b(region) and limit the @b<region> of text on
  490. which EMACS performs many of its editing functions. 
  491.  
  492. Let's begin by entering some new text.  Don't forget to add @b(wrap)
  493. mode if its not set on this buffer.  Start EMACS and open a file called
  494. @b{PUBLISH.TXT}.  Type in the following text:
  495.  
  496. @quotation{One of the largest growth areas in personal computing is
  497. electronic publishing.  There are packages available for practically
  498. every machine from elegantly simple programs for the humble Commodore 64
  499. to sophisticated professional packages for PC and Macintosh computers. 
  500.  
  501. Electronic publishing is as revolutionary in its way as the Gutenburg
  502. press.  Whereas the printing press allowed the mass production and
  503. distribution of the written word, electronic publishing puts the means
  504. of production in the hands of nearly every individual.  From the class
  505. magazine to the corporate report, electronic publishing is changing the
  506. way we produce and disseminate information. 
  507.  
  508. Personal publishing greatly increases the utility of practically every
  509. computer.  Thousands of people who joined the computer revolution of
  510. this decade only to hide their machines unused in closets have
  511. discovered a new use for them as dedicated publishing workstations.}
  512.  
  513. Now let's do some editing.  The last paragraph seems a little out of
  514. place.  To see what the document looks like without it we can cut it
  515. from the text by moving the cursor to the beginning of the paragraph. 
  516. Enter @b(M-<space>) @i(set-mark) @index(set-mark).  EMACS will respond
  517. with "[Mark set]".  Now move the cursor to the end of the paragraph. 
  518. You have just defined a region of text.  To remove this text from the
  519. screen, type @b<^W> @i(kill-region) @index(kill-region).  The paragraph
  520. disappears from the screen. 
  521.  
  522. On further consideration, however, perhaps the paragraph we cut wasn't
  523. so bad after all.  The problem may have been one of placement.  If we
  524. could tack it on to the end of the first paragraph it might work quite
  525. well to support and strengthen the argument.  Move the cursor to the end
  526. of the first paragraph and enter @b<^Y> @i(yank) @index(yank).  Your
  527. text should now look like this:
  528.  
  529. @quotation{One of the largest growth areas in personal computing is
  530. electronic publishing.  There are packages available for practically
  531. every machine from elegantly simple programs for the humble Commodore 64
  532. to sophisticated professional packages for PC and Macintosh computers. 
  533. Personal publishing greatly increases the utility of practically every
  534. computer.  Thousands of people who joined the computer revolution of
  535. this decade only to hide their machines unused in closets have
  536. discovered a new use for them as dedicated publishing workstations. 
  537.  
  538. Electronic publishing is as revolutionary in its way as the Gutenburg
  539. press.  Whereas the printing press allowed the mass production and
  540. distribution of the written word, electronic publishing puts the means
  541. of production in the hands of nearly every individual.    From the class
  542. magazine to the corporate report, electronic publishing is changing the
  543. way we produce and disseminate information.}
  544.  
  545. @section(Yanking a Region)
  546.  
  547. The text you cut initially didn't simply just disappear, it was cut into
  548. a buffer that retains the 'killed' text appropriately called the @b<kill
  549. buffer>.  @b<^Y> "yanks" the text back from this buffer into the current
  550. buffer. If you have a long line (indicated, remember, by the "$"
  551. sign), simply hit @b{M-Q} to reformat the paragraph. 
  552.  
  553. There are other uses to which the kill buffer can be put.  Using the
  554. @index(kill buffer) method we've already learned, define the last
  555. paragraph as a region.  Now type @b<M-W> @i(copy-region)
  556. @index(copy-region).  Nothing seems to have happened; the cursor stays
  557. blinking at the point.  But things have changed, even though you may not
  558. be able to see any alteration. 
  559.  
  560. To see what has happened to the contents of the kill buffer, move the
  561. cursor down a couple of lines and "yank" the contents of the kill buffer
  562. back with @b<^Y>.  Notice the last paragraph is now repeated.  The
  563. region you defined is "tacked on" to the end of your file because
  564. @b<M-W> @b<copies> a region to the kill buffer while leaving the
  565. original text in your working buffer.  Some caution is needed however,
  566. because the contents of the kill buffer are updated when you delete any
  567. regions, lines or words.  If you are moving large quantities of text,
  568. complete the operation before you do any more deletions or you could
  569. find that the text you want to move has been replaced by the most recent
  570. deletion.  Remember--a buffer is a temporary area of computer memory
  571. that is lost when the machine is powered down or switched off.  In order
  572. to make your changes permanent, they must be saved to a file before you
  573. leave EMACS.  Let's delete the section of text we just added and save
  574. the file to disk. 
  575.  
  576. @heading(Chapter @value(chapter) Summary)
  577.  
  578. In Chapter @value(chapter), you learned how to achieve longer insertions
  579. and deletions.  The EMACS terms @b<point> and @b<mark> were introduced
  580. and you learned how to manipulate text with the kill buffer. 
  581.  
  582. @begin{verbatim}
  583. @begin(group)
  584. @u(Key Binding    Keystroke    Effect)
  585.  
  586. Delete-Region    @b{^W}        Deletes region between point and mark and
  587.                 places it in KILL buffer
  588.  
  589. Copy-Region    @b{M-W}        Copies text between point and mark into
  590.                 KILL buffer
  591.  
  592. Yank-Text    @b{^Y}        Inserts a copy of the KILL buffer into
  593.                 current buffer at point
  594. @end(group)
  595. @end(verbatim)
  596. @chapter(Search and Replace)
  597.  
  598. @section<Forward Search>
  599.  
  600. Load EMACS and bring in the file you just saved.  Your file should look
  601. like the one below.
  602.  
  603. @quotation{One of the largest growth areas in personal computing is
  604. electronic publishing.  There are packages available for practically every
  605. machine from elegantly simple programs for the humble Commodore 64 to
  606. sophisticated professional packages for PC and Macintosh computers. 
  607. Personal publishing greatly increases the utility of practically every
  608. computer.  Thousands of people who joined the computer revolution of
  609. this decade only to hide their machines unused in closets have
  610. discovered a new use for them as dedicated publishing workstations. 
  611.  
  612. Electronic publishing is as revolutionary in its way as the Gutenburg
  613. press.  Whereas the printing press allowed the mass production and
  614. distribution of the written word, electronic publishing puts the means
  615. of production in the hands of nearly every individual.    From the class
  616. magazine to the corporate report, electronic publishing is changing the
  617. way we produce and disseminate information.}
  618.  
  619. Let's use EMACS to search for the word "revolutionary" in the second
  620. paragraph.  Because EMACS searches from the current cursor position
  621. toward the end of buffers, and we intend to search forward, move the
  622. cursor to the beginning of the text.  Enter @b<^S> @i(search-forward)
  623. @index(search-forward).  Note that the command line now reads
  624.  
  625. "Search [] <META>:" 
  626.  
  627. EMACS is prompting you to enter the @b<search string> -- the text you
  628. want to find.  Enter the word @b<revolutionary> and hit the @b<META>
  629. key.  The cursor moves to the end of the word "revolutionary."
  630.  
  631. Notice that you must enter the <META> key to start the search.  If you
  632. @index(<NL>) simply press <NL> the command line responds with "<NL>". 
  633. Although this may seem infuriating to users who are used to pressing the
  634. return key to execute any command, EMACS' use of <META> to begin
  635. searches allows it to pinpoint text with great accuracy.  After every
  636. line wrap or carriage return, EMACS 'sees' a new line character (<NL>). 
  637. If you need to search for a word at the end of a line, you can specify
  638. this word uniquely in EMACS. 
  639.  
  640. In our sample text for example, the word "and" occurs a number of times,
  641. but only once at the end of a line.  To search for this particular
  642. occurrence of the word, move the cursor to the beginning of the buffer
  643. and type @b(^S).  Notice that EMACS stores the last specified
  644. @index(default string) search string as the @b<default> string.  If you
  645. press @b{<META>} now, EMACS will search for the default string, in this
  646. case, "revolutionary."
  647.  
  648. To change this string so we can search for our specified "and" simply
  649. enter the word @b{and} followed by @b{<NL>}.  The command
  650. line now shows:
  651.  
  652. "search [and<NL>]<META>:"
  653.  
  654. Press @b{<META>} and the cursor moves to "and" at the end of the second
  655. last line.
  656.  
  657. @section<Exact Searches>
  658.  
  659. If the mode EXACT is active in the current buffer, EMACS searches on a case
  660. sensitive basis.  Thus, for example you could search for @b{Publishing}
  661. as distinct from @b{publishing}. 
  662.  
  663. @section<Backward Search>
  664.  
  665. Backward searching is very similar to forward searching except that it
  666. is implemented in the reverse direction.  To implement a reverse search,
  667. type @b{^R} @i(search-reverse) @index(search-reverse).  Because EMACS
  668. makes no distinction between forward and backward stored search strings,
  669. the last search item you entered appears as the default string.  Try
  670. searching back for any word that lies between the cursor and the
  671. beginning of the buffer.  Notice that when the item is found, the point
  672. moves to the beginning of the found string (i.e., the cursor appears
  673. under the first letter of the search item). 
  674.  
  675. Practice searching for other words in your text.
  676.  
  677. @section<Searching and Replacing>
  678.  
  679. Searching and replacing is a powerful and quick way of making changes to
  680. your text.  Our sample text is about electronic publishing, but the
  681. correct term is 'desktop' publishing.  To make the necessary changes we
  682. need to replace all occurrences of the word "electronic" with "desktop."
  683. First, move the cursor to the top of the current buffer with the @b(M-<)
  684. command.  Then type @b[M-R] @i(replace-string) @index(replace-string). 
  685. The command line responds:
  686.  
  687. "Replace []<META>:"
  688.  
  689. where the square brackets enclose the default string.  Type the word
  690. @b<electronic> and hit @b{<META>}.  The command line responds:
  691.  
  692. "with []<META>"
  693.  
  694. type @b{desktop<META>}.  EMACS replaces all instances of the original
  695. word with your revision.  Of course, you will have to capitalize the
  696. first letter of "desktop" where it occurs at the beginning of a
  697. sentence.
  698.  
  699. You have just completed an @b<unconditional replace>.  In this
  700. operation, EMACS replaces every instance of the found string with the
  701. replacement string. 
  702.      
  703. @section<Query-Replace>
  704.  
  705. You may also replace text on a case by case basis.  The @b{M-^R}
  706. @i(query-replace-string) @index(query-replace-string) command causes
  707. EMACS to pause at each instance of the found string. 
  708.  
  709. For example, assume we want to replace some instances of the word
  710. "desktop" with the word "personal." Go back to the beginning of the
  711. current buffer and enter the @b(M-^R) @i(query-replace)
  712. @index(query-replace) command.  The procedure is very similar to that
  713. which you followed in the unconditional search/replace option.  When the
  714. search begins however, you will notice that EMACS pauses at each
  715. instance of "publishing" and asks whether you wish to replace it with
  716. the replacement string.  You have a number of options available for
  717. response:
  718.  
  719. @begin(verbatim)
  720. @u(    Response    Effect)
  721.     Y(es)    Make the current replacement and skip to the next
  722.         occurrence of the search string
  723.  
  724.     N(o)    Do not make this replacement but continue
  725.  
  726.     !    Do the rest of the replacements with no more queries
  727.  
  728.     U(ndo)    Undo just the last replacement and query for it
  729.         again (This can only go back ONE time)
  730.  
  731.     ^G    Abort the replacement command (This action does not
  732.         undo previously-authorized replacements
  733.  
  734.     .    Same effect as ^G, but cursor returns to the point at
  735.         which the replacement command was given
  736.  
  737.     ?    This lists help for the query replacement command
  738. @end(verbatim)
  739.  
  740. Practice searching and searching and replacing until you feel
  741. comfortable with the commands and their effects.
  742. @begin(group)
  743. @heading(Chapter @value(chapter) Summary)
  744.  
  745. In this chapter, you learned how to search for specified strings of text
  746. in EMACS.  The chapter also dealt with searching for and replacing
  747. elements within a buffer. 
  748.  
  749. @begin(verbatim)
  750. @u(Key Binding        Keystroke             Effect)
  751.  
  752. Search-Forward        @b{^S}    Searches from point to end of buffer.
  753.                 Point is moved from current location to
  754.                 the end of the found string
  755.  
  756. Search-Backward        @b{^R}    Searches from point to beginning of buffer. 
  757.                 Point is moved from current location to
  758.                 beginning of found string
  759.  
  760. Replace            @b{M-R} Replace ALL occurrences of search string with 
  761.                 specified (null) string from point to the
  762.                 end of the current buffer
  763.  
  764. Query-Replace           @b{M-^R}    As above, but pause at each found string
  765.                 and query for action
  766. @end(verbatim)
  767. @end(group)
  768. @chapter(Windows)
  769.  
  770. @section<Creating Windows>
  771.  
  772. We have already met windows in an earlier chapter.  In this chapter, we
  773. will explore one of EMACS' more powerful features -- text manipulation
  774. through multiple windowing.
  775.  
  776. You will recall that windows are areas of buffer text that you can see
  777. @index(windows) on the screen.  Because EMACS can support several screen
  778. windows simultaneously you can use them to look into different places in
  779. the same buffer.  You can also use them to look at text in different
  780. buffers.  In effect, you can edit several files at the same time. 
  781.  
  782. Let's invoke EMACS and pull back our file on desktop publishing by
  783. typing
  784.  
  785. @quotation<emacs publish.txt>
  786.  
  787. When the text appears, type the @b{^X-2} @i(split-current-window)
  788. @index(split-current-window) command.  The window splits into two
  789. windows.  The window where the cursor resides is called the @b<current>
  790. window -- in this case the bottom window.  Notice that each window has a
  791. text area and a mode line.  The @b(command line) is however, common to
  792. all windows on the screen. 
  793.  
  794. The two windows on your screen are virtually mirror images of each other
  795. because the new window is opened into the same buffer as the one you are
  796. in when you issue the Open-Window command.  All commands issued to EMACS
  797. are executed on the current buffer in the current window.
  798.  
  799. To move the cursor to the upper window (i.e., to make that window the
  800. current window, type @b{^X-P} @i(previous-window)
  801. @index(previous-window).  Notice the cursor moves to the upper or
  802. @b<previous> window.  Entering @b{^X-O} @i(next-window) moves to the
  803. @b{next} window.  Practice moving between windows.  You will notice that
  804. you can also move into the Function Key menu by entering these commands. 
  805.  
  806. Now move to the upper window.  Let's open a new file.  On the EMACS disk
  807. is a tutorial file.  Let's call it into the upper window by typing:
  808.  
  809. @quotation<@b[^X-^F] @i(find-file) @index(find-file)>
  810.  
  811. @flushleft(and press return.  Then enter the filename @b<emacs.tut>.)
  812.  
  813. In a short time, the tutorial file will appear in the window.  We now
  814. have two windows on the screen, each looking into different buffers.  We
  815. have just used the @b(^X- ^F) @i(find-file) @index(find-file) command to
  816. find a file and bring it into our current window. 
  817.  
  818. You can scroll any window up and down with the cursor keys, or with the
  819. commands we've learned so far.    However, because the area of visible
  820. text in each window is relatively small, you can scroll the current
  821. window a line at a time.  
  822.  
  823. Type @b{^X-^N} @i(move-window-down) @index(move-window-down)
  824.  
  825. The current window scrolls down by one line -- the top line of text
  826. scrolls out of view, and the bottom line moves towards the top of the
  827. screen.  You can imagine, if you like, the whole window slowly moving
  828. down to the end of the buffer in increments of one line.  The command
  829. @b{^X-^P} @i(move-window-up) @index(move-window-up) scrolls the window
  830. in the opposite direction. 
  831.  
  832. As we have seen, EMACS editing commands are executed in the current
  833. window, but the program does support a useful feature that allows you to
  834. scroll the @b<next> window.  @b<M-^Z> @i(scroll-next-up)
  835. @index(scroll-next-up) scrolls the next window up, @b{M-^U}
  836. @i(scroll-next-down) @index(scroll-next-down) scrolls it downward.  From
  837. the tutorial window, practice scrolling the window with the desktop
  838. publishing text in it up and down. 
  839.  
  840. When you're finished, exit EMACS without saving any changes in your
  841. files. 
  842.  
  843. Windows offer you a powerful and easy way to edit text.  By
  844. manipulating a number of windows and buffers on the screen
  845. simultaneously, you can perform complete edits and revisions on the
  846. computer screen while having your draft text or original data
  847. available for reference in another window. 
  848.  
  849. Experiment with splitting the windows on your screen.  Open windows into
  850. different buffers and experiment with any other files you may have.  Try
  851. editing the text in each window, but
  852. don't forget to save any changes you want to keep -- you still have to
  853. save each buffer separately.
  854.  
  855. @section(Deleting Windows)
  856.  
  857. @section(Resizing Windows)
  858.  
  859. @section(Other Window commands)
  860.  
  861. @newpage
  862. @heading(Chapter @value(chapter) Summary)
  863.  
  864. In Chapter @value(chapter) you learned how to manipulate windows and the
  865. editing flexibility they offer. 
  866.  
  867. @begin{verbatim}
  868. @u(Key Binding        Keystroke               Effect)
  869.  
  870. Open-Window        @b{^X-2}    Splits current window into two windows
  871.                     if space is available
  872.  
  873. Close-Windows        @b{^X-1}    Closes all windows except current
  874.                     window
  875.  
  876. Next-Window        @b{^X-O}    Moves point into next (i.e. downward)
  877.                     window
  878.  
  879. Previous-Window        @b{^X-P}     Moves point to previous (i.e. upward)
  880.                     window
  881.  
  882. Move-Window-Down    @b{^X-^N}    Scrolls current window down one line
  883.  
  884. Move-Window-Up        @b{^X-^P}    Scrolls current window up one line
  885.  
  886. Redraw-display        @b{M-!} or    Window is moved so line with point
  887.             @b{M-^L}    (with cursor) is at center of window
  888.  
  889. Grow-Window        @b{^X-^}    Current window is enlarged by one
  890.                     line and nearest window is shrunk by 
  891.                     one line
  892.  
  893. Shrink-Window        @b{^X-^Z}     Current window is shrunk by one line
  894.                     and nearest window is enlarged by one
  895.                     line
  896.  
  897. Clear-and-Redraw    @b{^L}        Screen is blanked and redrawn.  Keeps
  898.                     screen updates in sync with your
  899.                     commands
  900.  
  901. Scroll-Next-Up        @b{M-^Z}     Scrolls next window up by one line
  902.  
  903. Scroll-Next-Down    @b{M-^U}     Scrolls next window down by one line
  904. @end(verbatim)
  905. @chapter(Buffers)
  906.  
  907. @index(buffers) We have already learned a number of things about buffers. 
  908. As you will recall, they are the major internal entities in EMACS -- the
  909. place where editing commands are executed.  They are characterized by
  910. their @b<names>, their @b<modes>, and by the file with which they are
  911. associated.  Each buffer also "remembers" its @b(mark) and @b(point). 
  912. This convenient feature allows you to go to other buffers and return to
  913. the original location in the "current" buffer. 
  914.  
  915. Advanced users of EMACS frequently have a number of buffers in the
  916. computer's memory simultaneously.  In the last chapter, for example, you
  917. opened at least two buffers -- one into the text you were editing, and
  918. the other into the EMACS on-line tutorial.  If you deal with complex
  919. text files -- say, sectioned chapters of a book, you may have five or
  920. six buffers in the computer's memory.  You could select different
  921. buffers by simply calling up the file with @b{^X-^F} @i(find-file)
  922. @index(find-file), and let EMACS open or reopen the buffer.  However,
  923. EMACS offers fast and sophisticated buffering techniques that you will
  924. find easy to master and much more convenient to use. 
  925.  
  926. Let's begin by opening three buffers.  You can open any three you
  927. choose, for example call the following files into memory: @b(fang.txt),
  928. @b(publish.txt), and @b(emacs.tut) in the order listed here.  When
  929. you've finished this process, you'll be looking at a screen showing the
  930. EMACS tutorial.  Let's assume that you want to move to the fang.txt
  931. buffer.  Enter:
  932.  
  933. @b{^X-X} @i(next-buffer) @index(next-buffer)
  934.  
  935. This command moves you to the @u<next> buffer.  Because EMACS cycles
  936. through the buffer list, which is alphabetized, you will now be in the
  937. @b(fang.txt) buffer. Using @b(^X-X) again places you in the
  938. @b(publish.txt) buffer. @i(If you are on a machine that supports
  939. function keys, using @b[^X-X] again places you in the @b(Function Keys)
  940. buffer). Using @b(^X-X) one last time cycles you back to the beginning
  941. of the list.
  942.  
  943. If you have a large number of buffers to deal with, this cycling process
  944. may be slow and inconvenient.  The command @b{^X-B} @i(select-buffer)
  945. @index(select-buffer) allows you to specify the buffer you wish to be
  946. switched to.  When the command is entered, EMACS prompts, "Use buffer:". 
  947. Simply enter the buffer name (NOT the file name), and that buffer will
  948. then become the current buffer. 
  949.  
  950. Multiple buffer manipulation and editing is a complex activity, and you
  951. will probably find it very inconvenient to re-save each buffer as you
  952. modify it.  The command @b{^X-^B} @i(list-buffers) @index(list-buffers)
  953. creates a new window that gives details about all the buffers currently
  954. known to EMACS.  Buffers that have been modified are identified by the
  955. "buffer changed" indicator (an asterisk in the second column).  You can
  956. thus quickly and easily identify buffers that need to be saved to files
  957. before you exit EMACS.  The buffer window also provides other
  958. information -- buffer specific modes, buffer size, and buffer name are
  959. also listed.  To close this window, simply type the close-windows
  960. command, @b{^X-1}. 
  961.  
  962. To delete any buffer, type @b{^X-K} @i(delete-buffer)
  963. @index(delete-buffer).  EMACS prompts you "Kill buffer:".  Enter the
  964. buffer name you want to delete.  As this is destructive command, EMACS
  965. will ask for confirmation if the buffer was changed and not saved. 
  966. Answer Y(es) or N(o).  As usual @b{^G} cancels the command. 
  967.  
  968. @newpage
  969. @heading(Chapter @value(chapter) Summary)
  970.  
  971. In Chapter @value(chapter) you learned how to manipulate buffers. 
  972.  
  973. @begin{verbatim}
  974. @u(Key Binding        Keystroke               Effect)
  975. Next-Buffer        @b(^X-^X)    Switch to the next buffer in the
  976.                     buffer list
  977.  
  978. Select-Buffer        @b(^X-B)    Switch to a particular buffer
  979.  
  980. List-Buffers        @b(^X-^B)    List all buffers
  981.  
  982. Delete-Buffer        @b(^X-K)    delete a particular buffer if it
  983.                     is off-screen
  984. @end(verbatim)
  985. @chapter(Modes)
  986.  
  987.     EMACS allows you to change the way it works in order to
  988. customized it to the style of editing you are using.  It does this by
  989. providing a number of different @b(modes) @index(modes).  These modes
  990. can effect either a single buffer, or any new buffer that is created. 
  991. To add a mode to the current buffer, type @b(^X-M) @i(add-mode)
  992. @index(add-mode).  EMACS will then prompt you for the name of a mode to
  993. add.  When you type in a legal mode name, and type a <NL>, EMACS will
  994. add the mode name to the list of current mode names in the mode line of
  995. the current buffer. 
  996.  
  997.     To remove an existing mode, typing the @b(^X-^M) @i(delete-mode)
  998. @index(delete-mode) will cause EMACS to prompt you for the name of a
  999. mode to delete from the current buffer.  This will remove that mode from
  1000. the mode list on the current mode line.
  1001.  
  1002.     Global modes are the modes which are inherited by any new
  1003. buffers which are created.  For example, if you wish to always do string
  1004. searching with character case being significant, you would want global
  1005. mode EXACT to be set so that any new files read in inherent the EXACT
  1006. mode.  Global modes are set with the @b(M-M) @i(add-global-mode)
  1007. @index(add-global-mode) command, and unset with the @b(M-^M)
  1008. @i(delete-global-mode) @index(delete-global-mode) command.  Also, the
  1009. current global modes are displayed in the first line of a
  1010. @b(^X-^B) @i(list-buffers) @index(list-buffers) command.
  1011.  
  1012.     On machines which are capable of displaying colors,
  1013. @index(color) the mode commands can also set the background and
  1014. foreground character colors.  Using @i(add-mode) or @i(delete-mode) with
  1015. a lowercase color will set the background color in the current window. 
  1016. An uppercase color will set the foreground color in the current window. 
  1017. Colors that EMACS knows about are: white, cyan, magenta, yellow, blue,
  1018. red, green, and black.  If the computer you are running on does not have
  1019. eight colors, EMACS will attempt to make some intelligent guess at what
  1020. color to use when you ask for one which is not there. 
  1021.  
  1022. @section(ASAVE mode)
  1023.  
  1024.     Automatic Save mode tells EMACS to automatically write out the
  1025. current buffer to its associated file on a regular basis.  Normally this
  1026. will be every 256 characters typed into the file.  The environment
  1027. variable $ACOUNT counts down to the next auto-save, and $ASAVE is the
  1028. value used to reset $ACOUNT after a save occurs. 
  1029.  
  1030. @section(CMODE mode)
  1031.  
  1032.     CMODE is useful to C programmers.  When CMODE is active, EMACS
  1033. will try to assist the user in a number of ways.  This mode is set
  1034. automatically with files that have a .c or .h extension. 
  1035.  
  1036.     The <NL> key will normally attempt to return the user to the next
  1037. line at the same level of indentation as the current line, unless the
  1038. current line ends with a open brace ({) in which case the new line will
  1039. be further indented by one tab position.
  1040.  
  1041.     A close brace (}) will delete one tab position preceding itself
  1042. as it is typed.  This should line up the close brace with its matching
  1043. IF, FOR or WHILE statement. 
  1044.  
  1045.     A pound sign (#) with only leading whitespace will delete all
  1046. the whitespace preceding itself. This will always bring preprocessor
  1047. directives flush to the left margin.
  1048.  
  1049.     Whenever any close fence is typed, i.e )]>}, if the matching open
  1050. fence is on screen in the current window, the cursor will briefly flash
  1051. to it, and then back. This makes balancing expressions, and matching
  1052. blocks much easier.
  1053.  
  1054. @section(CRYPT mode)
  1055.  
  1056.     When a buffer is in CRYPT mode, @index(encryption) it is
  1057. encrypted whenever it is written to a file, and decrypted when it is
  1058. read from the file.  The encryption key can be specified on the command
  1059. line with the -k switch, or with the @b(M-E) @i(set-encryption-key)
  1060. @index(set-encryption-key) command.  If you attempt to read or write a
  1061. buffer in crypt mode and now key has not been set, EMACS will execute
  1062. @i(set-encryption-key) automatically, prompting you for the needed key. 
  1063. Whenever EMACS prompts you for a key, it will not echo the key to your
  1064. screen as you type it (i.e make SURE you get it right when you set it
  1065. originally).
  1066.  
  1067.     The encryption algorithm used changes all characters into normal
  1068. printing characters, thus the resulting file is suitable for sending via
  1069. electronic mail.  All version of MicroEMACS should be able decrypt the
  1070. resulting file regardless of what machine encrypted it.  Also available
  1071. with EMACS is the stand alone program, MicroCRYPT, which can en/decrypt
  1072. the files produced by CRYPT mode in EMACS.
  1073.  
  1074. @section(EXACT mode)
  1075.  
  1076.     All string searches and replacements will take upper/lower case
  1077. into account. Normally the case of a string during a search or replace
  1078. is not taken into account.
  1079.  
  1080. @section(MAGIC mode)
  1081.  
  1082.      In the MAGIC mode certain characters gain special meanings when
  1083. used in a search pattern.  Collectively they are know as regular
  1084. expressions, and a limited number of them are supported in MicroEmacs. 
  1085. They grant greater flexibility when using the search command.  However,
  1086. they do not affect the incremental search command. 
  1087.  
  1088.      The symbols that have special meaning in MAGIC mode are
  1089. ^, $, ., *, [ (and ], used with it), and \.
  1090.  
  1091.      The characters ^ and $ fix the search pattern to the beginning and
  1092. end of line, respectively.  The ^ character must appear at the beginning
  1093. of the search string, and the $ must appear at the end, otherwise they
  1094. loose their meaning and are treated just like any other character.  For
  1095. example, in MAGIC mode, searching for the pattern "t$" would put the
  1096. cursor at the end of any line that ended with the letter 't'.  Note that
  1097. this is different than searching for "t<NL>", that is, 't' followed by a
  1098. newline character.  The character $ (and ^, for that matter) matches a
  1099. position, not a character, so the cursor remains at the end of the line. 
  1100. But a newline is a character that must be matched, just like any other
  1101. character, which means that the cursor is placed just after it - on the
  1102. beginning of the next line. 
  1103.  
  1104.      The character .  has a very simple meaning -- it matches any single
  1105. character, except the newline.  Thus a search for "bad.er" could match
  1106. "badger", "badder" (slang), or up to the 'r' of "bad error". 
  1107.  
  1108.      The character * is known as closure, and means that zero or more of
  1109. the preceding character will match.  If there is no character preceding,
  1110. * has no special meaning, and since it will not match with a newline, *
  1111. will have no special meaning if preceded by the beginning of line symbol
  1112. ^ or the literal newline character <NL>. 
  1113.  
  1114.      The notion of zero or more characters is important.  If, for
  1115. example, your cursor was on the line
  1116.  
  1117. @quotation(This line is missing two vowels.)
  1118.  
  1119. and a search was made for "a*", the cursor would not move, because it is
  1120. guaranteed to match no letter 'a' , which satisfies the search
  1121. conditions.  If you wanted to search for one or more of the letter 'a',
  1122. you would search for "aa*", which would match the letter a, then zero or
  1123. more of them. 
  1124.  
  1125.      The character [ indicates the beginning of a character class.  It
  1126. is similar to the 'any' character ., but you get to choose which
  1127. characters you want to match.  The character class is ended with the
  1128. character ].  So, while a search for "ba.e" will match "bane", "bade",
  1129. "bale", "bate", et cetera, you can limit it to matching "babe" and
  1130. "bake" by searching for "ba[bk]e".  Only one of the characters inside
  1131. the [ and ] will match a character.  If in fact you want to match any
  1132. character except those in the character class, you can put a ^ as the
  1133. first character.  It must be the first character of the class, or else
  1134. it has no special meaning.  So, a search for [^aeiou] will match any
  1135. character except a vowel, but a search for [aeiou^] will match any vowel
  1136. or a ^.
  1137.  
  1138. If you have a lot of characters in order that you want to put in the
  1139. character class, you may use a dash (-) as a range character.  So, [a-z]
  1140. will match any letter (or any lower case letter if EXACT mode is on),
  1141. and [0-9a-f] will match any digit or any letter 'a' through 'f', which
  1142. happen to be the characters for hexadecimal numbers.  If the dash is at
  1143. the beginning or end of a character class, it is taken to be just a
  1144. dash. 
  1145.  
  1146.      The escape character \ is for those times when you want to be in
  1147. MAGIC mode, but also want to use a regular expression character
  1148. to be just a character.  It turns off the special meaning of the
  1149. character.  So a search for "it\." will search for a line with "it.",
  1150. and not "it" followed by any other character.  The escape character
  1151. will also let you put ^, -, or ] inside a character class with no
  1152. special side effects.
  1153.  
  1154. @section(OVER mode)
  1155.  
  1156.     OVER mode stands for overwrite mode.  When in this mode, when
  1157. characters are typed, instead of simply inserting them into the file,
  1158. EMACS will attempt to overwrite an existing character past the point. 
  1159. This is very useful for adjusting tables and diagrams. 
  1160.  
  1161. @section(WRAP mode)
  1162.  
  1163.     Wrap mode is used when typing in continuous text.  Whenever the
  1164. cursor is past the currently set fill column @index(fill column) (72 by
  1165. default) and the user types a space or a <NL>, the last word of the line
  1166. is brought down to the beginning of the next line.  Using this, one just
  1167. types a continuous stream of words and EMACS automatically inserts <NL>s
  1168. at appropriate places.
  1169.  
  1170. @center(NOTE to programmers:)
  1171.  
  1172. @quotation{EMACS actually calls up the function bound to the illegal
  1173. keystroke M-FNW.  This is bound to the function @i(wrap-word)
  1174. @index(wrap-word) by default, but can be re-bound to activate different
  1175. functions and macros at wrap time.}
  1176.  
  1177. @section(VIEW mode)
  1178.  
  1179.     VIEW mode disables all commands which can change the current
  1180. buffer.  EMACS will display an error message and ring the bell every
  1181. time you attempt to change a buffer in VIEW mode.
  1182. @newpage
  1183. @heading(Chapter @value(chapter) Summary)
  1184.  
  1185. In Chapter @value(chapter) you learned about modes and their effects.
  1186.  
  1187. @begin{verbatim}
  1188. @u(Key Binding        Keystroke               Effect)
  1189. Add-Mode        @b(^X-M)    Add a mode to the current buffer
  1190.  
  1191. Delete-Mode        @b(^X-^M)    Delete a mode from the current buffer
  1192.  
  1193. Add-Global-Mode        @b(M-M)        Add a global mode to the
  1194.                     current buffer
  1195.  
  1196. Delete-Global-Mode    @b(M-^M)    Delete a global mode from the
  1197.                     current buffer
  1198. @end(verbatim)
  1199. @chapter(Files)
  1200.  
  1201. A file is simply a collection of related data.  In EMACS we are dealing
  1202. with text files -- named collections of text residing on a disk (or some
  1203. other storage medium).  You will recall that the major entities EMACS
  1204. deals with are buffers.  Disk-based versions of files are only active in
  1205. EMACS when you are reading into or writing out of buffers.  As we have
  1206. already seen, buffers and physical files are linked by associated
  1207. filenames.  For example, the buffer "ch7.txt" which is associated with
  1208. the physical disk file "ch7.txt." You will notice that the file is
  1209. usually specified by the drive name or (in the case of a hard drive) a
  1210. path.  Thus you can specify full filenames in EMACS,
  1211.  
  1212. e.g. disk:\directories\filename.extension
  1213.  
  1214. If you do not specify a disk and directories, the default disk is used.
  1215.  
  1216. IMPORTANT -- If you do not explicitly save your buffer to a file, all your
  1217. edits will be lost when you leave EMACS (although EMACS will prompt you
  1218. when you are about to lose edits by exiting).  In addition, EMACS does
  1219. not protect your disk-based files from overwriting when it saves files. 
  1220. Thus when you instruct EMACS to save a file to disk, it will create a
  1221. file if the specified file doesn't exist, or it will overwrite the
  1222. previously saved version of the file thus replacing it.  Your old
  1223. version is gone forever. 
  1224.  
  1225. If you are at all unsure about your edits, or if (for any reason) you
  1226. wish to keep previous versions of a file, you can change the name of the
  1227. associated file with the command @b{^X-N}.  When this file is saved
  1228. to disk, EMACS will create a new physical file under the new name.  The
  1229. earlier disk file will be preserved.
  1230.  
  1231. For example, let's load the file @b{fang.txt} into EMACS.  Now, type
  1232. @b{^X-N}.  The EMACS command line prompts "name:".  Enter a new name
  1233. for the file -- say @b(new.txt) and press <NL>.  The file will be
  1234. saved under the new filename, and your disk directory will show both
  1235. @b(fang.txt) and @b(new.txt).
  1236.  
  1237. An alternative method is to write the file directly to disk under a new
  1238. filename.  Let's pull our "publish.txt" file into EMACS.  To write this
  1239. file under another filename, type @b{^X-^W}.  EMACS will prompt
  1240. you "write file:".  Enter an alternate filename -- @b{desktop.txt}. 
  1241. Your file will be saved as the physical file "desktop.txt".
  1242.  
  1243. Note that in the examples above, although you have changed the names of
  1244. the related files, the buffer names remain the same.  However, when you
  1245. pull the physical file back into EMACS, you will find that the buffer
  1246. name now relates to the filename.
  1247.  
  1248. For example -- You are working with a buffer "fang.txt" with the related
  1249. file "fang.txt".  You change the name of the file to "new.txt".  EMACS
  1250. now shows you working with the buffer "fang.txt" and the related file
  1251. "new.txt".  Now pull the file "new.txt" into EMACS.  Notice that the
  1252. buffer name has now changed to "new.txt".
  1253.  
  1254. If for any reason a conflict of buffer names occurs,(if you have files
  1255. of the same name on different drives for example) EMACS will prompt
  1256. you "use buffer:".  Enter an alternative buffer name if you need to. 
  1257.  
  1258. For a list of file related commands (including some we`ve already
  1259. seen), see the summary page.
  1260. @newpage
  1261. @heading(Chapter @value(chapter) Summary)
  1262.  
  1263. In Chapter @value(chapter) you learned some of the more advanced
  1264. concepts of file naming and manipulation.  The relationship between
  1265. files and buffers was discussed in some detail. 
  1266.  
  1267. @begin(verbatim)
  1268. @u(Key Binding    Keystroke    Effect)
  1269.  
  1270. Save-file    @b{^X-^S}    Saves contents of current buffer with
  1271.                 associated filename on default disk/
  1272.                 directory (if not specified)
  1273.  
  1274. Write-File    @b{^X-^W}    Current buffer contents will be
  1275.                 saved under specified name 
  1276.  
  1277. Change-File-name
  1278.         @b{^X-N}    The associated filename is changed
  1279.                 (or associated if not previously
  1280.                 specified) as specified
  1281.  
  1282. Find-File    @b{^X-^F}    Reads specified file into buffer and 
  1283.                 switches you to that buffer, or switches
  1284.                 to buffer in which the file has previously
  1285.                 been read
  1286.  
  1287. Read-File    @b{^X-^R}    Reads file into buffer thus overwriting
  1288.                 buffer contents.  If file has already
  1289.                 been read into another buffer, you will
  1290.                 be switched to it
  1291.  
  1292. View-File    @b{^X-^V}    The same as read-file except the buffer
  1293.                 is automatically put into VIEW mode thus 
  1294.                 preventing any changes from being made
  1295. @end{verbatim}
  1296. -----snip-----snip-----snip-----snip-----snip-----snip-----snip-----snip-----
  1297. -- 
  1298.                             Paul Homchick
  1299. Chimitt Gilman Homchick, Inc.; One Radnor Station, Suite 300; Radnor, PA 19087
  1300.              {seismo!bpa | ihnp4!cbmvax} !vu-vlsi!cgh!paul
  1301.