home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / texted / uemacs / a147doc / EmacsMss next >
Text File  |  1991-06-15  |  163KB  |  4,002 lines

  1. @style(indent 5 chars, spacing 1 lines, BindingMargin .5 inches, font Times10)
  2. @Define(table, font 8, fill n, group, indent 0, spacing 1, afterexit = "@example()")
  3. @Define(goodstuff, fill n, font Helvetica10, margins 1.5 inches)
  4. @Form(ir() = "@b(@eval)@index(@eval)")
  5. @Form(FullLine="@begin(text, fill n)
  6. @ux(@>)
  7. @end(text)")
  8. @pagefooting()
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.         @big(MicroEMACS)
  26.  
  27.         Full Screen Text Editor
  28.         Reference Manual
  29.  
  30.         Version 3.11 BETA
  31.         March 24, 1991
  32.  
  33.         (C)opyright 1988, 1989, 1990, 1991 by Daniel M. Lawrence
  34.         Reference Manual (C)opyright 1988, 1989, 1990, 1991
  35.             by Brian Straight and Daniel M. Lawrence
  36.         All Rights Reserved
  37.  
  38.         @i(MicroEMACS 3.11 can be copied and distributed freely
  39.         for any non-commercial purposes. Commercial users may
  40.         use MicroEMACS 3.11 inhouse. Shareware distributers may
  41.         redistribute MicroEMACS 3.11 for media costs only.
  42.         MicroEMACS 3.11 can only be incorporated into
  43.         commercial software or resold with the permission of
  44.         the current author.)
  45. @newpage
  46. @flushleft(@big[Introduction])
  47.  
  48.     MicroEMACS is a tool for creating and changing documents,
  49. programs, and other text files. It is both relatively easy for the
  50. novice to use, but also very powerful in the hands of an expert.
  51. MicroEMACS can be extensively customized for the needs of the
  52. individual user.
  53.  
  54.     MicroEMACS allows several files to be edited at the same time.
  55. The screen can be split into different windows, and text may be moved
  56. freely from one window to the next. Depending on the type of file being
  57. edited, MicroEMACS can change how it behaves to make editing simple. 
  58. Editing standard text files, program files and word processing documents
  59. are all possible at the same time.
  60.  
  61.     There are extensive capabilities to make word processing and
  62. editing easier. These include commands for string searching and
  63. replacing, paragraph reformatting and deleting, automatic word wrapping,
  64. word move and deletes, easy case controlling, and automatic word counts.
  65.  
  66.     For complex and repetitive editing tasks editing macroes can be
  67. written. These macroes allow the user a great degree of flexibility in
  68. determining how MicroEMACS behaves. Also, any and all the commands can
  69. be used by any keystroke by changing, or rebinding, what commands
  70. various keys invoke.
  71.  
  72.     Special features are also available to perform a diverse set of
  73. operations such as file encryption, automatic backup file generation,
  74. entabbing and detabbing lines, executing operating system commands and
  75. filtering of text through other programs.
  76.  
  77. @flushleft(@big[History])
  78.  
  79.     EMACS was originally a text editor written by Richard Stallman
  80. at MIT in the early 1970s for Digital Equipment computers. Various
  81. versions, rewrites and clones have made an appearance since.
  82.  
  83.     This version of MicroEMACS is derived from code written by Dave
  84. G. Conroy in 1985. Later modifications were performed by Steve Wilhite
  85. and George Jones. In December of 1985 Daniel Lawrence picked up the
  86. then current source (version 2.0) and made extensive modifications and
  87. additions to it over the course of the next five years. Updates and
  88. support for the current version are still available. Commercial
  89. support and usage licences are also available.    The current program
  90. author can be contacted by writing to:
  91.  
  92. @begin(verbatim)
  93.     USMAIL: Daniel Lawrence
  94.         617 New York St
  95.         Lafayette, IN 47901
  96.  
  97.     UUCP:    pur-ee!mdbs!dan
  98.     ARPA:    mdbs!dan@@ee.ecn.purdue.edu
  99.     FIDO:    Opus 201/10 The Programmer's Room (317) 742-5533
  100. @end(verbatim)
  101. @flushleft(@big[Credits])
  102.  
  103.     Many people have been involved in creating this software and we
  104. wish to credit some of them here. Dave Conroy, of course, wrote the
  105. very first version of MicroEMACS, and it is a credit to his clean
  106. coding that so much work was able to be done to expand it. John Gamble
  107. is responsible for writing the MAGIC mode search routines, and for
  108. maintaining all the search code. Dana Hoggatt supplied the encryption
  109. routines for encrypt mode and continues to answer really hard questions
  110. about MSDOS and UNIX. Jeff Lomicka wrote the appendix on DEC VMS and
  111. has supplied a lot of code to support VMS and the ATARI 1040ST
  112. versions. Curtis Smith wrote the original VMS code and help support the
  113. Commodore AMIGA. Also Lance Jones has done a lot of work on the AMIGA
  114. code. Professor Suresh Konda at Carnigie Mellon has put a lot of effort
  115. into writing complex macros and finding all the bugs in the macro
  116. language before anyone else does.
  117.  
  118.     As to people sending source code and text translations over
  119. computer networks like USENET and ARPA net, there are simply more than
  120. can be listed here. [The comments in the edit history in the history.c
  121. file mention each and the piece they contributed]. All these people
  122. should be thanked for the hard work they have put into MicroEMACS.
  123.  
  124. @closing(Daniel M. Lawrence)
  125. @newpage
  126. @string(ChapterTitle="")
  127. @set(page = 0)
  128. @pageheading(odd, left "@title[Chapter]", right "MicroEMACS Reference Manual")
  129. @pageheading(even, left "MicroEMACS Reference Manual", right "@title[Chapter]")
  130. @pagefooting(odd, left="@value(page)")
  131. @pagefooting(even, right="@value(page)")
  132. @chapter(Basic Concepts)
  133.  
  134.     The current version of MicroEMACS is 3.11 (Third major
  135. re-write, eleventh public release), and for the rest of this document,
  136. we shall simply refer to this version as "EMACS". Any modifications for
  137. later versions will be in the file READ.ME on the MicroEMACS
  138. distribution disk.
  139.  
  140. @section(Keys and the Keyboard)
  141.  
  142.     Many times throughout this manual we will be talking about
  143. @index(special keys) commands and the keys on the keyboard needed to use
  144. them. There are a number of "special" keys which can be used and are
  145. listed here:
  146.  
  147. @begin(description)
  148. <NL>@\NewLine which is also called RETURN or ENTER, this key is used to
  149. @index(newline) end different commands. 
  150.  
  151. ^@\The control key can be used before any alphabetic character and some
  152. symbols. For example, ^C means to hold down the <CONTROL> key and type
  153. @index(control key) the C key at the same time. 
  154.  
  155. ^X@\The CONTROL-X key is used at the beginning of many different
  156. @index(control-x) commands. 
  157.  
  158. META or M-@\This is a special EMACS key used to begin many commands as
  159. @index(meta key) well.    This key is pressed and then released before
  160. typing the next character. On most systems, this is the <ESC> key, but
  161. it can be changed. (consult appendix E to learn what key is used for
  162. META on your computer).
  163. @end(description)
  164.  
  165. Whenever a command is described, the manual will list the actual
  166. keystrokes needed to execute it in @b(boldface) using the above
  167. conventions, and also the name of the command in @i(italics).
  168. @section(Getting Started)
  169.  
  170.     In order to use EMACS, you must call it up from your system or
  171. computer's command prompt. On UNIX and MSDOS machines, just type
  172. "emacs" from the command prompt and follow it with the <RETURN> or
  173. <ENTER> key (we will refer to this key as <NL> for "new-line" for the
  174. remainder of this manual). On the Macintosh, the Amiga, the ATARI ST
  175. and other icon based operating systems, double click on the uEMACS
  176. icon. Shortly after this, a screen similar to the one below should
  177. appear.
  178.  
  179. @section(Parts and Pieces)
  180.  
  181.     The screen is divided into a number of areas or @b<windows>. On
  182. some systems the top window contains a function list of unshifted and
  183. @index(windows) shifted function keys.    We will discuss these keys later. 
  184. @index(mode line) Below them is an EMACS @b<mode line> which, as we will
  185. see, informs you of the present mode of operation of the editor--for
  186. example "(WRAP)" if you set EMACS to wrap at the end of each line. 
  187. @index(text window) Under the mode line is the @b<text window> where text
  188. appears and is manipulated. Since each window has its own mode line,
  189. below the text window is it's mode line. The last line of the screen is
  190. the @b(command line) where EMACS takes commands and reports on what it
  191. is doing. 
  192.  
  193. @begin(table)
  194. @FullLine
  195. f1 search-> f2 <-search |    MicroEMACS:  Text Editor
  196. f3 hunt->   f4 <-hunt    | 
  197. f5 fkeys    f6 help    |  Available function key Pages include:
  198. f7 nxt wind f8 pg[    ] |    WORD  BOX    EMACS  PASCAL  C
  199. f9 save     f10 exit    |  [use the f8 key to load Pages]
  200. @FullLine
  201. @ux(   MicroEMACS 3.11 ()     Function Keys                          )
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. @FullLine
  214. @ux(---- MicroEMACS 3.11 () -- Main ----------------------------------------------)
  215.  
  216.         Fig 1:    EMACS screen on an IBM-PC
  217. @end(table)
  218.  
  219. @section(Entering Text)
  220.  
  221. Entering text in EMACS is simple. Type the following sentence fragment:
  222.  
  223. @goodstuff<Fang Rock lighthouse, center of a series of mysterious and>
  224.  
  225. @flushleft(The text is displayed at the top of the text window. Now type:)
  226.  
  227. @goodstuff<terrifying events at the turn of the century>
  228.  
  229. Notice that some of your text has dissapeared off the left side of the
  230. screen. Don't panic--your text is safe!!! You've just discovered that
  231. EMACS doesn't "wrap" text to the next line like most word processors
  232. unless you hit <NL>. But since EMACS is used for both word processing,
  233. and text editing, it has a bit of a dual personality. You can change
  234. @index(modes) the way it works by setting various @b(modes). In this
  235. case, you need to set @b(WRAP) mode, using the @i(add-mode)
  236. @index(add-mode) command, by typing @b(^XM). The command line at the
  237. base of the screen will prompt you for the mode you wish to add. Type
  238. @b<wrap> followed by the <NL> key and any text you now enter will be
  239. wrapped. However, the command doesn't wrap text already entered. To get
  240. rid of the long line, press and hold down the <BACKSPACE> key until the
  241. line is gone. Now type in the words you deleted, watch how EMACS goes
  242. down to the next line at the right time. @i{(In some versions of EMACS,
  243. @b<WRAP> is a default mode in which case you don't have to worry about
  244. the instructions relating to adding this mode.)}
  245.  
  246. Now let's type a longer insert. Hit <NL> a couple of times to tab
  247. down from the text you just entered. Now type the following paragraphs. 
  248. Press <NL> twice to indicate a paragraph break. 
  249.  
  250. @goodstuff<Fang Rock lighthouse, center of a series of mysterious and
  251. terrifying events at the turn of the century, is built on a rocky island
  252. a few miles of the Channel coast. So small is the island that wherever
  253. you stand its rocks are wet with sea spray. 
  254.  
  255. The lighthouse tower is in the center of the island. A steep flight of
  256. steps leads to the heavy door in its base. Winding stairs lead up to
  257. the crew room.>
  258.  
  259. @section<Basic cursor movement>
  260.  
  261. Now let's practice moving around in this text. To move the cursor back
  262. to the word "Winding," enter @b<M-B> @i(previous-word)
  263. @index(previous-word).    This command moves the cursor backwards by one
  264. word at a time. Note you have to press the key combination every time
  265. the cursor steps back by one word. Continuously pressing META and
  266. toggling B produces an error message. To move forward to the word
  267. "stairs" enter @b<M-F> @i(next-word)@index(next-word), which moves the
  268. cursor forward by one word at a time. 
  269.  
  270. Notice that EMACS commands are usually mnemonic--F for forward, B for
  271. backward, for example.
  272.  
  273. To move the cursor up one line, enter @b<^P> @i(previous-line)
  274. @index(previous-line), down one line @b<^N> @i(next-line)
  275. @index(next-line). Practice this movement by moving the cursor to the
  276. word "terrifying" in the second line. 
  277.  
  278. The cursor may also be moved forward or backward in smaller increments. 
  279. To move forward by one character, enter @b<^F> @i(forward-character)
  280. @index(forward-character), to move backward, @b<^B>
  281. @i(backward-character) @index(backward-character). EMACS also allows
  282. you to specify a number which is normally used to tell a command to
  283. execute many times. To repeat most commands, press META and then the
  284. number before you enter the command. Thus, the command META 5 ^F
  285. (@b<M-5^F>) will move the cursor forward by five characters. Try moving
  286. around in the text by using these commands. For extra practice, see how
  287. close you can come to the word "small" in the first paragraph by giving
  288. an argument to the commands listed here. 
  289.  
  290. Two other simple cursor commands that are useful to help us move around
  291. in the text are @b<M-N> @i(next-paragraph) @index(next-paragraph) which
  292. moves the cursor to the second paragraph, and @b<M-P>
  293. @i(previous-paragraph) @index(previous-paragraph) which moves it back
  294. to the previous paragraph. The cursor may also be moved rapidly from
  295. one end of the line to the other. Move the cursor to the word "few" in
  296. the second line. Press @b<^A> @i(beginning-of-line)
  297. @index(beginning-of-line). Notice the cursor moves to the word
  298. "events" at the beginning of the line.    Pressing @b<^E> @i(end-of-line)
  299. @index(end-of-line) moves the cursor to the end of the line. 
  300.  
  301. Finally, the cursor may be moved from any point in the file to the end
  302. or beginning of the file. Entering @b{M->} @i(end-of-file)
  303. @index(end-of-file) moves the cursor to the end of the buffer, @b{M-<}
  304. @i(beginning-of-file) @index(beginning-of-file) to the first character
  305. of the file. 
  306.  
  307. @i(On the IBM-PC, the ATARI ST and many other machines, the cursor keys
  308. @index(cursor keys) can also be used to move the cursor.)
  309.  
  310. Practice moving the cursor in the text until you are comfortable with
  311. the commands we've explored in this chapter.
  312.  
  313. @section(Saving your text)
  314.  
  315. When you've finished practicing cursor movement, save your file. Your
  316. @index(buffer) file currently resides in a @b<BUFFER>.    The buffer is a
  317. temporary storage area for your text, and is lost when the computer is
  318. turned off. You can save the buffer to a file by entering @b<^X^S>
  319. @i(save-file) @index(save-file). Notice that EMACS informs you that
  320. your file has no name and will not let you save it.
  321.  
  322. To save your buffer to a file with a different name than it's current
  323. one (which is empty), press @b<^X^W> @i(write-file) @index(write-file). 
  324. EMACS will prompt you for the filename you wish to write. Enter the
  325. name @b<fang.txt> and press return. On a micro, the drive light will
  326. come on, and EMACS will inform you it is writing the file. When it
  327. finishes, it will inform you of the number of lines it has written to
  328. the disk. 
  329.  
  330. Congratulations!! You've just saved your first EMACS file!
  331. @newpage
  332. @heading(Chapter @value(chapter) Summary)
  333.  
  334.     In chapter @value(chapter), you learned how to enter text, how
  335. to use wrap mode, how to move the cursor, and to save a buffer. The
  336. following is a table of the commands covered in this chapter and their
  337. corresponding key bindings:
  338.  
  339. @begin{verbatim}
  340. @u(Key Binding        Keystroke    Effect)
  341.  
  342. abort-command        @b<^G>        aborts current command
  343.  
  344. add-mode        @b<^XM>     allows addition of EMACS
  345.                     mode such as @b(WRAP)
  346.  
  347. backward-character    @b<^B>        moves cursor left one character
  348.  
  349. beginning-of-file    @b{M-<}     moves cursor to beginning of file
  350.  
  351. beginning-of-line    @b<^A>        moves cursor to beginning of line
  352.  
  353. end-of-file        @b{M->}     moves cursor to end of file
  354.  
  355. end-of-line        @b<^E>        moves cursor to end of line
  356.  
  357. forward-character    @b<^F>        moves cursor right one character
  358.  
  359. next-line        @b<^N>        moves cursor to next line
  360.  
  361. next-paragraph        @b<M-N>     moves cursor to next paragraph
  362.  
  363. next-word        @b<M-F>     moves cursor forward one word
  364.  
  365. previous-line        @b<^P>        moves cursor backward by one line
  366.  
  367. previous-paragraph    @b<M-P>     moves cursor to previous paragraph
  368.  
  369. previous-word        @b<M-B>     moves cursor backward by one word
  370.  
  371. save-file        @b<^X^S>    saves current buffer to a file
  372.  
  373. write-file        @b<^X^W>    save current buffer under a new name
  374. @end(verbatim)
  375. @newpage
  376. @chapter(Basic Editing--Simple Insertions and Deletions)
  377.  
  378. @section<A Word About Windows, Buffers, Screens, and Modes>
  379.  
  380. In the first chapter, you learned how to create and save a file in
  381. EMACS.    Let's do some more editing on this file. Call up emacs by
  382. typing in the following command.
  383.  
  384. @b<emacs fang.txt>
  385.  
  386. @i(On icon oriented systems, double click on the uEMACS icon, usually a
  387. file dialog box of some sort will appear. Choose @b(FANG.TXT) from the
  388. appropriate folder.)
  389.  
  390. Shortly after you invoke EMACS, the text should appear on the screen
  391. ready for you to edit.    The text you are looking at currently resides in
  392. a @b<buffer>. A buffer is a temporary area of computer memory which is
  393. @index(buffer) the primary unit internal to EMACS -- this is the place
  394. where EMACS goes to work. The mode line at the bottom of the screen
  395. lists the buffer name, @b<FANG.TXT> and the name of the file with which
  396. this buffer is associated, @b<FANG.TXT>
  397.  
  398. The computer talks to you through the use of its @b(screen). This
  399. @index(screen) screen usually has an area of 24 lines each of 80
  400. characters across. You can use EMACS to subdivide the screen into
  401. several separate work areas, or @b(windows), each of which can be
  402. @index(window) 'looking into' different files or sections of text. Using
  403. windows, you can work on several related texts at one time, copying and
  404. moving blocks of text between windows with ease. To keep track of what
  405. you are editing, each window is identified by a @b(mode line) on the
  406. @index(mode line) @index(buffer) last line of the window which lists the
  407. name of the @b(buffer) which it is looking into, the file from which the
  408. text was read, and how the text is being edited. 
  409.  
  410. An EMACS @b<mode> tells EMACS how to deal with user input. As we have
  411. already seen, the mode 'WRAP' controls how EMACS deals with long lines
  412. (lines with over 79 characters) while the user is typing them in. The
  413. 'VIEW' mode, allows you to read a file without modifying it. Modes are
  414. associated with buffers and not with files; hence, a mode needs to be
  415. explicitly set or removed every time you edit a file. A new file read
  416. into a buffer with a previously specified mode will be edited under this
  417. mode. If you use specific modes frequently, EMACS allows you to set
  418. the modes which are used by all new buffers, called @b<global> modes. 
  419.  
  420. @section<Insertions>
  421.  
  422. Your previously-saved text should look like this:
  423.  
  424. @goodstuff<Fang Rock lighthouse, center of a series of mysterious and
  425. terrifying events at the turn of the century, is built on a rocky island
  426. a few miles of the Channel coast. So small is the island that wherever
  427. you stand its rocks are wet with sea spray. 
  428.  
  429. The lighthouse tower is in the center of the island. A steep flight of
  430. steps leads to the heavy door in its base. Winding stairs lead up to
  431. the crew room.>
  432.  
  433. Let's assume you want to add a sentence in the second paragraph after
  434. the word "base."  Move the cursor until it is on the "W" of "Winding".
  435. Now type the following:
  436.  
  437. @goodstuff<This gives entry to the lower floor where the big steam
  438. generator throbs steadily away, providing power for the electric
  439. lantern.>
  440.  
  441. If the line fails to wrap and you end up with a '$' sign in the right
  442. margin, just enter @b{M-Q} @i(fill-paragraph) @index(fill-paragraph) to
  443. reformat the paragraph. This new command attempts to fill out a
  444. paragraph. Long lines are divided up, and words are shuffled around to
  445. make the paragraph look nicer. 
  446.  
  447. Notice that all visible EMACS characters are self-inserting -- all you
  448. had to do was type the characters to insert and the existing text made
  449. space for it. With a few exceptions discussed later, all non-printing
  450. characters (such as control or escape sequences) are commands.    To
  451. insert spaces, simply use the space bar. Now move to the first line of
  452. the file and type @b{^O} @i(open-line) @index(open-line) (Oh, not zero). 
  453. You've just learned how to insert a blank line in your text. 
  454.  
  455. @section<Deletions>
  456.  
  457. EMACS offers a number of deletion options. For example, move the cursor
  458. until it's under the period at the end of the insertion you just did. 
  459. Press the backspace key. Notice the "n" on "lantern" disappeared. The
  460. backspace implemented on EMACS is called a @b<destructive> backspace--it
  461. removes text immediately before the current cursor position from the
  462. buffer. Now type @b<^H> @i(delete-previous-character)
  463. @index(delete-previous-character). Notice that the cursor moves back
  464. and obliterates the "r"--either command will backspace the cursor. 
  465.  
  466. Type in the two letters you erased to restore your text and move the
  467. cursor to the beginning of the buffer @b{M->} @i(beginning-of-file)
  468. @index(beginning-of-file). Move the cursor down one line to the
  469. beginning of the first paragraph. 
  470.  
  471. To delete the forward character, type @b{^D} @i(delete-next-character)
  472. @index(delete-next-character).    The "F" of "Fang" disappears. Continue
  473. to type @b{^D} until the whole word is erased EMACS also permits the
  474. deletion of larger elements of text. Move the cursor to the word
  475. "center" in the first line of text. Pressing @b{M-<backspace>}
  476. @i(delete-previous-word) @index(delete-previous-word) kills the word
  477. immediately before the cursor.    @b{M-^H} has the same effect. 
  478.  
  479. Notice that the commands are very similar to the control commands you
  480. used to delete individual letters. As a general rule in EMACS, control
  481. sequences affect small areas of text, META sequences larger areas. The
  482. word forward of the cursor position can therefore be deleted by typing
  483. @b{M-D} @i(delete-next-word) @index(delete-next-word).    Now let's take
  484. out the remainder of the first line by typing @b{^K}
  485. @i(kill-to-end-of-line) @index(kill-to-end-of-line). You now have a
  486. blank line at the top of your screen. Typing @b{^K} again or @b{^X^O}
  487. @i(delete-blank-lines) @index(delete-blank-lines) deletes the blank line
  488. and flushes the second line to the top of the text. Now exit EMACS by
  489. typing @b{^X^C} @i(exit-emacs) @index(exit-emacs). Notice EMACS
  490. reminds you that you have not saved your buffer. Ignore the warning and
  491. exit. This way you can exit EMACS without saving any of the changes you
  492. just made. 
  493. @newpage
  494. @heading(Chapter @value(chapter) Summary)
  495.  
  496. In Chapter @value(chapter), you learned about the basic 'building
  497. blocks' of an EMACS text file--buffers, windows, and files. 
  498.  
  499. @begin{verbatim}
  500. @u(Key binding        Keystroke    Effect)
  501. delete-previous-character
  502.             @b{^H}        deletes character immediately before
  503.                     the current cursor position
  504.  
  505. delete-next-character    @b{^D}        deletes character immediately after     
  506.                     current cursor position
  507.  
  508. delete-previous-word    @b{M-^H}    deletes word immediately before
  509.                     current cursor position
  510.  
  511. delete-next-word    @b{M-D}     deletes word immediately after
  512.                     current cursor position
  513.  
  514. kill-to-end-of-line    @b<^K>        deletes from current cursor
  515.                     position to end of line
  516.  
  517. insert-space        @b<^C>        inserts a space to right of cursor
  518.  
  519. open-line        @b{^O}        inserts blank line
  520.  
  521. delete-blank-lines    @b{^X^O}    removes blank line
  522.  
  523. exit-emacs        @b{^X^C}    exits emacs
  524. @end(verbatim)
  525. @chapter(Using Regions)
  526.  
  527. @section(Defining and Deleting a Region)
  528.  
  529. At this point its time to familiarize ourselves with two more EMACS
  530. terms--the @b<point> and the @b<mark>.    The point is located directly
  531. @index(point) @index(mark) behind the current cursor position.    The mark
  532. (as we shall see shortly) is user defined. These two elements together
  533. are called the current @b(region) and limit the @b<region> of text on
  534. which EMACS performs many of its editing functions. 
  535.  
  536. Let's begin by entering some new text.    Don't forget to add @b(wrap)
  537. mode if its not set on this buffer. Start EMACS and open a file called
  538. @b{PUBLISH.TXT}. Type in the following text:
  539.  
  540. @goodstuff{One of the largest growth areas in personal computing is
  541. electronic publishing.    There are packages available for practically
  542. every machine from elegantly simple programs for the humble Commodore 64
  543. to sophisticated professional packages for PC and Macintosh computers. 
  544.  
  545. Electronic publishing is as revolutionary in its way as the Gutenburg
  546. press.    Whereas the printing press allowed the mass production and
  547. distribution of the written word, electronic publishing puts the means
  548. of production in the hands of nearly every individual.    From the class
  549. magazine to the corporate report, electronic publishing is changing the
  550. way we produce and disseminate information. 
  551.  
  552. Personal publishing greatly increases the utility of practically every
  553. computer. Thousands of people who joined the computer revolution of
  554. this decade only to hide their machines unused in closets have
  555. discovered a new use for them as dedicated publishing workstations.}
  556.  
  557. Now let's do some editing. The last paragraph seems a little out of
  558. place.    To see what the document looks like without it we can cut it
  559. from the text by moving the cursor to the beginning of the paragraph. 
  560. Enter @b(M-<space>) @i(set-mark) @index(set-mark). EMACS will respond
  561. with "[Mark set]". Now move the cursor to the end of the paragraph. 
  562. You have just defined a region of text. To remove this text from the
  563. screen, type @b<^W> @i(kill-region) @index(kill-region). The paragraph
  564. disappears from the screen. 
  565.  
  566. On further consideration, however, perhaps the paragraph we cut wasn't
  567. so bad after all. The problem may have been one of placement.    If we
  568. could tack it on to the end of the first paragraph it might work quite
  569. well to support and strengthen the argument. Move the cursor to the end
  570. of the first paragraph and enter @b<^Y> @i(yank) @index(yank).    Your
  571. text should now look like this:
  572.  
  573. @goodstuff{One of the largest growth areas in personal computing is
  574. electronic publishing.    There are packages available for practically
  575. every machine from elegantly simple programs for the humble Commodore 64
  576. to sophisticated professional packages for PC and Macintosh computers. 
  577. Personal publishing greatly increases the utility of practically every
  578. computer. Thousands of people who joined the computer revolution of
  579. this decade only to hide their machines unused in closets have
  580. discovered a new use for them as dedicated publishing workstations. 
  581.  
  582. Electronic publishing is as revolutionary in its way as the Gutenburg
  583. press.    Whereas the printing press allowed the mass production and
  584. distribution of the written word, electronic publishing puts the means
  585. of production in the hands of nearly every individual.    From the class
  586. magazine to the corporate report, electronic publishing is changing the
  587. way we produce and disseminate information.}
  588.  
  589. @section(Yanking a Region)
  590.  
  591. The text you cut initially didn't simply just disappear, it was cut into
  592. a buffer that retains the 'killed' text appropriately called the @b<kill
  593. buffer>. @b<^Y> "yanks" the text back from this buffer into the current
  594. buffer. If you have a long line (indicated, remember, by the "$"
  595. sign), simply hit @b{M-Q} to reformat the paragraph. 
  596.  
  597. There are other uses to which the kill buffer can be put. Using the
  598. @index(kill buffer) method we've already learned, define the last
  599. paragraph as a region.    Now type @b<M-W> @i(copy-region)
  600. @index(copy-region). Nothing seems to have happened; the cursor stays
  601. blinking at the point.    But things have changed, even though you may not
  602. be able to see any alteration. 
  603.  
  604. To see what has happened to the contents of the kill buffer, move the
  605. cursor down a couple of lines and "yank" the contents of the kill buffer
  606. back with @b<^Y>. Notice the last paragraph is now repeated. The
  607. region you defined is "tacked on" to the end of your file because
  608. @b<M-W> @b<copies> a region to the kill buffer while leaving the
  609. original text in your working buffer. Some caution is needed however,
  610. because the contents of the kill buffer are updated when you delete any
  611. regions, lines or words. If you are moving large quantities of text,
  612. complete the operation before you do any more deletions or you could
  613. find that the text you want to move has been replaced by the most recent
  614. deletion. Remember--a buffer is a temporary area of computer memory
  615. that is lost when the machine is powered down or switched off.    In order
  616. to make your changes permanent, they must be saved to a file before you
  617. leave EMACS. Let's delete the section of text we just added and save
  618. the file to disk. 
  619.  
  620. @heading(Chapter @value(chapter) Summary)
  621.  
  622. In Chapter @value(chapter), you learned how to achieve longer insertions
  623. and deletions.    The EMACS terms @b<point> and @b<mark> were introduced
  624. and you learned how to manipulate text with the kill buffer. 
  625.  
  626. @begin{verbatim}
  627. @begin(group)
  628. @u(Key Binding    Keystroke    Effect)
  629.  
  630. set-mark    @b{M-<space>}    Marks the beginning of a region
  631.  
  632. delete-region    @b{^W}        Deletes region between point and mark and
  633.                 places it in KILL buffer
  634.  
  635. copy-region    @b{M-W}     Copies text between point and mark into
  636.                 KILL buffer
  637.  
  638. yank-text    @b{^Y}        Inserts a copy of the KILL buffer into
  639.                 current buffer at point
  640. @end(group)
  641. @end(verbatim)
  642. @chapter(Search and Replace)
  643.  
  644. @section<Forward Search>
  645.  
  646. Load EMACS and bring in the file you just saved. Your file should look
  647. like the one below.
  648.  
  649. @goodstuff{One of the largest growth areas in personal computing is electronic
  650. publishing. There are packages available for practically every machine
  651. from elegantly simple programs for the humble Commodore 64 to
  652. sophisticated professional packages for PC and Macintosh computers. 
  653. Personal publishing greatly increases the utility of practically every
  654. computer. Thousands of people who joined the computer revolution of
  655. this decade only to hide their machines unused in closets have
  656. discovered a new use for them as dedicated publishing workstations. 
  657.  
  658. Electronic publishing is as revolutionary in its way as the Gutenburg
  659. press.    Whereas the printing press allowed the mass production and
  660. distribution of the written word, electronic publishing puts the means
  661. of production in the hands of nearly every individual.    From the class
  662. magazine to the corporate report, electronic publishing is changing the
  663. way we produce and disseminate information.}
  664.  
  665. Let's use EMACS to search for the word "revolutionary" in the second
  666. paragraph. Because EMACS searches from the current cursor position
  667. toward the end of buffers, and we intend to search forward, move the
  668. cursor to the beginning of the text. Enter @b<^S> @i(search-forward)
  669. @index(search-forward). Note that the command line now reads
  670.  
  671. "Search [] <META>:" 
  672.  
  673. EMACS is prompting you to enter the @b<search string> -- the text you
  674. want to find. Enter the word @b<revolutionary> and hit the @b<META>
  675. key. The cursor moves to the end of the word "revolutionary."
  676.  
  677. Notice that you must enter the <META> key to start the search.    If you
  678. @index(<NL>) simply press <NL> the command line responds with "<NL>". 
  679. Although this may seem infuriating to users who are used to pressing the
  680. return key to execute any command, EMACS' use of <META> to begin
  681. searches allows it to pinpoint text with great accuracy. After every
  682. line wrap or carriage return, EMACS 'sees' a new line character (<NL>). 
  683. If you need to search for a word at the end of a line, you can specify
  684. this word uniquely in EMACS. 
  685.  
  686. In our sample text for example, the word "and" occurs a number of times,
  687. but only once at the end of a line. To search for this particular
  688. occurrence of the word, move the cursor to the beginning of the buffer
  689. and type @b(^S). Notice that EMACS stores the last specified
  690. @index(default string) search string as the @b<default> string. If you
  691. press @b{<META>} now, EMACS will search for the default string, in this
  692. case, "revolutionary."
  693.  
  694. To change this string so we can search for our specified "and" simply
  695. enter the word @b{and} followed by @b{<NL>}. The command
  696. line now shows:
  697.  
  698. "search [and<NL>]<META>:"
  699.  
  700. Press @b{<META>} and the cursor moves to "and" at the end of the second
  701. last line.
  702.  
  703. @section<Exact Searches>
  704.  
  705. If the mode EXACT is active in the current buffer, EMACS searches on a case
  706. sensitive basis. Thus, for example you could search for @b{Publishing}
  707. as distinct from @b{publishing}. 
  708.  
  709.  
  710. @section<Backward Search>
  711.  
  712. Backward searching is very similar to forward searching except that it
  713. is implemented in the reverse direction. To implement a reverse search,
  714. type @b{^R} @i(search-reverse) @index(search-reverse).    Because EMACS
  715. makes no distinction between forward and backward stored search strings,
  716. the last search item you entered appears as the default string. Try
  717. searching back for any word that lies between the cursor and the
  718. beginning of the buffer. Notice that when the item is found, the point
  719. moves to the beginning of the found string (i.e., the cursor appears
  720. under the first letter of the search item). 
  721.  
  722. Practice searching for other words in your text.
  723.  
  724. @section<Searching and Replacing>
  725.  
  726. Searching and replacing is a powerful and quick way of making changes to
  727. your text. Our sample text is about electronic publishing, but the
  728. correct term is 'desktop' publishing. To make the necessary changes we
  729. need to replace all occurrences of the word "electronic" with "desktop."
  730. First, move the cursor to the top of the current buffer with the @b(M-<)
  731. command. Then type @b[M-R] @i(replace-string) @index(replace-string). 
  732. The command line responds:
  733.  
  734. "Replace []<META>:"
  735.  
  736. where the square brackets enclose the default string. Type the word
  737. @b<electronic> and hit @b{<META>}. The command line responds:
  738.  
  739. "with []<META>"
  740.  
  741. type @b{desktop<META>}. EMACS replaces all instances of the original
  742. word with your revision. Of course, you will have to capitalize the
  743. first letter of "desktop" where it occurs at the beginning of a
  744. sentence.
  745.  
  746. You have just completed an @b<unconditional replace>. In this
  747. operation, EMACS replaces every instance of the found string with the
  748. replacement string. 
  749.      
  750. @section<Query-Replace>
  751.  
  752. You may also replace text on a case by case basis. The @b{M-^R}
  753. @i(query-replace-string) @index(query-replace-string) command causes
  754. EMACS to pause at each instance of the found string. 
  755.  
  756. For example, assume we want to replace some instances of the word
  757. "desktop" with the word "personal." Go back to the beginning of the
  758. current buffer and enter the @b(M-^R) @i(query-replace)
  759. @index(query-replace) command.    The procedure is very similar to that
  760. which you followed in the unconditional search/replace option.    When the
  761. search begins however, you will notice that EMACS pauses at each
  762. instance of "publishing" and asks whether you wish to replace it with
  763. the replacement string. You have a number of options available for
  764. response:
  765.  
  766. @begin(verbatim)
  767. @u(    Response    Effect)
  768.     Y(es)    Make the current replacement and skip to the next
  769.         occurrence of the search string
  770.  
  771.     N(o)    Do not make this replacement but continue
  772.  
  773.     !    Do the rest of the replacements with no more queries
  774.  
  775.     U(ndo)    Undo just the last replacement and query for it
  776.         again (This can only go back ONE time)
  777.  
  778.     ^G    Abort the replacement command (This action does not
  779.         undo previously-authorized replacements
  780.  
  781.     .    Same effect as ^G, but cursor returns to the point at
  782.         which the replacement command was given
  783.  
  784.     ?    This lists help for the query replacement command
  785. @end(verbatim)
  786.  
  787. Practice searching and searching and replacing until you feel
  788. comfortable with the commands and their effects.
  789. @begin(group)
  790. @heading(Chapter @value(chapter) Summary)
  791.  
  792. In this chapter, you learned how to search for specified strings of text
  793. in EMACS. The chapter also dealt with searching for and replacing
  794. elements within a buffer. 
  795.  
  796. @begin(verbatim)
  797. @u(Key Binding        Keystroke             Effect)
  798.  
  799. search-forward        @b{^S}    Searches from point to end of buffer.
  800.                 Point is moved from current location to
  801.                 the end of the found string
  802.  
  803. search-backward     @b{^R}    Searches from point to beginning of buffer. 
  804.                 Point is moved from current location to
  805.                 beginning of found string
  806.  
  807. replace         @b{M-R} Replace ALL occurrences of search string with 
  808.                 specified (null) string from point to the
  809.                 end of the current buffer
  810.  
  811. query-replace           @b{M-^R} As above, but pause at each found string
  812.                 and query for action
  813. @end(verbatim)
  814. @end(group)
  815. @chapter(Windows)
  816.  
  817. @section<Creating Windows>@index{Windows, Creating}
  818.  
  819. We have already met windows in an earlier chapter. In this chapter, we
  820. will explore one of EMACS' more powerful features -- text manipulation
  821. through multiple windowing. Windows offer you a powerful and easy way
  822. to edit text. By manipulating a number of windows and buffers on the
  823. screen simultaneously, you can perform complete edits and revisions on
  824. the computer screen while having your draft text or original data
  825. available for reference in another window. 
  826.  
  827. You will recall that windows are areas of buffer text that you can see
  828. @index(windows) on the screen.    Because EMACS can support several screen
  829. windows simultaneously you can use them to look into different places in
  830. the same buffer. You can also use them to look at text in different
  831. buffers. In effect, you can edit several files at the same time. 
  832.  
  833. Let's invoke EMACS and pull back our file on desktop publishing by
  834. typing
  835.  
  836. @goodstuff<emacs publish.txt>
  837.  
  838. When the text appears, type the @b{^X2} @i(split-current-window)
  839. @index{split-current-window} command. The window splits into two
  840. windows. The window where the cursor resides is called the @b<current>
  841. window -- in this case the bottom window. Notice that each window has
  842. a text area and a mode line. The @b(command line) @index{command line}
  843. is however, common to all windows on the screen. 
  844.  
  845. The two windows on your screen are virtually mirror images of each other
  846. because the new window is opened into the same buffer as the one you are
  847. in when you issue the @i{open-window command} @index{open-window}. All
  848. commands issued to EMACS are executed on the current buffer in the
  849. current window. 
  850.  
  851. To move the cursor to the upper window (i.e., to make that window the
  852. current window, type @b{^XP} @i(previous-window) @index{previous-window}. 
  853. Notice the cursor
  854. moves to the upper or @b<previous> window. Entering @b{^XO}
  855. @i(next-window) moves to the @b{next} window. Practice moving between
  856. windows. You will notice that you can also move into the Function Key
  857. menu by entering these commands. 
  858.  
  859. Now move to the upper window. Let's open a new file. On the EMACS disk
  860. is a tutorial file. Let's call it into the upper window by typing:
  861.  
  862. @goodstuff<^X^F>
  863.  
  864. and press return.
  865.  
  866. Enter the filename @b<emacs.tut>.
  867.  
  868. In a short time, the tutorial file will appear in the window. We now have
  869. two windows on the screen, each looking into different buffers. We have
  870. just used the @b(^X^F) @i(find-file) @index{find-file}
  871. command to find a file and bring
  872. it into our current window.
  873.  
  874. You can scroll any window up and down with the cursor keys, or with the
  875. commands we've learned so far.    However, because the area of visible
  876. text in each window is relatively small, you can scroll the current
  877. window a line at a time. 
  878.  
  879. Type @b{^X^N} @i(move-window-down)@index{move-window-down}
  880.  
  881. The current window scrolls down by one line -- the top line of text
  882. scrolls out of view, and the bottom line moves towards the top of the
  883. screen. You can imagine, if you like, the whole window slowly moving
  884. down to the end of the buffer in increments of one line. The command
  885. @b{^X^P} @i(move-window-up)@index{move-window-up} 
  886. scrolls the window in the opposite
  887. direction. 
  888.  
  889. As we have seen, EMACS editing commands are executed in the current
  890. window, but the program does support a useful feature that allows you
  891. to scroll the @b<next> window.     @b<M-^Z> @i(scroll-next-up)
  892. @index{scroll-next-up} scrolls the next window up, @b{M-^V}
  893. @i(scroll-next-down)@index{scroll-next-down}  scrolls it downward. 
  894. From the tutorial window, practice scrolling the window with the
  895. desktop publishing text in it up and down. 
  896.  
  897. When you're finished, exit EMACS without saving any changes in your
  898. files. 
  899.  
  900.  
  901. Experiment with splitting the windows on your screen. Open windows
  902. into different buffers and experiment with any other files you may
  903. have. Try editing the text in each window, but don't forget to save
  904. any changes you want to keep -- you still have to save each buffer
  905. separately.
  906.  
  907. @section(Deleting Windows)@index{Windows, Deleting}
  908. Windows allow you to perform complex editing tasks with ease. However,
  909. they become an inconvenience when your screen is cluttered with open
  910. windows you have finished using. The simplest solution is to delete
  911. unneeded windows. The command @b{^X0} @i{delete-window}
  912. will delete the window you are currently working in and move you to the
  913. next window.
  914.  
  915. If you have a number of windows open, you can delete all but the current
  916. window by entering @b{^X1} @i{delete-other-windows}.
  917.  
  918. @section(Resizing Windows)@index{Windows, Resizing} 
  919.  
  920. During complex editing tasks, you will probably find it convenient to
  921. have a number of windows on the screen simultaneously.    However this
  922. situation may present inconveniences because the more windows you have
  923. on the screen the smaller they are; in some cases, a window may show
  924. only a couple of lines of text. To increase the flexibility and utility
  925. of the window environment, EMACS allows you to resize the window you are
  926. working in (called, as you will recall, the @b<current> window) to a
  927. convenient size for easier editing, and then shrink it when you no
  928. longer need it to be so large. 
  929.  
  930. Let's try an example. Load in any EMACS text file and split the current
  931. window into two. Now type @b{^X^(Shift-6)},
  932. @i{grow-window}@index{grow-window}. Your current window should be
  933. the lower one on the screen. Notice that it increases in size upwards
  934. by one line. If you are in the upper window, it increases in size in a
  935. downward direction. The command @b{^X^Z},
  936. @i{shrink-window}@index{shrink-window} correspondingly decreases window
  937. size by one line at a time. 
  938.  
  939. EMACS also allows you to resize a window more precisely by entering a
  940. numeric argument specifying the size of the window in lines. To resize
  941. the window this way, press the META key and enter a numeric argument
  942. (remember to keep it smaller than the number of lines on your screen
  943. display) then press @b{^XW} @i{resize-window}@index{resize-window}. 
  944. The current window will be enlarged or shrunk to the number of lines
  945. specified in the numeric argument. For example entering:
  946.  
  947. @goodstuff{@b[M-8 ^XW]}will resize the current window to 8 lines.
  948.  
  949. @section(Repositioning within a Window)
  950.  
  951. The cursor may be centered within a window by entering @b{M-! or M-^L}
  952. @i{redraw-display} @index{redraw-display}. This command is especially
  953. useful in allowing you to quickly locate the cursor if you are moving
  954. frequently from window to window. You can also use this command to move
  955. the line containing the cursor to any position within the current
  956. window. This is done by using a numeric argument before the command.
  957. Type @b(M-<n> M-^L) where <n> is the number of the line within the
  958. window that you wish the current line to be displayed.
  959.  
  960. The @b{^L} @i{Refresh-screen} @index{refresh-screen} command is useful
  961. for 'cleaning up' a 'messy' screen that can result of using EMACS on a
  962. mainframe system and being interrupted by a system message. 
  963. @newpage
  964. @u<Chapter @value(chapter) summary>
  965.  
  966. In Chapter @value(chapter) you learned how to manipulate windows and the
  967. editing flexibility they offer. 
  968.  
  969. @begin(verbatim)
  970. @u(Key Binding    Keystroke    Effect)
  971.  
  972. open-window    @b{^X2}     Splits current window into two windows if
  973.                 space available
  974.  
  975. close-windows    @b{^X1}     Closes all windows except current window
  976.  
  977. next-window    @b{^XO}[oh]    Moves point into next (i.e. downward) window
  978.  
  979. previous-window @b{^XP}     Moves point to previous (i.e. upward) window
  980.  
  981. move-window-down @b{^X^N}    Scrolls current window down one line
  982.  
  983. move-window-up    @b{^X^P}    Scrolls current window up one line
  984.  
  985. redraw-display    @b{M !} or    Window is moved so line with point
  986.         @b{M ^L}    (with cursor) is at center of window
  987.  
  988. grow-window    @b{M-X ^}    Current window is enlarged by one
  989.                 line and nearest window is shrunk by 
  990.                 one line
  991.  
  992. shrink-window    @b{^X^Z}    Current window is shrunk by one line
  993.                 and nearest window is enlarged by one line
  994.  
  995. clear-and-redraw @b{^L}     Screen is blanked and redrawn.    Keeps
  996.                 screen updates in sync with your commands
  997.  
  998. scroll-next-up    @b{M-^Z}    Scrolls next window up by one line
  999.  
  1000. scroll-next-down @b{M-^V}    Scrolls next window down by one line
  1001.  
  1002. delete-window    @b{^X0}     Deletes current window
  1003.  
  1004. delete-other-windows @b{^X1}    Deletes all but current window
  1005.  
  1006. resize-window    @b{^X^W}    Resizes window to a given numeric argument
  1007. @end(verbatim)
  1008. @chapter(Using a Mouse)
  1009.  
  1010.     On computers equipped with a mouse@index(mouse), the mouse can
  1011. usually be used to make editing easier. If your computer has a mouse,
  1012. let's try using it. Start MicroEMACS by typing:
  1013.  
  1014.     emacs publish.txt
  1015.  
  1016.     This brings EMACS up and allows it to edit the file from the
  1017. last chapter. If the function key window is visible on the screen,
  1018. press the F5 key to cause it to disappear. Now use the @b(^X2)
  1019. @i(split-current-window) command to split the screen into two windows. 
  1020. Next use the @b(^X^F) @i(find-file) command to read in the @b(fang.txt)
  1021. file. Now your screen should have two windows looking into two
  1022. different files.
  1023.  
  1024.     Grab the mouse and move it around. On the screen an arrow, or
  1025. block of color appears. This is called the mouse cursor @index(mouse
  1026. cursor) and can be positioned on any character on the screen. On some
  1027. computers, positioning the mouse cursor in the extreme upper right or
  1028. left corner may bring down menus which allow you to access that
  1029. computers utilities, sometimes called @b(Desk Accessories) @index(desk
  1030. accessories).
  1031.  
  1032. @section(Moving around with the mouse)
  1033.  
  1034.     Using the mouse button (or the left button if the mouse has more
  1035. than one), position the mouse over some character in the current window. 
  1036. Click the mouse button once. The @b(point) will move to where the mouse
  1037. cursor is. If you place the mouse cursor past the end of a line, the
  1038. point will move to the end of that line.
  1039.  
  1040.     Move the mouse cursor into the other window and click on one of
  1041. the characters there. MicroEMACS will automatically make this window
  1042. the current window (notice that the mode line changes) and position the
  1043. point to the mouse cursor. This makes it very easy to use the mouse to
  1044. switch to a different window quickly.
  1045.  
  1046. @section(Dragging around)
  1047.  
  1048.     Besides just using the mouse to move around on the screen, you
  1049. can use the same button to move text. Move the mouse cursor to a
  1050. character in one of the windows, and click down... but don't let the
  1051. button up yet!    The point will move to where the mouse cursor is. Now
  1052. move the mouse cursor up or down on the screen, and release the button.
  1053. The point will again move to where the mouse cursor is, but this time
  1054. it will bring the text under it along for the ride. This is called
  1055. @b(dragging)@index(dragging), and is how you can make the text appear
  1056. just where you want it to. If you try to drag text out of the current
  1057. window, EMACS will ignore your attempt and leave the point where you
  1058. first clicked down. @index(vertical scrolling)
  1059.  
  1060.     Now, click down on a word in one of the windows, and drag it
  1061. directly to the left. Release the button and watch as the entire
  1062. window slides, or @b(scrolls) @index(horizontal scrolling) to the left. 
  1063. The missing text has not been deleted, it is simply not visible, off the
  1064. left hand side of the screen. Notice the mode line has changed and now
  1065. looks like:
  1066.  
  1067. @flushleft(==== MicroEMACS 3.11 [<12] () == fang.txt == File: fang.txt =========)
  1068.  
  1069.     The [] delimits a new field which indicates that the screen is
  1070. now scrolled 12 characters from the left margin.
  1071.  
  1072.     Now grab the same text again, and drag it to the right, pulling
  1073. the rest of the text back into the current window. The [<] field will
  1074. disappear, meaning that the window is no longer scrolled to the left. 
  1075. This feature is very useful for looking at wide charts and tables. 
  1076. Remember, MicroEMACS will only scroll the text in the current window
  1077. sideways if you drag it straight to the side, otherwise it will drag
  1078. the text vertically.
  1079.  
  1080.     Now, place the mouse cursor over a character on the upper mode
  1081. line, click down, move the mouse cursor up or down a few lines and let
  1082. go of the button. The mode line moves to where you dragged it, 
  1083. changing the size of the windows above and below it. If you try to
  1084. make a window with less than one line, EMACS will not let you.    Dragging
  1085. the mode lines can make it very fast and easy for you to rearrange the
  1086. windows as you would like.
  1087.  
  1088.     If you have a number of different windows visible on the screen,
  1089. positioning the mouse over the mode line of one window and clicking the
  1090. right mouse button will cause that window to be deleted.
  1091.  
  1092. @section(Cut and Paste)
  1093.  
  1094.     If your mouse has two buttons, then you can use the right
  1095. button to do some other things as well. Earlier, we learned how to
  1096. define a @b(region)@index(region) by using the @b(M-<space>)
  1097. @i(set-mark) command. Now, position the mouse over at the beginning of
  1098. a region you would like to copy. Next click and hold down the right
  1099. mouse button. Notice that the point jumps to the mouse cursor and
  1100. EMACS reports "[Mark Set]". Holding the button down move the mouse to
  1101. the  end of the text you wish to copy and release the mouse button. 
  1102. Emacs reports "[Region Copied]" to let you know it has copied the
  1103. region into the KILL buffer. If you now click the right mouse button,
  1104. without moving the mouse, the region you defined would be deleted or
  1105. @b(cut)@index(cut) from the current buffer.
  1106.  
  1107.     If you move the mouse again, and click the right mouse button
  1108. down and up without moving the mouse, the text in the KILL buffer gets
  1109. inserted, or pasted@index(paste) into the current buffer at the point. 
  1110.  
  1111. @newpage
  1112. @heading(Chapter @value(chapter) Summary)
  1113.  
  1114. In Chapter @value(chapter), you learned how to use the mouse to move the
  1115. point, switch windows, drag text, and resize windows. You also learned
  1116. how to use the right mouse button in order to copy and delete regions
  1117. and yank them back at other places.
  1118.  
  1119. @begin{verbatim}
  1120. @begin(group)
  1121. @u(Action    Mouse Directions)
  1122.  
  1123. Move Cursor    position mouse cursor over desired location
  1124.         click down and up with left button
  1125.  
  1126. Drag Text    position mouse cursor over desired text
  1127.         click left button down
  1128.         move to new screen location for text
  1129.         release mouse button
  1130.  
  1131. Resize Windows    position mouse cursor over mode line to move
  1132.         click left button down
  1133.         move to new location for mode line
  1134.         release mouse button
  1135.  
  1136. Delete Window    position mouse cursor over mode line of window to delete
  1137.         click right mouse button
  1138.  
  1139. Resize Screen    position mouse cursor over last character on message line
  1140.         click left button down
  1141.         move to new lower right corner of screen
  1142.         release mouse button
  1143.  
  1144. Copy Region    position mouse at beginning of region
  1145.         click right button down
  1146.         move to end of region
  1147.         release mouse button
  1148.  
  1149. Cut Region    position mouse at beginning of region
  1150.         click right button down
  1151.         move to end of region
  1152.         release mouse button
  1153.         click right button down and up
  1154.  
  1155. Paste region    Position mouse at place to paste
  1156.         click right button down and up
  1157. @end(group)
  1158. @end(verbatim)
  1159. @chapter(Buffers)
  1160.  
  1161. @index(buffer)We have already learned a number of things about buffers.
  1162. As you will recall, they are the major internal entities in EMACS --
  1163. the place where editing commands are executed.    They are characterized
  1164. by their @b<names>, their @b<modes>, and by the file with which they
  1165. are associated. Each buffer also "remembers" its @b(mark) and
  1166. @b(point). This convenient feature allows you to go to other buffers
  1167. and return to the original location in the "current" buffer. 
  1168.  
  1169. Advanced users of EMACS frequently have a number of buffers in the
  1170. computer's memory simultaneously. In the last chapter, for example, you
  1171. opened at least two buffers -- one into the text you were editing, and
  1172. the other into the EMACS on-line tutorial. If you deal with complex
  1173. text files -- say, sectioned chapters of a book, you may have five or
  1174. six buffers in the computer's memory. You could select different
  1175. buffers by simply calling up the file with @b{^X^F} @i(find-file)
  1176. @index(find-file), and let EMACS open or reopen the buffer. However,
  1177. EMACS offers fast and sophisticated buffering techniques that you will
  1178. find easy to master and much more convenient to use. 
  1179.  
  1180. Let's begin by opening three buffers. You can open any three you
  1181. choose, for example call the following files into memory: @b(fang.txt),
  1182. @b(publish.txt), and @b(emacs.tut) in the order listed here. When
  1183. you've finished this process, you'll be looking at a screen showing the
  1184. EMACS tutorial. Let's assume that you want to move to the fang.txt
  1185. buffer. Enter:
  1186.  
  1187. @b{^XX} @i(next-buffer) @index(next-buffer)
  1188.  
  1189. This command moves you to the @u<next> buffer.    Because EMACS cycles
  1190. through the buffer list, which is alphabetized, you will now be in the
  1191. @b(fang.txt) buffer. Using @b(^XX) again places you in the
  1192. @b(publish.txt) buffer. @i(If you are on a machine that supports
  1193. function keys, using @b[^XX] again places you in the @b(Function Keys)
  1194. buffer). Using @b(^XX) one last time cycles you back to the beginning
  1195. of the list.
  1196.  
  1197. If you have a large number of buffers to deal with, this cycling process
  1198. may be slow and inconvenient. The command @b{^XB} @i(select-buffer)
  1199. @index(select-buffer) allows you to specify the buffer you wish to be
  1200. switched to. When the command is entered, EMACS prompts, "Use buffer:". 
  1201. Simply enter the buffer name (NOT the file name), and that buffer will
  1202. then become the current buffer. If you type in part of the file name
  1203. and press the space bar, EMACS will attempt to complete the name from
  1204. the list of current buffers. If it succeeds, it will print the rest of
  1205. the name and you can hit <NL> to switch to that buffer. If EMACS beeps
  1206. the bell, there is no such buffer, and you may continue editing the name
  1207. on the command line.
  1208.  
  1209. Multiple buffer manipulation and editing is a complex activity, and you
  1210. will probably find it very inconvenient to re-save each buffer as you
  1211. modify it. The command @b{^X^B} @i(list-buffers) @index(list-buffers)
  1212. creates a new window that gives details about all the buffers currently
  1213. known to EMACS. Buffers that have been modified are identified by the
  1214. "buffer changed" indicator (an asterisk in the second column).    You can
  1215. thus quickly and easily identify buffers that need to be saved to files
  1216. before you exit EMACS.    The buffer window also provides other
  1217. information -- buffer specific modes, buffer size, and buffer name are
  1218. also listed. To close this window, simply type the close-windows
  1219. command, @b{^X1}. 
  1220.  
  1221. To delete any buffer, type @b{^XK} @i(delete-buffer)
  1222. @index(delete-buffer).    EMACS prompts you "Kill buffer:". Enter the
  1223. buffer name you want to delete. As this is destructive command, EMACS
  1224. will ask for confirmation if the buffer was changed and not saved. 
  1225. Answer Y(es) or N(o). As usual @b{^G} cancels the command. 
  1226.  
  1227. @newpage
  1228. @heading(Chapter @value(chapter) Summary)
  1229.  
  1230. In Chapter @value(chapter) you learned how to manipulate buffers. 
  1231.  
  1232. @begin{verbatim}
  1233. @u(Key Binding        Keystroke               Effect)
  1234. next-buffer        @b(^X^X)    Switch to the next buffer in the
  1235.                     buffer list
  1236.  
  1237. select-buffer        @b(^XB)     Switch to a particular buffer
  1238.  
  1239. list-buffers        @b(^X^B)    List all buffers
  1240.  
  1241. delete-buffer        @b(^XK)     Delete a particular buffer if it
  1242.                     is off-screen
  1243. @end(verbatim)
  1244. @chapter(Modes)
  1245.  
  1246.     EMACS allows you to change the way it works in order to
  1247. customized it to the style of editing you are using. It does this by
  1248. providing a number of different @b(modes) @index(modes). These modes
  1249. can effect either a single buffer, or any new buffer that is created. 
  1250. To add a mode to the current buffer, type @b(^XM) @i(add-mode)
  1251. @index(add-mode). EMACS will then prompt you for the name of a mode to
  1252. add. When you type in a legal mode name, and type a <NL>, EMACS will
  1253. add the mode name to the list of current mode names in the mode line of
  1254. the current buffer. 
  1255.  
  1256.     To remove an existing mode, typing the @b(^X^M) @i(delete-mode)
  1257. @index(delete-mode) will cause EMACS to prompt you for the name of a
  1258. mode to delete from the current buffer. This will remove that mode from
  1259. the mode list on the current mode line.
  1260.  
  1261.     Global modes are the modes which are inherited by any new
  1262. buffers which are created. For example, if you wish to always do string
  1263. searching with character case being significant, you would want global
  1264. mode EXACT to be set so that any new files read in inherent the EXACT
  1265. mode. Global modes are set with the @b(M-M) @i(add-global-mode)
  1266. @index(add-global-mode) command, and unset with the @b(M-^M)
  1267. @i(delete-global-mode) @index(delete-global-mode) command. Also, the
  1268. current global modes are displayed in the first line of a
  1269. @b(^X^B) @i(list-buffers) @index(list-buffers) command.
  1270.  
  1271.     On machines which are capable of displaying colors,
  1272. @index(color) the mode commands can also set the background and
  1273. foreground character colors. Using @i(add-mode) or @i(delete-mode) with
  1274. a lowercase color will set the background color in the current window. 
  1275. An uppercase color will set the foreground color in the current window. 
  1276. Colors that EMACS knows about are: white, cyan, magenta, yellow, blue,
  1277. red, green, and black.    If the computer you are running on does not have
  1278. eight colors, EMACS will attempt to make some intelligent guess at what
  1279. color to use when you ask for one which is not there. 
  1280.  
  1281. @section(ASAVE mode)@index(ASAVE mode)
  1282.  
  1283.     Automatic Save mode tells EMACS to automatically write out the
  1284. current buffer to its associated file on a regular basis. Normally this
  1285. will be every 256 characters typed into the file. The environment
  1286. variable $ACOUNT counts down to the next auto-save, and $ASAVE is the
  1287. value used to reset $ACOUNT after a save occurs. 
  1288.  
  1289. @section(CMODE mode)@index(CMODE mode)
  1290.  
  1291.     CMODE is useful to C programmers. When CMODE is active, EMACS
  1292. will try to assist the user in a number of ways. This mode is set
  1293. automatically with files that have a .c or .h extension. 
  1294.  
  1295.     The <NL> key will normally attempt to return the user to the
  1296. next line at the same level of indentation as the last non blank line,
  1297. unless the current line ends with a open brace ({) in which case the
  1298. new line will be further indented by one tab position.
  1299.  
  1300.     A close brace (}) will search for the corresponding open brace
  1301. and line up with it.
  1302.  
  1303.     A pound sign (#) with only leading white space will delete all
  1304. the white space preceding itself. This will always bring preprocessor
  1305. directives flush to the left margin.
  1306.  
  1307.     Whenever any close fence is typed, IE )]>}, if the matching open
  1308. fence is on screen in the current window, the cursor will briefly flash
  1309. to it, and then back. This makes balancing expressions, and matching
  1310. blocks much easier.
  1311.  
  1312. @section(CRYPT mode)@index(CRYPT mode)
  1313.  
  1314.     When a buffer is in CRYPT mode, @index(encryption) it is
  1315. encrypted whenever it is written to a file, and decrypted when it is
  1316. read from the file. The encryption key can be specified on the command
  1317. line with the -k switch, or with the @b(M-E) @i(set-encryption-key)
  1318. @index(set-encryption-key) command. If you attempt to read or write a
  1319. buffer in crypt mode and now key has not been set, EMACS will execute
  1320. @i(set-encryption-key) automatically, prompting you for the needed key. 
  1321. Whenever EMACS prompts you for a key, it will not echo the key to your
  1322. screen as you type it (IE make SURE you get it right when you set it
  1323. originally).
  1324.  
  1325.     The encryption algorithm used changes all characters into normal
  1326. printing characters, thus the resulting file is suitable for sending via
  1327. electronic mail. All version of MicroEMACS should be able decrypt the
  1328. resulting file regardless of what machine encrypted it. Also available
  1329. with EMACS is the stand alone program, MicroCRYPT, which can en/decrypt
  1330. the files produced by CRYPT mode in EMACS.
  1331.  
  1332. @section(EXACT mode)@index(EXACT mode)
  1333.  
  1334.     All string searches and replacements will take upper/lower case
  1335. into account. Normally the case of a string during a search or replace
  1336. is not taken into account.
  1337.  
  1338. @section(MAGIC mode)@index(MAGIC mode)
  1339.  
  1340.      In the MAGIC mode certain characters gain special meanings when
  1341. used in a search pattern. Collectively they are know as regular
  1342. expressions, and a limited number of them are supported in MicroEmacs. 
  1343. They grant greater flexibility when using the search command. However,
  1344. they do not affect the incremental search command. 
  1345.  
  1346.      The symbols that have special meaning in MAGIC mode are
  1347. ^, $, ., &, ?, *, +, [ (and ], used with it), and \.
  1348.  
  1349.      The characters ^ and $ fix the search pattern to the beginning and
  1350. end of line, respectively. The ^ character must appear at the beginning
  1351. of the search string, and the $ must appear at the end, otherwise they
  1352. loose their meaning and are treated just like any other character. For
  1353. example, in MAGIC mode, searching for the pattern "t$" would put the
  1354. cursor at the end of any line that ended with the letter 't'. Note that
  1355. this is different than searching for "t<NL>", that is, 't' followed by a
  1356. newline character. The character $ (and ^, for that matter) matches a
  1357. position, not a character, so the cursor remains at the end of the line. 
  1358. But a newline is a character that must be matched like any other
  1359. character, which means that the cursor is placed just after it - on the
  1360. beginning of the next line. 
  1361.  
  1362.      The character . has a very simple meaning -- it matches any single
  1363. character, except the newline.    Thus a search for "bad.er" could match
  1364. "badger", "badder" (slang), or up to the 'r' of "bad error". 
  1365.  
  1366.      The character [ indicates the beginning of a character class. It
  1367. is similar to the 'any' character ., but you get to choose which
  1368. characters you want to match. The character class is ended with the
  1369. character ]. So, while a search for "ba.e" will match "bane", "bade",
  1370. "bale", "bate", et cetera, you can limit it to matching "babe" and
  1371. "bake" by searching for "ba[bk]e". Only one of the characters inside
  1372. the [ and ] will match a character. If in fact you want to match any
  1373. character except those in the character class, you can put a ^ as the
  1374. first character. It must be the first character of the class, or else
  1375. it has no special meaning. So, a search for [^aeiou] will match any
  1376. character except a vowel, but a search for [aeiou^] will match any vowel
  1377. or a ^.
  1378.  
  1379. If you have many characters in order, that you want to put in the
  1380. character class, you may use a dash (-) as a range character. So, [a-z]
  1381. will match any letter (or any lower case letter if EXACT mode is on),
  1382. and [0-9a-f] will match any digit or any letter 'a' through 'f', which
  1383. happen to be the characters for hexadecimal numbers. If the dash is at
  1384. the beginning or end of a character class, it is taken to be just a
  1385. dash. 
  1386.  
  1387.      The ? character indicates that the preceding character is optional.
  1388. The character may or may not appear in the matched string. For example,
  1389. a search for "bea?st" would match both "beast" and "best". If there is
  1390. no preceding charcter for ? to modify, it is treated as a normal
  1391. question mark character.
  1392.  
  1393.      The * character is known as closure, and means that zero or more
  1394. of the preceding character will match. If there is no preceding character,
  1395.  * has no special meaning and is treated as a normal asterisk. The
  1396. closure symbol will also have no special meaning if it is preceded by
  1397. the beginning of line symbol ^, since it represents a position, not a
  1398. character. 
  1399.  
  1400.      The notion of zero or more characters is important. If, for
  1401. example, your cursor was on the line
  1402.  
  1403. @goodstuff(This line is missing two vowels.)
  1404.  
  1405. and a search was made for "a*", the cursor would not move, because it is
  1406. guaranteed to match no letter 'a' , which satisfies the search
  1407. conditions. If you wanted to search for one or more of the letter 'a',
  1408. you could search for "aa*", which would match the letter a, then zero or
  1409. more of them. A better way, however, is to use the + character.
  1410.  
  1411.      The + character behaves in every respect like the * character, with
  1412. the excetion that its minimum match range is one, not zero. Thus the
  1413. pattern "a+" is identical "aa*".
  1414.  
  1415.      The character & (ampersand) is a replacement character, and
  1416. represents the characters which matched the search string. When used in
  1417. the @b[M-R] @i(replace-string) @index(replace-string) or the @b[M-^R]
  1418. @i(query-replace-string) @index(query-replace-string) commands, the &
  1419. will be substituted for the search string. 
  1420.  
  1421.      The escape character \ is for those times when you want to be in
  1422. MAGIC mode, but also want to use a regular expression character
  1423. to be just a character. It turns off the special meaning of the
  1424. character. So a search for "it\." will search for a line with "it.",
  1425. and not "it" followed by any other character. The escape character
  1426. will also let you put ^, -, or ] inside a character class with no
  1427. special side effects.
  1428.  
  1429. @section(OVER mode)@index(OVER mode)
  1430.  
  1431.     OVER mode stands for overwrite mode. When in this mode, when
  1432. characters are typed, instead of simply inserting them into the file,
  1433. EMACS will attempt to overwrite an existing character past the point. 
  1434. This is very useful for adjusting tables and diagrams. 
  1435.  
  1436. @section(WRAP mode)@index(WRAP mode)
  1437.  
  1438.     Wrap mode is used when typing in continuous text. Whenever the
  1439. cursor is past the currently set fill column @index(fill column) (72 by
  1440. default) and the user types a space or a <NL>, the last word of the line
  1441. is brought down to the beginning of the next line. Using this, one just
  1442. types a continuous stream of words and EMACS automatically inserts <NL>s
  1443. at appropriate places.
  1444.  
  1445. @center(NOTE to programmers:)
  1446.  
  1447. @quotation{The EMACS variable $wraphook contains the name of the
  1448. function which executes when EMACS detects it is time to wrap. This is
  1449. set to the function @i(wrap-word) @index(wrap-word) by default, but can
  1450. be changed to activate different functions and macros at wrap time.}
  1451.  
  1452. @section(VIEW mode)@index(VIEW mode)
  1453.  
  1454.     VIEW mode disables all commands which can change the current
  1455. buffer. EMACS will display an error message and ring the bell every
  1456. time you attempt to change a buffer in VIEW mode.
  1457. @newpage
  1458. @heading(Chapter @value(chapter) Summary)
  1459.  
  1460. In Chapter @value(chapter) you learned about modes and their effects.
  1461.  
  1462. @begin{verbatim}
  1463. @u(Key Binding        Keystroke               Effect)
  1464. add-mode        @b(^XM)     Add a mode to the current buffer
  1465.  
  1466. delete-mode        @b(^X^M)    Delete a mode from the current buffer
  1467.  
  1468. add-global-mode     @b(M-M)     Add a global mode to the
  1469.                     current buffer
  1470.  
  1471. delete-global-mode    @b(M-^M)    Delete a global mode from the
  1472.                     current buffer
  1473. @end(verbatim)
  1474. @chapter(Files)
  1475.  
  1476. A file is simply a collection of related data.    In EMACS we are dealing
  1477. with text files -- named collections of text residing on a disk (or some
  1478. other storage medium).    You will recall that the major entities EMACS
  1479. deals with are buffers. Disk-based versions of files are only active in
  1480. EMACS when you are reading into or writing out of buffers. As we have
  1481. already seen, buffers and physical files are linked by associated
  1482. file names. For example, the buffer "ch7.txt" which is associated with
  1483. the physical disk file "ch7.txt." You will notice that the file is
  1484. usually specified by the drive name or (in the case of a hard drive) a
  1485. path. Thus you can specify full file names in EMACS,
  1486.  
  1487. e.g. disk:\directories\filename.extension
  1488.  
  1489. If you do not specify a disk and directories, the default disk and the
  1490. current directory is used.
  1491.  
  1492. IMPORTANT -- If you do not explicitly save your buffer to a file, all your
  1493. edits will be lost when you leave EMACS (although EMACS will prompt you
  1494. when you are about to lose edits by exiting). In addition, EMACS does
  1495. not protect your disk-based files from overwriting when it saves files. 
  1496. Thus when you instruct EMACS to save a file to disk, it will create a
  1497. file if the specified file doesn't exist, or it will overwrite the
  1498. previously saved version of the file thus replacing it. Your old
  1499. version is gone forever. 
  1500.  
  1501. If you are at all unsure about your edits, or if (for any reason) you
  1502. wish to keep previous versions of a file, you can change the name of
  1503. the associated file with the command @b{^XN}
  1504. @i(change-file-name)@index(change-file-name). When this file is saved
  1505. to disk, EMACS will create a new physical file under the new name. The
  1506. earlier disk file will be preserved.
  1507.  
  1508. For example, let's load the file @b{fang.txt} into EMACS. Now, type
  1509. @b{^XN}. The EMACS command line prompts "Name:". Enter a new name
  1510. for the file -- say @b(new.txt) and press <NL>. The file will be
  1511. saved under the new filename, and your disk directory will show both
  1512. @b(fang.txt) and @b(new.txt).
  1513.  
  1514. An alternative method is to write the file directly to disk under a new
  1515. filename. Let's pull our "publish.txt" file into EMACS. To write this
  1516. file under another filename, type @b{^X^W}
  1517. @i(write-file)@index(writefile). EMACS will prompt you "write file:". 
  1518. Enter an alternate filename -- @b{desktop.txt}. Your file will be
  1519. saved as the physical file "desktop.txt".
  1520.  
  1521. Sometimes you will want to send your text to the end of a file that
  1522. already exists. The @i(append-file)@index(append-file) command lets you
  1523. do just that. Type ^X^A and emacs will prompt you with the name of a
  1524. file to place the current buffer at the end.
  1525.  
  1526. Note that in the examples above, although you have changed the names of
  1527. the related files, the buffer names remain the same. However, when you
  1528. pull the physical file back into EMACS, you will find that the buffer
  1529. name now relates to the filename.
  1530.  
  1531. For example -- You are working with a buffer "fang.txt" with the related
  1532. file "fang.txt". You change the name of the file to "new.txt". EMACS
  1533. now shows you working with the buffer "fang.txt" and the related file
  1534. "new.txt". Now pull the file "new.txt" into EMACS. Notice that the
  1535. buffer name has now changed to "new.txt". 
  1536.  
  1537. If for any reason a conflict of buffer names occurs,(if you have files
  1538. of the same name on different drives for example) EMACS will prompt
  1539. you "use buffer:". Enter an alternative buffer name if you need to. 
  1540.  
  1541. For a list of file related commands (including some we`ve already
  1542. seen), see the summary page.
  1543. @newpage
  1544. @heading(Chapter @value(chapter) Summary)
  1545.  
  1546. In Chapter @value(chapter) you learned some of the more advanced
  1547. concepts of file naming and manipulation. The relationship between
  1548. files and buffers was discussed in some detail. 
  1549.  
  1550. @begin(verbatim)
  1551. @u(Key Binding    Keystroke    Effect)
  1552.  
  1553. save-file    @b{^X^S}    Saves contents of current buffer with
  1554.                 associated filename on default disk/
  1555.                 directory (if not specified)
  1556.  
  1557. write-file    @b{^X^W}    Current buffer contents will be
  1558.                 saved under specified name 
  1559.  
  1560. append-file    @b{^X^A}    Append the current buffer to the end of
  1561.                 an existing file
  1562.  
  1563. change-file-name
  1564.         @b{^XN}     The associated filename is changed
  1565.                 (or associated if not previously
  1566.                 specified) as specified
  1567.  
  1568. find-file    @b{^X^F}    Reads specified file into buffer and 
  1569.                 switches you to that buffer, or switches
  1570.                 to buffer in which the file has previously
  1571.                 been read
  1572.  
  1573. read-file    @b{^X^R}    Reads file into buffer thus overwriting
  1574.                 buffer contents. If file has already
  1575.                 been read into another buffer, you will
  1576.                 be switched to it
  1577.  
  1578. view-file    @b{^X^V}    The same as read-file except the buffer
  1579.                 is automatically put into VIEW mode thus 
  1580.                 preventing any changes from being made
  1581. @end{verbatim}
  1582. @chapter(Screen Formatting)
  1583.  
  1584. @section<Wrapping Text>
  1585.  
  1586. As we learned in the introduction, EMACS is not a word processor, but an
  1587. editor. Some simple formatting options are available however, although
  1588. in most cases they will not affect the appearance of the finished text
  1589. @index(wrapping text) when it is run through the formatter. We have
  1590. already encountered WRAP mode which wraps lines longer than a certain
  1591. length (default is 75 characters). You will recall that WRAP is enabled
  1592. by entering @b{^XM} and responding to the command line prompt with
  1593. @b{wrap}. 
  1594.  
  1595. You can also set your own wrap margin with the command @b{^XF}
  1596. @i(set-fill-column) @index(set-fill-column). Notice EMACS responds
  1597. "[Fill column is 1]." Now try typing some text. You'll notice some very
  1598. strange things happening -- your text wraps at every word!! This effect
  1599. occurs because the set wrap margin command must be preceded by a
  1600. numeric argument or EMACS sets it to the first column.    Thus any text
  1601. you type that extends past the first column will wrap at the most
  1602. convenient line break. 
  1603.  
  1604. To reset the wrap column to 72 characters, press the @b{<META>} key and
  1605. enter 72. EMACS will respond "Arg: 72". Now press @b<^XF>. EMACS
  1606. will respond "[Fill column is 72]". Your text will again wrap at the
  1607. margin you've been using up to this point.
  1608.  
  1609. @section<Reformatting Paragraphs>
  1610.  
  1611. After an intensive editing session, you may find that you have
  1612. paragraphs containing lines of differing lengths. Although this
  1613. disparity will not affect the formatted text, aesthetic and technical
  1614. concerns may make it desirable to have consistent paragraph blocks on
  1615. the screen. If you are in WRAP mode, you can reformat a paragraph with
  1616. the command @b{M-Q} @i(fill-paragraph) @index(fill-paragraph).    This
  1617. command 'fills' the current paragraph reformatting it so all the lines
  1618. are filled and wrap logically.
  1619.  
  1620. @section<Changing Case>
  1621.  
  1622. There may be occasions when you find it necessary to change the case of
  1623. the text you've entered. EMACS allows you to change the case of even
  1624. large amounts of text with ease. Let's try and convert a few of the
  1625. office traditionalists to the joy of word processing. Type in the
  1626. following text:
  1627.  
  1628. @goodstuff{Throw away your typewriter and learn to use a word processor. 
  1629. Word processing is relatively easy to learn and will increase your
  1630. productivity enormously. Enter the Computer Age and find out just how
  1631. much fun it can be!!}
  1632.  
  1633. Let's give it a little more impact by capitalizing the first four words. 
  1634. The first step is to define the region of text just as you would if you
  1635. were doing an extensive deletion. Set the mark at the beginning of the
  1636. paragraph with @b{M-<space>} @i(set-mark) and move the cursor to the
  1637. space beyond "typewriter." Now enter @b{^X^U} @i(case-region-upper). 
  1638. Your text should now look like this:
  1639.  
  1640. @goodstuff{THROW AWAY YOUR TYPEWRITER and learn to use a word processor. 
  1641. Word processing is relatively easy to learn and will increase your
  1642. productivity enormously. Enter the Computer Age and find out just how
  1643. much fun it can be!!}
  1644.  
  1645. If you want to change the text back to lower case, type @b{^X^L}
  1646. @i(case-region-lower) @index(case-region-lower). You can also
  1647. capitalize individual words. To capitalize the word "fun", position the
  1648. cursor in front of the word and type @b{M-U} @i(case-word-upper)
  1649. @index(case-word-upper). The word is now capitalized.    To change it
  1650. ck to lower case, move the cursor back to the beginning of the word
  1651. and type @b{M-L} @i(case-word-lower) @index(case-word-lower). 
  1652.  
  1653. You may also capitalize individual letters in EMACS. The command
  1654. @b{M-C} @i(case-word-capitalize) @index(case-word-capitalize)
  1655. capitalizes the first letter after the point. This command would
  1656. normally be issued with the cursor positioned in front of the first
  1657. letter of the word you wish to capitalize. If you issue it in the
  1658. middle of a word, you can end up with some strAnge looking text. 
  1659.  
  1660. @section<Tabs>
  1661.  
  1662. Unless your formatter is instructed to take screen text literally (as
  1663. MicroSCRIBE does in the 'verbatim' environment for example), tabs in
  1664. EMACS generally affect screen formatting only. 
  1665.  
  1666. When EMACS is first started, it sets the default tab to every eighth
  1667. column. As long as you stay with default, every time you press the tab
  1668. key a tab character, @b(^I) is inserted. This character, like other
  1669. control characters, is invisible -- but it makes a subtle and
  1670. significant difference to your file and editing. 
  1671.  
  1672. For example, in default mode, press the tab key and then type the word
  1673. @b{Test}. "Test" appears at the eighth column. Move your cursor to the
  1674. beginning of the word and delete the backward character. The word
  1675. doesn't move back just one character, but flushes to the left margin. 
  1676. The reason for this behavior is easily explained. In tab default, EMACS
  1677. inserts a 'real' tab character when you press the tab key. This
  1678. character is inserted at the default position, but NO SPACES are
  1679. inserted between the tab character and the margin (or previous tab
  1680. character). As you will recall, EMACS only recognizes characters (such
  1681. as spaces or letters) and thus when the tab character is removed, the
  1682. text beyond the tab is flushed back to the margin or previous tab mark.
  1683.  
  1684. This situation changes if you alter the default configuration.    The
  1685. default value may be changed by entering a numeric argument before
  1686. pressing the tab key. As we saw earlier, pressing the @b{META} key and
  1687. entering a number allows you to specify how EMACS performs a given
  1688. action. In this case, let's specify an argument of 10 and hit the tab
  1689. key. 
  1690.  
  1691. Now hit the tab key again and type @b{Test}. Notice the word now
  1692. appears at the tenth column. Now move to the beginning of the word and
  1693. delete the backward character.    "Test" moves back by one character. 
  1694.  
  1695. EMACS behaves differently in these circumstances because the @b(^I)
  1696. @index(tab handling) @i(handle-tab) @index(handle-tab) function deals
  1697. with tabbing in two distinct ways. In default conditions, or if the
  1698. numeric argument of zero is used, @i(handle-tab) inserts a true tab
  1699. character. If, however, a non-zero numeric argument is specified,
  1700. @i(handle-tab) inserts the correct number of spaces needed to position
  1701. the cursor at the next specified tab position.    It does NOT insert the
  1702. single tab character and hence any editing functions should take account
  1703. of the number of spaces between tabbed columns.
  1704.  
  1705. The distance which a true tab character moves the cursor can be
  1706. modified by changing the value of the $hardtab environment variable. 
  1707. Initially set to 8, this will determine how far each tab stop is placed
  1708. from the previous one.    (Use the ^XA @i(set)@index(set) command to set
  1709. the value of an environment variable).
  1710.  
  1711. Many times you would like to take text which has been created using
  1712. the tab character and change it to use just spaces. The command
  1713. @b(^X^D) @i(detab-region) @index(detab-region) changes any tabs 
  1714. in the currently selected region into the right number of spaces so
  1715. the text does not change. This is very useful for times when the file
  1716. must be printed or transferred to a machine which does not understand
  1717. tabs. 
  1718.  
  1719. Also, the inverse command, @b(^X^E) @i(entab-region)
  1720. @index(entab-region) changes multiple spaces to tabs where possible. 
  1721. This is a good way to shrink the size of large documents, especially
  1722. with data tables. Both of these commands can take a numeric argument
  1723. which will be interpreted as the number of lines to en/detab. 
  1724.  
  1725. Another function, related to those above is provided for by the @b(^X^T)
  1726. @i(trim-region)@index(trim-region) when invoked will delete any trailing
  1727. white space in the selected region. A preceding numeric argument will do
  1728. this for that number of lines.
  1729. @newpage
  1730. @heading(Chapter @value(chapter) Summary)
  1731.  
  1732. In Chapter @value(chapter) introduced some of the formatting features of
  1733. EMACS. Text-wrap, paragraph reformatting, and tabs were discussed in
  1734. some detail. The commands in the following table were covered in the
  1735. chapter. 
  1736.  
  1737. @begin{verbatim}
  1738.  
  1739. @u(Key Binding        Keystroke            Effect)
  1740. add-mode/WRAP        @b{^XM}[WRAP]    Add wrap mode to current buffer
  1741.  
  1742. delete-mode/WRAP    @b{^X^M}[WRAP]    Remove wrap mode from current buffer
  1743.  
  1744. set-fill-column     @b{^XF}     Set fill column to given numeric
  1745.                     argument  
  1746.  
  1747. fill-paragraph        @b{M-Q}     Logically reformats the current
  1748.                     paragraph
  1749.  
  1750. case-word-upper     @b{M-U}     Text from point to end of the
  1751.                     current word is changed to uppercase
  1752.  
  1753. case-word-lower     @b{M-L}     Text from point to end of the 
  1754.                     current word is changed to lowercase
  1755.  
  1756. case-word-capitalize    @b{M-C}     First word (or letter) after the
  1757.                     point is capitalized
  1758.  
  1759. case-region-upper    @b{^X^U}    The current region is uppercased
  1760.  
  1761. case-region-lower    @b{^X^L}    The current region is lowercased
  1762.  
  1763. handle-tab        @b{^I}        Tab interval is set to the given
  1764.                     numeric argument
  1765.  
  1766. entab-region        @b(^X^E)    Changes multiple spaces to tabs
  1767.                     characters where possible
  1768.  
  1769. detab-region        @b(^X^D)    Changes tab characters to the
  1770.                     appropriate number of spaces
  1771.  
  1772. trim-region        @b(^X^T)    Trims white space from the end
  1773.                     of the lines in the current region
  1774. @end{verbatim}
  1775. @chapter(Access to the Outside World)
  1776.  
  1777.     EMACS has the ability to interface to other programs and the
  1778. environment of the computer outside of itself.    It does this through a
  1779. series of commands that allow it to talk to the computer's @b(command
  1780. processor) @index(command processor) or @b(shell) @index(shell). Just
  1781. what this is varies between different computers. Under MSDOS or PCDOS
  1782. this is the @b(command.com) @index(command.com) command processor. 
  1783. Under UNIX it is the @b(csh) @index(cshell) shell. On the Atari ST is
  1784. can be the Mark Williams @b(MSH) or the Beckmeyer shell. In each case,
  1785. it is the part of the computer's operating system that is responsible
  1786. for determining what programs are executed, and when. 
  1787.  
  1788.     The @b(^X!) @i(shell-command) @index(shell-command) command
  1789. prompts the user for a command line to send out to the shell to execute.
  1790. This can be very useful for doing file listings and changing the
  1791. current directory or folder. EMACS gives control to the shell, which
  1792. executed the command, and then types @b([END]) and waits for the user to
  1793. type a character before redrawing the screen and resuming editing. If
  1794. the @i(shell-command) command is used from within the macro language,
  1795. there is no pause.
  1796.  
  1797.     @b(^X@@) @i(pipe-command) @index(pipe-command) command allows
  1798. EMACS to execute a shell command, and if the particular computer allows
  1799. it, send the results into a buffer which is automatically displayed on
  1800. the screen. The resulting buffer, called "command" can be manipulated
  1801. just like any other editing buffer. Text can be copied out of it or
  1802. rearranged as needed. This buffer is originally created in @b(VIEW) mode,
  1803. so remember to @b(^X^Mview<NL>) in order to change it.
  1804.  
  1805.     Many computers provide tools which will allow you to @b(filter)
  1806. @index(filter) text, making some modifications to it along the way. A
  1807. very common tool is the @b(SORT) program which accepts a file, sorts
  1808. it, and prints the result out. The EMACS command, @b(^X#)
  1809. @i(filter-buffer)@index(filter-buffer) sends the current buffer through
  1810. such a filter. Therefore, if you wished to sort the current buffer on
  1811. a system which supplied a sort filter, you would type @b(^X#sort<NL>). 
  1812. You can also create your own filters by writing programs and utilities
  1813. which read text from the keyboard and display the results. EMACS will
  1814. use any of these which would normally be available from the current
  1815. shell.
  1816.  
  1817.     If you would like to execute another program directly, without
  1818. the overhead of an intervening shell, you can use the @b(^X$)
  1819. @i(execute-program) @index(execute-program) command. It will prompt you
  1820. for an external program and its arguments and attempt to execute it. 
  1821. Like when EMACS looks for command files, EMACS will look first in the
  1822. HOME directory, then down the execute PATH, and finally in the current
  1823. directory for the named program. On some systems, it will automatically
  1824. tack the proper extension on the file name to indicate it is a program.
  1825. On some systems that don't support this function, @b(^X$) will be
  1826. equivalent to @b(^X!) @i(shell-command).
  1827.  
  1828.     Sometimes, you would like to get back to the shell and execute
  1829. other commands, without losing the current contents of EMACS. The
  1830. @b(^XC) @i(i-shell) @index(i-shell) command shells out of EMACS,
  1831. leaving EMACS in the computer and executing another command shell. Most
  1832. systems would allow you to return to EMACS with the "exit" command. 
  1833.  
  1834. @i(    On some systems, mainly advanced versions of UNIX, you can
  1835. direct EMACS to "go into the background" with the @b(^XD) suspend-emacs
  1836. @index(suspend-emacs) command.    This places EMACS in the background
  1837. returning you to the original command shell. EMACS can then be returned
  1838. to at any time with the "fg" foreground command.)
  1839. @newpage
  1840. @heading(Chapter @value(chapter) Summary)
  1841.  
  1842. In Chapter @value(chapter) introduced different ways to access the
  1843. computers shell or command processor from within EMACS. The commands
  1844. in the following table were covered in the chapter. 
  1845.  
  1846. @begin{verbatim}
  1847.  
  1848. @u(Key Binding        Keystroke            Effect)
  1849. execute-program     @b(^X$)     Execute an external program
  1850.                     directly
  1851.  
  1852. filter-command        @b(^X#)     Send the current buffer through
  1853.                     a shell filter
  1854.  
  1855. i-shell         @b(^XC)     Escape to a new shell
  1856.  
  1857. pipe-command        @b(^X@@)    Send the results of an external
  1858.                     shell command to a buffer
  1859.  
  1860. shell-command        @b(^X!)     Execute one shell command
  1861.  
  1862. suspend-emacs        @b(^XD)     Place EMACS in the background
  1863.                     (some UNIX systems only)
  1864. @end{verbatim}
  1865. @chapter(Keyboard Macros)
  1866.  
  1867. In many applications, it may be necessary to repeat a series of
  1868. characters or commands frequently. For example, a paper may require the
  1869. frequent repetition of a complex formula or a long name. You may also
  1870. have a series of EMACS commands that you invoke frequently. Keyboard
  1871. macros offer a convenient method of recording and repeating these
  1872. commands. 
  1873.  
  1874. Imagine, for example, you are writing a scholarly paper on @i{Asplenium
  1875. platyneuron}, the spleenwort fern. Even the dedicated botanist would
  1876. probably find it a task bordering on the agonizing to type
  1877. @i{Asplenium platyneuron} frequently throughout the paper. An
  1878. alternative method is 'record' the name in a keyboard macro. Try it
  1879. yourself.
  1880.  
  1881. The command @b{^X(} @i(begin-macro) @index(begin-macro) starts
  1882. recording the all the keystrokes and commands you input. After you've
  1883. typed it, enter @b{Asplenium platyneuron}. To stop recording, type
  1884. @b{^X)} @i(end-macro) @index(end-macro). EMACS has stored all the
  1885. keystrokes between the two commands. To repeat the name you've stored,
  1886. just enter @b{^XE} @i(execute-macro) @index(execute-macro), and the
  1887. name "Asplenium platyneuron" appears. You can repeat this action as
  1888. often as you want, and of course as with any EMACS command, you may
  1889. precede it with a numerical argument. 
  1890.  
  1891. Because EMACS records keystrokes, you may freely intermix commands and
  1892. text. Unfortunately, you can only store one macro at a time. Thus, if
  1893. you begin to record another macro, the previously defined macro is
  1894. lost. Be careful to ensure that you've finished with one macro before
  1895. defining another. If you have a series of commands that you would like
  1896. to 'record' for future use, use the macro or procedure facilities
  1897. detailed in chapter <X>.
  1898. @newpage
  1899. @heading(Chapter @value(chapter) Summary)
  1900.  
  1901. Chapter @value(chapter) covered keyboard macros. You learned how to
  1902. record keystrokes and how to repeat the stored sequence. 
  1903.  
  1904. @begin{verbatim}
  1905. @u(Key Binding        Keystroke        Effect)
  1906.  
  1907. start-macro        @b{^X(}     Starts recording all keyboard input
  1908.  
  1909. end-macro        @b{^X)}     Stops recording keystrokes for macro
  1910.  
  1911. execute-macro        @b{^XE}     Entire sequence of recorded
  1912.                     keystrokes is replayed
  1913. @end{verbatim}
  1914. @chapter(MicroEMACS Macros)
  1915.  
  1916.     Macros are programs that are used to customize the editor and to
  1917. perform complicated editing tasks. They may be stored in files or
  1918. buffers and may be executed using an appropriate command, or bound to a
  1919. particular keystroke. Portions of the standard start-up file are
  1920. implemented via macros, as well as the example menu system. The
  1921. @i(execute-macro-<n>) @index(execute-macro-<n>) commands cause the
  1922. macro, numbered from 1 to 40, to be executed. The @i(execute-file)
  1923. @index(execute-file) command allows you to execute a macro stored in a
  1924. disk file, and the @i(execute-buffer) @index(execute-buffer) command
  1925. allows you to execute a macro stored in a buffer. Macros are stored for
  1926. easy execution by executing files that contain the store-macro command. 
  1927.  
  1928.     If you need more than 40 macros, named macroes, called
  1929. @b(procedures), @index(procedures) can be used. The @i(store-procedure)
  1930. @index(store-procedure) command takes a string argument which is the
  1931. name of a procedure to store. These procedures than can be executed
  1932. with the @b(M-^E) @i(execute-procedure) @index(execute-procedure) or the
  1933. @i(run) @index(run) commands. Also, giving the name of a stored
  1934. procedure within another macro will executed that named procedure as if
  1935. it had been called up with the @i(run) command.
  1936.  
  1937.     Some fairly length examples of MicroEMACS macroes can be seen by
  1938. examining the standard files that come with EMACS. The @b(emacs.rc)
  1939. @index(emacs.rc) file (called @b[.emacsrc]@index[.emacsrc]) under UNIX)
  1940. is the EMACS macro file which is executed when EMACS is normally run. 
  1941. It contains a number of different stored macroes along with the lines to
  1942. setup and display the Function key window @index(function key window)
  1943. and to call up other commands and macro files using function keys.
  1944.  
  1945.     There are many different aspects to the macro language within
  1946. MicroEMACS. Editor commands are the various commands that manipulate
  1947. text, buffers, windows, et cetera, within the editor. Directives are
  1948. commands which control what lines get executed within a macro.    Also
  1949. there are various types of variables. Environmental variables both
  1950. control and report on different aspects of the editor.    User variables
  1951. hold string values which may be changed and inspected.    Buffer
  1952. variables allow text to be placed into variables. Interactive variable
  1953. allow the program to prompt the user for information. Functions can be
  1954. used to manipulate all these variables. 
  1955.  
  1956. @section(Constants)
  1957.  
  1958.     All constants and variable contents in EMACS are stored as
  1959. strings of characters. Numbers are stored digit by digit as characters.
  1960. This allows EMACS to be "typeless", not having different variables types
  1961. be legal in different contexts. This has the disadvantage of forcing the
  1962. user to be more careful about the context of the statements variables
  1963. are placed in, but in turn gives them more flexibility in where they
  1964. can place variables. Needless to say, this also allows EMACS's expression
  1965. evaluator to be both concise and quick.
  1966.  
  1967.     Wherever statements need to have arguments, it is legal to place
  1968. constants. A constant is a double quote character, followed by a string
  1969. of characters, and terminated by another double quote character. To
  1970. represent various special characters within a constant, the tilde (~)
  1971. character is used. The character following the tilde is interpreted
  1972. according to the following table:
  1973.  
  1974. @begin(verbatim)
  1975. @u(Sequence    Result)
  1976. ~n            EMACS newline character (breaks lines)
  1977. ~r        ^M    carriage return
  1978. ~l        ^J    linefeed
  1979. ~~        ~    tilde
  1980. ~b        ^H    backspace
  1981. ~f        ^L    formfeed
  1982. ~t        ^I    tab
  1983. ~"        "    quote
  1984. @end(verbatim)
  1985.  
  1986.     Any character not in the table which follows a tilde will be
  1987. passed unmodified. This action is similar to the @b(^Q)
  1988. @i(quote-character) command available from the keyboard. 
  1989.  
  1990.     EMACS may use different characters for line terminators
  1991. on different computers. The ~n combination will always get the proper
  1992. line terminating sequence for the current system.
  1993.  
  1994.     The double quotes around constants are not needed if the
  1995. constant contains no internal white space and it also does not happen to
  1996. meet the rules for any other EMACS commands, directives, variables, or
  1997. functions. This is reasonable useful for numeric constants.
  1998.  
  1999. @section(Variables)
  2000.  
  2001.     Variables in MicroEMACS can be used to return values within
  2002. expressions, as repeat counts to editing commands, or as text to be
  2003. inserted into buffers and messages. The value of these variables is set
  2004. using the set (^XA) command. For example, to set the current fill
  2005. column to 64 characters, the following macro line would be used:
  2006.  
  2007.     set $fillcol 64
  2008.  
  2009.     or to have the contents of @b(%name) inserted at the point in the
  2010. current buffer, the command to use would be:
  2011.  
  2012.     insert-string %name
  2013. @newpage
  2014. @subsection(Environmental Variables)
  2015.  
  2016.     "What good is a quote if you can't change it?"
  2017.  
  2018.     These variables are used to change different aspects of the way
  2019. the editor works. Also they will return the current settings if used as
  2020. part of an expression.    All environmental variable names begin with a
  2021. dollar sign ($) and are in lower case.
  2022.  
  2023. @begin(description)
  2024. $acount@\The countdown of inserted characters until the next save-file
  2025.  
  2026. $asave@\The number of inserted characters between automatic file-saves
  2027. in ASAVE mode
  2028.  
  2029. $bufhook@\The function named in this variable is run when a buffer is
  2030. entered. It can be used to implement modes which are specific to a
  2031. paricular file or file type.
  2032.  
  2033. $cbflags@\Current buffer attribute flags (See appendix G for details)
  2034.  
  2035. $cbufname@\Name of the current buffer
  2036.  
  2037. $cfname@\File name of the current buffer
  2038.  
  2039. $cmdhook@\Name of function to run before accepting a command. This is
  2040. by default set to @i(nop)
  2041.  
  2042. $cmode@\Integer containing the mode of the current buffer. (See Appendix F
  2043. for values)
  2044.  
  2045. $curchar@\Ascii value of the character currently at the point
  2046.  
  2047. $curcol@\Current column of point in current buffer
  2048.  
  2049. $curline@\Current line of point in current buffer
  2050.  
  2051. $curwidth@\Number of columns used currently
  2052.  
  2053. $cwline@\Current display line in current window
  2054.  
  2055. $debug@\Flag to trigger macro debugging
  2056.  
  2057. $diagflag@\If set to TRUE, diagonal dragging of text and mode lines is
  2058. enabled. If FALSE, text and modelines can only be dragged horizontally
  2059. or vertically at one time.
  2060.  
  2061. $discmd@\Controls the echoing of command prompts. Default is TRUE.
  2062.  
  2063. $disinp@\Controls the echoing of input at the command prompts. Default
  2064. is TRUE.
  2065.  
  2066. $disphigh@\If set to TRUE, high-bit characters (single byte characters
  2067. that are greater than 127 in value) will be displayed in a
  2068. pseudo-control format. The characters "^!" will lead off the sequence,
  2069. followed by the character stripped of its high bit. Default is FALSE
  2070.  
  2071. $exbhook@\This variable holds the name of a function or macro which is
  2072. run whenever you are switching out of a buffer.
  2073.  
  2074. $fcol@\The current line position being displayed in the first column of
  2075. the current window.
  2076.  
  2077. $fillcol@\Current fill column
  2078.  
  2079. $flicker@\Flicker Flag set to TRUE if IBM CGA set to FALSE for most others
  2080.  
  2081. $gflags@\Global flags controlling some EMACS internal functions (See
  2082. appendix G for details)
  2083.  
  2084. $gmode@\Global mode flags. (See Appendix F for values)
  2085.  
  2086. $hardtab@\Number of spaces between hard tab stops. Normally 8, this can
  2087. be used to change indentation only within the editor.@index(tabs)
  2088.  
  2089. $hjump@\The number in here tells EMACS how many columns to scroll the
  2090. screen horizontally when a horizontal scroll is required.
  2091.  
  2092. $hscroll@\This flag determines if EMACS will scroll the entire current
  2093. window horizontally, or just the current line.    The default value, TRUE,
  2094. results in the entire current window being shifted left and right when
  2095. the cursor goes off the edge of the screen.
  2096.  
  2097. $kill@\This contains the first 127 characters currently in the kill
  2098. buffer and can be used to set the contents of the kill buffer
  2099.  
  2100. $language@\[READ ONLY]Contains the name of the language which the
  2101. current EMACS's message will display. (Currently EMACS is available in
  2102. English, French, Spanish, Pig Latin, Portuguese, Dutch, German and
  2103. Esperonto).
  2104.  
  2105. $lastkey@\[READ ONLY]Last keyboard character typed
  2106.  
  2107. $lastmesg@\[READ ONLY]Contains the text of the last message which
  2108. emacs wrote on the command line
  2109.  
  2110. $line@\The current line in the current buffer can be retrieved and
  2111. set with this environment variable
  2112.  
  2113. $lterm@\Character(s) to write as a line terminator when writing a file
  2114. to disk. Default is null, which causes a '\n' character to be written.
  2115. Not all operating systems support this.
  2116.  
  2117. $lwidth@\[READ ONLY]Returns the number of characters in the current line
  2118.  
  2119. $match@\[READ ONLY]Last string matched in a search
  2120.  
  2121. $modeflag@\Determines if mode lines are currently displayed
  2122.  
  2123. $msflag@\If TRUE, the mouse (if present) is active. If FALSE, no mouse
  2124. cursor is displayed, and no mouse actions are taken.@index(mouse)
  2125.  
  2126. $oldcrypt@\Use the old method of encryption (which had a bug in it). 
  2127. Default is FALSE.
  2128.  
  2129. $pagelen@\Number of screen lines used currently
  2130.  
  2131. $palette@\string used to control the palette register settings on
  2132. graphics versions. The usually form consists of groups of three octal
  2133. digits setting the red, green, and blue levels.@index(color pallette)
  2134.  
  2135. $pending@\[READ ONLY]Flag to determine if there are user keystrokes
  2136. waiting to be processed.
  2137.  
  2138. $popflag@\Use pop-up windows. Default is TRUE.
  2139.  
  2140. $progname@\[READ ONLY]Always contains the string "MicroEMACS" for
  2141. standard MicroEMACS. Could be something else if EMACS is incorporated
  2142. as part of someone else's program
  2143.  
  2144. $ram@\ The amount of remaining memory if MicroEMACS was compiled with
  2145. RAMSIZE set. A debugging tool.
  2146.  
  2147. $readhook@\This variable holds the name of a function to execute
  2148. whenever a file is read into EMACS. Normally, using the standard
  2149. @b(emacs.rc) file, this is bound to a function which places EMACS into
  2150. CMODE if the extension of the file read is .c or .h
  2151.  
  2152. $region@\Contains the string of the current region. It will truncate at
  2153. the stringsize limit, 255.
  2154.  
  2155. $replace@\Current default replace string
  2156.  
  2157. $rval@\This contains the return value from the last subprocess which was
  2158. invoked from EMACS
  2159.  
  2160. $search@\Current default search string
  2161.  
  2162. $searchpnt@\Set the placement of the of the cursor on a successful
  2163. search match. $searchpnt = 0 (the default), causes the cursor to be placed at the
  2164. end of the matched text on forward searches, and at the beginning of the
  2165. text on reverse searches. $searchpnt = 1 causes the cursor to be placed
  2166. at the the beginning of the matched text regardless of the search
  2167. direction, while $searchpnt = 2 causes the cursor to be placed at the end.
  2168.  
  2169. $seed@\Integer seed of the random number generator
  2170.  
  2171. $softtab@\Number of spaces inserted by EMACS when the handle-tab command
  2172. (which is normally bound to the TAB key) is invoked.@index(tabs)
  2173.  
  2174. $sres@\Current screen resolution (CGA, MONO, EGA or VGA on the IBM-PC
  2175. driver. LOW, MEDIUM, HIGH or DENSE on the Atari ST1040, NORMAL on all
  2176. others)@index(screen resolution)
  2177.  
  2178. $ssave@\If TRUE, when EMACS is asked to save the current file, it
  2179. writes all files out to a temporary file, deletes the original, and
  2180. then renames the temporary to the old file name. The default value of
  2181. this is TRUE.
  2182.  
  2183. $sscroll@\Changes EMACS, when set to TRUE, to smoothly scroll windows
  2184. (one line at a time) when cursoring off the ends of the current
  2185. window.
  2186.  
  2187. $status@\[READ ONLY]Status of the success of the last command (TRUE or
  2188. FALSE). This is usually used with !force to check on the success of a
  2189. search, or a file operation. 
  2190.  
  2191. $sterm@\This is the character used to terminate search string inputs.
  2192. The default for this is the last key bound to @i(meta-prefix)
  2193.  
  2194. $target@\Current target for line moves (setting this fool's EMACS into
  2195. believing the last command was a line move)
  2196.  
  2197. $time@\[READ ONLY]Contains a string corresponding to the current date
  2198. and time. Usually this is in a form similar to "Mon May 09 10:10:58 1988".
  2199. Not all operating systems will support this.
  2200.  
  2201. $tpause@\Controls the length of the pause to display a matched fence
  2202. when the current buffer is in CMODE and a close fence has been typed.
  2203.  
  2204. $version@\[READ ONLY]Contains the current MicroEMACS version number.
  2205.  
  2206. $wchars@\When set, MicroEMACS uses the characters listed in it to
  2207. determine if it is in a word or not. If it is not set (the default),
  2208. the characters it uses are the upper and lower case letters, and the
  2209. underscore.
  2210.  
  2211. $wline@\Number of display lines in current window
  2212.  
  2213. $wraphook@\This variable contains the name of an EMACS function which is
  2214. executed when a buffer is in WRAP mode and it is time to wrap.    By
  2215. default this is bound to @i(wrap-word).
  2216.  
  2217. $writehook@\This variable contains the name of an EMACS function or
  2218. macro which is invoked whenever EMACS attempts to write a file out to
  2219. disk. This is executed before the file is written, allowing you to
  2220. process a file on the way out.
  2221.  
  2222. $xpos@\The column the mouse was at the last mouse button press
  2223.  
  2224. $ypos@\The line which the mouse was on during the last mouse button press
  2225. @end(description)
  2226.  
  2227.     Obviously, many more of these variables will be available in
  2228. future releases of MicroEMACS. (Yes, send a vote for your favorite new
  2229. environmental variables today).
  2230.  
  2231. @subsection(User variables)
  2232.  
  2233.     User variables allow you, the user, to store strings and
  2234. manipulate them. These strings can be pieces of text, numbers (in text
  2235. form), or the logical values @b(TRUE) and @b(FALSE). These variables
  2236. can be combined, tested, inserted into buffers, and otherwise used to
  2237. control the way your macros execute. At the moment, up to 255 user
  2238. variables may be in use in one editing session. All users variable
  2239. names must begin with a percent sign (%) and may contain any printing
  2240. characters. Only the first 10 characters are significant (IE
  2241. differences beyond the tenth character are ignored). Most operators
  2242. will truncate strings to a length of 128 characters. 
  2243.  
  2244. @subsection(Buffer Variables)
  2245.  
  2246.     Buffer variables are special in that they can only be queried
  2247. and cannot be set. What buffer variables are is a way to take text from
  2248. a buffer and place it in a variable. For example, if I have a buffer by
  2249. the name of RIGEL2, and it contains the text:
  2250.  
  2251. @begin(verbatim)
  2252. @begin(group)
  2253.     Richmond
  2254.     Lafayette
  2255.     <*>Bloomington        (where <*> is the current point)
  2256.     Indianapolis
  2257.     Gary
  2258.     =* MicroEMACS 3.11 (WRAP) == rigel2 == File: /data/rigel2.txt =====
  2259. @end(group)
  2260. @end(verbatim)
  2261.  
  2262.     and within a command I reference #rigel2, like:
  2263.  
  2264.     insert-string #rigel2
  2265.  
  2266.     MicroEMACS would start at the current point in the RIGEL2
  2267. buffer and grab all the text up to the end of that line and pass that
  2268. back. Then it would advance the point to the beginning of the next line.
  2269. Thus, after our last command executes, the string "Bloomington" gets
  2270. inserted into the current buffer, and the buffer RIGEL2 now looks like
  2271. this:
  2272.  
  2273. @begin(verbatim)
  2274. @begin(group)
  2275.     Richmond
  2276.     Lafayette
  2277.     Bloomington
  2278.     <*>Indianapolis     (where <*> is the current point)
  2279.     Gary
  2280.     =* MicroEMACS 3.11 (WRAP) == rigel2 == File: /data/rigel2.txt =====
  2281. @end(group)
  2282. @end(verbatim)
  2283.  
  2284.     as you have probably noticed, a buffer variable consists of the
  2285. buffer name, preceded by a pound sign (#).
  2286.  
  2287. @subsection(Interactive variables)
  2288.  
  2289.     Interactive variables are actually a method to prompt the user
  2290. for a string. This is done by using an at sign (@@) followed either with
  2291. a quoted string, or a variable containing a string. The string is the
  2292. placed on the bottom line, and the editor waits for the user to type in
  2293. a string. Then the string typed in by the users is returned as the
  2294. value of the interactive variable. For example:
  2295.  
  2296. @begin(verbatim)
  2297.     set %quest "What file? "
  2298.     find-file @@%quest
  2299. @end(verbatim)
  2300.  
  2301.     will ask the user for a file name, and then attempt to find it.
  2302. Note also that complex expressions can be built up with these
  2303. operators, such as:
  2304.  
  2305. @verbatim(@@&cat &cat "File to decode[" %default "]: ")
  2306.  
  2307.     which prompts the user with the concatenated string.
  2308.  
  2309. @section(Functions)
  2310.  
  2311.     Functions can be used to manipulate variables in various ways. 
  2312. Functions can have one, two, or three arguments. These arguments will
  2313. always be placed after the function on the current command line. For
  2314. example, if we wanted to increase the current fill column by two, using
  2315. emacs's set (^XA) command, we would write:
  2316.  
  2317. @begin(group)
  2318. @begin(verbatim)
  2319.     set $fillcol &add $fillcol 2
  2320.      \    \      \      \     \____second operand
  2321.       \     \    \      \_________first operand
  2322.        \      \     \_______________function to execute
  2323.         \       \_____________________variable to set
  2324.          \___________________________set (^XA) command
  2325. @end(verbatim)
  2326. @end(group)
  2327.  
  2328.     Function names always begin with the ampersand (&) character,
  2329. and are only significant to the first three characters after the
  2330. ampersand. Functions will normal expect one of three types of
  2331. arguments, and will automatically convert types when needed.
  2332.  
  2333. @begin(description)
  2334. <num>@\an ascii string of digits which is interpreted as a numeric value. 
  2335. Any string which does not start with a digit or a minus sign (-) will be
  2336.  
  2337. considered zero. 
  2338.  
  2339. <str>@\An arbitrary string of characters. At the moment, strings are
  2340. limited to 128 characters in length. 
  2341.  
  2342. <log>@\A logical value consisting of the string "TRUE" or "FALSE". 
  2343. Numeric strings will also evaluate to "FALSE" if they are equal to zero,
  2344. and "TRUE" if they are non-zero. Arbitrary text strings will have the
  2345. value of "FALSE". 
  2346. @end(description)
  2347.  
  2348.     A list of the currently available functions follows: (Once
  2349. again, send in those votes on what kind of functions you would like to
  2350. see added!) Functions are always used in lower case, the uppercase
  2351. letters in the function table are the short form of the function (IE
  2352. &div for ÷).
  2353.  
  2354. @begin(verbatim)
  2355. Numeric Functions:    (returns <num>)
  2356.  
  2357. &ADD        <num> <num>    Add two numbers
  2358. &SUB        <num> <num>    Subtract the second number from the first
  2359. &TIMes        <num> <num>    Multiply two numbers
  2360. &DIVide     <num> <num>    Divide the first number by the second
  2361.                 giving an integer result
  2362. &MOD        <num> <num>    Return the reminder of dividing the
  2363.                 first number by the second
  2364. &NEGate     <neg>        Multiply the arg by -1
  2365. &LENgth     <str>        Returns length of string
  2366. &SINdex     <str1> <str2>    Finds the position of <str2> within
  2367.                 <str1>. Returns zero if not found.
  2368. &ASCii        <str>        Return the ascii code of the first
  2369.                 character in <str>
  2370. &RND        <num>        Returns a random integer between 1 and <num>
  2371. &ABS        <num>        Returns the absolute value of <num>
  2372. &BANd        <num> <num>    Bitwise AND function
  2373. &BOR        <num> <num>    Bitwise OR function
  2374. &BXOr        <num> <num>    Bitwise XOR function
  2375. &BNOt        <num>        Bitwise NOT function
  2376.  
  2377. String manipulation functions:    (returns <str>)
  2378.  
  2379. &CAT        <str> <str>    Concatenate the two strings to form one
  2380. &LEFt        <str> <num>    return the <num> leftmost characters
  2381.                 from <str>
  2382. &RIGht        <str> <num>    return the <num> rightmost characters
  2383.                 from <str>
  2384. &MID        <str> <num1> <num2>
  2385.                 Starting from <num1> position in <str>,
  2386.                 return <num2> characters.
  2387. &UPPer        <str>        Uppercase <str>
  2388. &LOWer        <str>        lowercase <str>
  2389. &CHR        <num>        return a string with the character
  2390.                 represented by ascii code <num>
  2391. >C                returns a string of characters
  2392.                 containing a EMACS command input from
  2393.                 the user
  2394. >K                return a string containing a single
  2395.                 keystroke from the user
  2396. &ENV        <str>        If the operating system is capable, this
  2397.                 returns the environment string associated
  2398.                 with <str>
  2399. &BIND        <str>        return the function name bound to the
  2400.                 keystroke <str>
  2401. &XLATE        <str1> <str2> <str3>
  2402. &FINd        <str>        Find the named file <str> along the
  2403.                 path and return its full file specification
  2404.                 or an empty string if none exists
  2405. &TRIM        <str>        Trim the trailing whitespace from a string
  2406.  
  2407. Logical Testing functions:    (returns <log>)
  2408.  
  2409. &NOT        <log>        Return the opposite logical value
  2410. &AND        <log1> <log2>    Returns TRUE if BOTH logical arguments
  2411.                 are TRUE
  2412. &OR        <log1> <log2>    Returns TRUE if either argument
  2413.                 is TRUE
  2414. &EQUal        <num> <num>    If <num> and <num> are numerically
  2415.                 equal, return TRUE
  2416. &LESs        <num1> <num2>    If <num1> is less than <num2>, return
  2417.                 TRUE.
  2418. &GREater    <num1> <num2>    If <num1> is greater than, or equal to
  2419.                 <num2>, return TRUE.
  2420. &SEQual     <str1> <str2>    If the two strings are the same, return
  2421.                 TRUE.
  2422. &SLEss        <str1> <str2>    If <str1> is less alphabetically than
  2423.                 <str2>, return TRUE.
  2424. &SGReater    <str1> <str2>    If <str1> is alphabetically greater than
  2425.                 or equal to <str2>, return TRUE.
  2426. &EXIst        <str>        Does the named file <str> exist?
  2427.  
  2428. Special Functions:
  2429.  
  2430. &INDirect    <str>        Evaluate <str> as a variable.
  2431. @end(verbatim)
  2432.  
  2433.     This last function deserves more explanation. The &IND function
  2434. evaluates its argument, takes the resulting string, and then uses it as
  2435. a variable name. For example, given the following code sequence:
  2436.  
  2437. @begin(verbatim)
  2438.     ; set up reference table
  2439.  
  2440.     set %one    "elephant"
  2441.     set %two    "giraffe"
  2442.     set %three    "donkey"
  2443.  
  2444.     set %index "two"
  2445.     insert-string &ind %index
  2446. @end(verbatim)
  2447.  
  2448.     the string "giraffe" would have been inserted at the point in
  2449. the current buffer. This indirection can be safely nested up to about
  2450. 10 levels.
  2451.  
  2452. @section(Directives)
  2453.  
  2454.     Directives are commands which only operate within an executing
  2455. macro, IE they do not make sense as a single command. As such, they
  2456. cannot be called up singly or bound to keystroke. Used within macros,
  2457. they control what lines are executed and in what order.
  2458.  
  2459.     Directives always start with the exclamation mark (!) character
  2460. and must be the first thing placed on a line. Directives executed
  2461. interactively (via the execute-command-line command) will be ignored. 
  2462.  
  2463. @subsection(!ENDM Directive)
  2464.  
  2465.     This directive is used to terminate a macro being stored. For
  2466. example, if a file is being executed contains the text:
  2467.  
  2468. @begin(verbatim)
  2469.     ;    Read in a file in view mode, and make the window red
  2470.  
  2471.     26    store-macro
  2472.         find-file @@"File to view: "
  2473.         add-mode "view"
  2474.         add-mode "red"
  2475.     !endm
  2476.  
  2477.     write-message "[Consult macro has been loaded]"
  2478. @end(verbatim)
  2479.  
  2480.     only the lines between the store-macro command and the !ENDM
  2481. directive are stored in macro 26. Both numbered macroes and named
  2482. procedures (via the @i(store-procedure) command) should be terminated with
  2483. this directive.
  2484.  
  2485. @subsection(!FORCE Directive)
  2486.  
  2487.     When MicroEMACS executes a macro, if any command fails, the
  2488. macro is terminated at that point. If a line is preceded by a !FORCE
  2489. directive, execution continues whether the command succeeds or not. For
  2490. example:
  2491.  
  2492. @begin(verbatim)
  2493.     ;    Merge the top two windows
  2494.  
  2495.     save-window        ;remember what window we are at
  2496.     1 next-window        ;go to the top window
  2497.     delete-window        ;merge it with the second window
  2498.     !force restore-window    ;This will continue regardless
  2499.     add-mode "red"
  2500. @end(verbatim)
  2501.  
  2502. @subsection(!IF, !ELSE, and !ENDIF Directives)
  2503.  
  2504.     This directive allows statements only to be executed if a
  2505. condition specified in the directive is met. Every line following the
  2506. !IF directive, until the first !ELSE or !ENDIF directive, is only
  2507. executed if the expression following the !IF directive evaluates to a
  2508. TRUE value. For example, the following macro segment creates the
  2509. portion of a text file automatically. (yes believe me, this will be
  2510. easier to understand then that last explanation....)
  2511.  
  2512. @begin(verbatim)
  2513.     !if &sequal %curplace "timespace vortex"
  2514.         insert-string "First, rematerialize~n"
  2515.     !endif
  2516.     !if &sequal %planet "earth"    ;If we have landed on earth...
  2517.         !if &sequal %time "late 20th century"  ;and we are then
  2518.             write-message "Contact U.N.I.T."
  2519.         !else
  2520.             insert-string "Investigate the situation....~n"
  2521.             insert-string "(SAY 'stay here Sara')~n"
  2522.         !endif
  2523.     !else
  2524.         set %conditions @@"Atmosphere conditions outside? "
  2525.         !if &sequal %conditions "safe"
  2526.             insert-string &cat "Go outside......" "~n"
  2527.             insert-string "lock the door~n"
  2528.         !else
  2529.             insert-string "Dematerialize..try somewhen else"
  2530.             newline
  2531.         !endif
  2532.     !endif
  2533. @end(verbatim)
  2534.  
  2535. @subsection(!GOTO Directive)
  2536.  
  2537.     Flow can be controlled within a MicroEMACS macro using the !GOTO
  2538. directive. It takes as an argument a label. A label consists of a line
  2539. starting with an asterisk (*) and then an alphanumeric label. Only
  2540. labels in the currently executing macro can be jumped to, and trying to
  2541. jump to a non-existing label terminates execution of a macro. For
  2542. example..
  2543.  
  2544. @begin(verbatim)
  2545.     ;Create a block of DATA statements for a BASIC program
  2546.  
  2547.         insert-string "1000 DATA "
  2548.         set %linenum 1000
  2549.  
  2550.     *nxtin
  2551.         update-screen        ;make sure we see the changes
  2552.         set %data @@"Next number: "
  2553.         !if &equal %data 0
  2554.             !goto finish
  2555.         !endif
  2556.  
  2557.         !if &greater $curcol 60
  2558.             2 delete-previous-character
  2559.             newline
  2560.             set %linenum &add %linenum 10
  2561.             insert-string &cat %linenum " DATA "
  2562.         !endif
  2563.  
  2564.         insert-string &cat %data ", "
  2565.         !goto nxtin
  2566.  
  2567.     *finish
  2568.  
  2569.         2 delete-previous-character
  2570.         newline
  2571. @end(verbatim)
  2572.  
  2573. @subsection(!WHILE and !ENDWHILE Directives)
  2574.  
  2575.     This directive allows you to set up repetitive tasks easily and
  2576. efficiently. If a group of statements need to be executed while a
  2577. certain condition is true, enclose them with a while loop. For example,
  2578.  
  2579. @begin(verbatim)
  2580.     !while &less $curcol 70
  2581.         insert-string &cat &cat "[" #stuff "]"
  2582.     !endwhile
  2583. @end(verbatim)
  2584.  
  2585.     places items from buffer "item" in the current line until the
  2586. cursor is at or past column 70. While loops may be nested and can
  2587. contain and be the targets of !GOTOs with no ill effects. Using a while
  2588. loop to enclose a repeated task will run much faster than the
  2589. corresponding construct using !IFs.
  2590.  
  2591. @subsection(!BREAK Directive)
  2592.  
  2593.     This directive allows the user to abort out of the currently
  2594. most inner while loop, regardless of the condition. It is often used
  2595. to abort processing for error conditions. For example:
  2596.  
  2597. @begin(verbatim)
  2598. ;    Read in files and substitute "begining" with "beginning"
  2599.  
  2600.     set %filename #list
  2601.     !while ¬ &seq %filename "<end>"
  2602. !force        find-file %filename
  2603.         !if &seq $status FALSE
  2604.             write-message "[File read error]"
  2605.             !break
  2606.         !endif
  2607.         beginning-of-file
  2608.         replace-string "begining" "beginning"
  2609.         save-file
  2610.         set %filename #list
  2611.     !endwhile
  2612. @end(verbatim)
  2613.  
  2614.     This while loop will process files until the list is exhausted
  2615. or there is an error while reading a file.
  2616.  
  2617. @subsection(!RETURN Directive)
  2618.  
  2619.     The !RETURN Directive causes the current macro to exit, either
  2620. returning to the caller (if any) or to interactive mode. For example:
  2621.  
  2622. @begin(verbatim)
  2623.     ;    Check the monitor type and set %mtyp
  2624.  
  2625.     !if &sres "CGA"
  2626.         set %mtyp 1
  2627.         !return
  2628.     !else
  2629.         set %mtyp 2
  2630.     !endif
  2631.  
  2632.     insert-string "You are on a MONOCHROME machine!~n"
  2633. @end(verbatim)
  2634. @chapter(Debugging MicroEMACS macroes)
  2635.  
  2636.     @index(debugging)@index($debug)When developing new macroes, it
  2637. is very convenient to be able to trace their execution to find errors. 
  2638. The $debug environment variable enables macro debugging. While this
  2639. variable is TRUE, emacs will stop at each macro line it intends to
  2640. execute and allow you to view it, and issue a number of different
  2641. commands to help determine how the macro is executing.
  2642.  
  2643.     For example, we will step through the macro which toggles the
  2644. function key window off. The first thing to do, is to set $debug, using
  2645. the @b(^XA) @i(set) command. Type ^XA and emacs will prompt you on the
  2646. command line with "Variable to set: ".    Type in "$debug" and press the
  2647. enter key. Emacs will then ask "Value: ". Type in "TRUE" (in capital
  2648. letters) and press the enter key.
  2649.  
  2650.     While macro debugging is enabled (as it is now) emacs will
  2651. report each time a variable is assigned a value, by displaying the
  2652. variable and its value on the command line. Right now,
  2653.  
  2654. @flushleft{((($debug <- TRUE)))}
  2655.  
  2656.     appears on the command line to tell you that $debug now has been
  2657. assigned the value of TRUE. Press the space bar to continue.
  2658.  
  2659.     Now, lets try to debug a macro. Press function key 5 which
  2660. normally toggles the function key window. The first thing that appears
  2661. is:
  2662.  
  2663. @flushleft{<<<[Macro 01]:!if %rcfkeys>>>}
  2664.  
  2665.     At this point, emacs is waiting for a command.    It is prepared
  2666. to see if the user variable %rcfkeys is TRUE, and execute some lines if
  2667. they are. Suppose we want to see the value of this variable, type the
  2668. letter "e" to evaluate an expression. Emacs will prompt with "EXP: ". 
  2669. Type "%rcfkeys" followed by the enter key. Emacs should then respond
  2670. with "TRUE" to indicate that the function key window is currently on
  2671. screen.
  2672.  
  2673.     Press the space bar to allow the !if directive to execute. 
  2674. Emacs will decide that it is TRUE, and then display the next macro
  2675. command to execute.
  2676.  
  2677. @flushleft{<<<[Macro 01]:!goto rcfoff>>>}
  2678.  
  2679.     Notice emacs tells us what macro we are currently executing (in
  2680. this case, the macro bound to execute-macro-1). Press the space bar
  2681. again to execute the !goto directive.
  2682.  
  2683. @flushleft{<<<[Macro 01]:save-window>>>}
  2684.  
  2685.     Emacs is saving the position of the current window so that it
  2686. can attempt to return to it after it has brought up the function key window.
  2687.  
  2688. [...THIS CHAPTER IS NOT FINISHED...]
  2689. @chapter(Key Bindings, What they are and why)
  2690.  
  2691.     One of the features which makes MicroEMACS very adaptable is its
  2692. ability to use different keystrokes to execute different commands. The
  2693. process of changing the particular command a key invokes is called
  2694. @i(rebinding)@index(rebinding). This allows us to make the editor
  2695. look like other popular editors and programs.
  2696.  
  2697.     Each command in MicroEMACS has a name which is used for binding
  2698. purposes. For example, the command to move the cursor down one page is
  2699. called @i(next-line) and is normally bound to the ^N key. If you
  2700. decided that you also wanted to use the ^D key to move the cursor down
  2701. one line, you would use the M-K @i(bind-to-key)@index(bind-to-key)
  2702. command. EMACS would respond with ": bind-to-key " on the command line
  2703. and allow you to type in a command name. Then type in the name of the
  2704. command  you want to change, in this case @i(next-line),
  2705. followed by the <NL> key. EMACS will then wait for you to type in the
  2706. keys you want to activate the named function. Type a single ^D. From
  2707. now on, typing ^D will cause EMACS to move down one line, rather than
  2708. its original function of deleting characters.
  2709.  
  2710.     To find out the name of a command, consult the list of
  2711. valid EMACS commands in Appendix B. Also, you can use the ^X?
  2712. @i(describe-key)@index(describe-key) command to look up the name of a
  2713. command. Type ^X? and then the key to use that command, and EMACS will
  2714. show you the name of the command.
  2715.  
  2716.     After you have experimented with changing your key bindings, you
  2717. may decide that you want to change some bindings permanently. To have
  2718. EMACS rebind keys to your pleasure each time you start EMACS, you can
  2719. add statements to the end of your startup file (@b(emacs.rc) or
  2720. @b(.emacsrc) depending on the system).    For example,
  2721.  
  2722. bind-to-key next-line ^D
  2723.  
  2724.     Notice, that control D character in the startup file is
  2725. represented visibly as an uparrow key followed by a capital D.    To know
  2726. how to represent any keys you want to bind, use the @i(describe-key)
  2727. command on the key, and use the sequence that is displayed.
  2728.  
  2729. bind-to-key split-current-window FN1
  2730.  
  2731.     This example would make function key 1 activate the command
  2732. that splits the current window in two. 
  2733.  
  2734.     EMACS will let you define a large number of keys, but will report 
  2735. "Binding table FULL!" when it runs out of space to bind keys. Normally 
  2736. EMACS will allow up to 512 key bindings (including approx. 300 originally 
  2737. bound keys).
  2738.  
  2739.     If you want to get a current listing of all the commands and
  2740. the keys bound to them, use the @i(describe-bindings)
  2741. @index(describe-bindings) command. Notice, that this command is not
  2742. bound to any keys!
  2743.  
  2744. @appendix(MicroEMACS Command Line Switches and Startup Files)
  2745.  
  2746. @index(startup files)
  2747.     When EMACS first executes, it always searches for a file,
  2748. called @b(.emacsrc) @i(under most UNIX systems) or @b(emacs.rc) @i(on
  2749. most other systems) @index(emacs.rc) @index(.emacsrc) which it will
  2750. execute as EMACS macros before it reads in the named source files. This
  2751. file normally contains EMACS macroes to bind the function keys to
  2752. useful functions and load various useful macros. The contents of this
  2753. file will probably vary from system to system and can be modified by the
  2754. user as desired.
  2755.  
  2756.     When searching for this file, EMACS looks for it in this order. 
  2757. First, it attempts to find a definition for "@b(HOME)" in the
  2758. environment. It will look in that directory first. Then it searches
  2759. all the directories listed in the "@b(PATH)" environment variable. Then
  2760. it looks through a list of predefined standard directories which vary
  2761. from system to system.    Finally, failing all of these, it looks in the
  2762. current directory. This is also the same method EMACS uses to look up
  2763. any files to execute, and to find it's help file @b(EMACS.HLP). 
  2764. @index(PATH environment variable) @index(HOME environment variable)
  2765. @index(Help File)
  2766.  
  2767. @index(switches)
  2768.     On computers that call up EMACS via a command line process, such
  2769. as MSDOS and UNIX, there are different things that can be added to the
  2770. command line to control the way EMACS operates. These can be switches,
  2771. which are a dash ('-') followed by a letter, and possible other
  2772. parameters, or a startup file specifier, which is an at sign '@@'
  2773. followed by a file name.
  2774.  
  2775. @begin(description)
  2776. @@<file>@\This causes the named file to be executed instead of the
  2777. standard emacs.rc file before emacs reads in any other files. More than
  2778. one of these can be placed on the command line, and they will be
  2779. executed in the order that they appear. 
  2780.  
  2781. -C@\The following source files on the command line can be changed (as
  2782. opposed to being in VIEW mode). This is mainly used to cancel the
  2783. effects of the -v switch used previously in the same command line.
  2784.  
  2785. -E@\This flag causes emacs to automatically run the startup file
  2786. "error.cmd" instead of emacs.rc. This is used by various C compilers for
  2787. error processing (for example, Mark Williams C). @index(error parsing)
  2788.  
  2789. -G<num>@\Upon entering EMACS, position the cursor at the <num> line of
  2790. the first file.
  2791.  
  2792. -I<var> <value>@\Initialize an EMACS variable with <value>. This can be
  2793. useful to force EMACS to start in a particular mode. (For example,
  2794. invoke EMACS with "emacs -i$sres VGA foo.bar" to edit file foo.bar
  2795. in VGA 50 line mode on an IBM-PC).
  2796.  
  2797. -K<key>@\This key tells emacs to place the source files in CRYPT
  2798. @index(CRYPT mode) mode and read it in using <key> as the encryption
  2799. key. If no key is listed immediately after the -K switch, EMACS will
  2800. prompt for a key, and not echo it as it is typed. 
  2801.  
  2802. -R@\This places EMACS in "restricted mode"@index(restricted mode)
  2803. @index(BBS) where any commands allowing the user to read or write any
  2804. files other than the ones listed on the command line are disabled. Also
  2805. all commands allowing the user access to the operating system are
  2806. disabled. This makes EMACS very useful as a "safe" environment for use
  2807. within other applications and especially used as a remote editor for a
  2808. BBS or electronic bulletin board system.
  2809.  
  2810. -S<string>@\After EMACS is started, it automatically searches for
  2811. <string> in the first source file.
  2812.  
  2813. -V@\This tells EMACS that all the following sources files on the command
  2814. line should be in VIEW mode to prevent any changes being made to them.
  2815. @end(description)
  2816. @appendix(Command Completion)
  2817.  
  2818.     Some versions of MicroEMACS will allow you to abbrieviate buffer
  2819. names, command names and file names as you enter them. To use this,
  2820. type in the first few characters of the name you wish, and then hit
  2821. either the space bar, the META key or the TAB key. MicroEMACS will then
  2822. attempt to look at the list of all the availible names and if there is
  2823. only one which will fit, it will choose that name. If there are several
  2824. names that quailify, as many characters as are common to ALL of them
  2825. will be entered. If there are no possible matches, the bell will ring
  2826. to indicate MicroEMACS can not complete the command.
  2827.  
  2828.     For example, if you have several files in your current directory
  2829. with the following names:
  2830.  
  2831. @begin(verbatim)
  2832.     prog1.c
  2833.     prog1.obj
  2834.     prog1.exe
  2835.     prog1.doc
  2836.     program.one
  2837.     project.one
  2838.     test.c
  2839.     tes
  2840. @end(verbatim)
  2841.  
  2842.     and you enter the @b(^X^F) @i(find-file) command, if you type
  2843. 'p' and then hit the space bar, EMACS will respond by typing the 'r'
  2844. that is common to all the above file names begining with 'p'. If you
  2845. then type 'ogr' and hit the tab key, EMACS will respond with 'am.one'
  2846. and automatically hit the enter key for you.
  2847.  
  2848.     If you were to instead type an 'a' and hit the space bar, EMACS
  2849. will beep, informing you that there is no possible match.
  2850.  
  2851.     If you type a 'te' and hit the space bar, EMACS will then type
  2852. the following 's', but it will not automatically enter it because it is
  2853. possible you mean to get to the test.c file.
  2854.  
  2855.     Buffer name, and command name completion is available in all
  2856. versions of MicroEMACS. File name completion is available on UNIX
  2857. BSD4.3, the Atari ST, the AMIGA and under MSDOS.
  2858. @appendix(MicroEMACS commands)
  2859.  
  2860.     Below is a complete list of the commands in EMACS, the keys
  2861. normally used to do the command, and what the command does. Remember,
  2862. on some computers there may also be additional ways of using a command
  2863. (cursor keys and special function keys for example). 
  2864.  
  2865. @begin(verbatim)
  2866. @u(Command            Binding     Meaning)
  2867.  
  2868. abort-command            ^G     This allows the user to abort out of
  2869.                 any command that is waiting for input
  2870.  
  2871. add-global-mode          M-M    Add a global mode for all new buffers
  2872.  
  2873. add-mode                 ^XM    Add a mode to the current buffer
  2874.  
  2875. append-file        ^X^A    Append a file to the end of another file
  2876.  
  2877. apropos                  M-A    List out commands whose name contains
  2878.                 the string specified
  2879.  
  2880. backward-character       ^B     Move one character to the left
  2881.  
  2882. begin-macro              ^X(    Begin recording a keyboard macro
  2883.  
  2884. beginning-of-file        M-<    Move to the beginning of the file in
  2885.                 the current buffer
  2886.  
  2887. beginning-of-line        ^A     Move to the beginning of the current line
  2888.  
  2889. bind-to-key              M-K    Bind a key to a function
  2890.  
  2891. buffer-position          ^X=    List the position of the cursor in the
  2892.                 current window on the command line
  2893.  
  2894. case-region-lower        ^X^L   Make a marked region all lower case
  2895.  
  2896. case-region-upper        ^X^U   Make a marked region all upper case
  2897.  
  2898. case-word-capitalize     M-C    Capitalize the following word
  2899.  
  2900. case-word-lower          M-L    Lower case the following word
  2901.  
  2902. case-word-upper          M-U    Upper case the following word
  2903.  
  2904. change-file-name         ^XN    Change the name of the file in the
  2905.                 current buffer
  2906.  
  2907. change-screen-size      (none)  Change the number of lines of the
  2908.                 screen currently being used
  2909.  
  2910. change-screen-width     (none)  Change the number of columns of the
  2911.                 screen currently being used
  2912.  
  2913. clear-and-redraw         ^L     Clear the physical screen and redraw it
  2914.  
  2915. clear-message-line      (none)  Clear the command line
  2916.  
  2917. copy-region              M-W    Copy the currently marked region into
  2918.                 the kill buffer
  2919.  
  2920. count-words              M-^C   Count how many words, lines and
  2921.                 characters are in the current marked region
  2922.  
  2923. ctlx-prefix              ^X     Change the key used as the ^X prefix
  2924.  
  2925. delete-blank-lines       ^X^O   Delete all blank lines around the cursor
  2926.  
  2927. delete-buffer            ^XK    Delete a buffer which is not being
  2928.                 currently displayed in a window
  2929.  
  2930. delete-global-mode       M-^M   Turn off a global mode
  2931.  
  2932. delete-mode              ^X^M   Turn off a mode in the current buffer
  2933.  
  2934. delete-next-character    ^D     Delete the character following the cursor
  2935.  
  2936. delete-next-word         M-D    Delete the word following the cursor
  2937.  
  2938. delete-other-windows     ^X1    Make the current window cover the entire screen
  2939.  
  2940. delete-previous-character^H     Delete the character to the left of the cursor
  2941.  
  2942. delete-previous-word     M-^H   Delete the word to the left of the cursor
  2943.  
  2944. delete-screen         A-D    Delete a screen from memory
  2945.  
  2946. delete-window            ^X0    Remove the current window from the screen
  2947.  
  2948. describe-bindings       (none)  Make a list of all legal commands
  2949.  
  2950. describe-functions    (none)    Make a list of all legal functions
  2951.  
  2952. describe-key             ^X?    Describe what command is bound to a
  2953.                 keystroke sequence
  2954.  
  2955. describe-variables    (none)    Make a list of all existing variables
  2956.  
  2957. detab-region             ^X^D   Change all tabs in a region to the
  2958.                 equivalent spaces
  2959.  
  2960. display                 ^XG     Prompts the user for a variable and
  2961.                 displays its current value
  2962.  
  2963. end-macro                ^X)    stop recording a keyboard macro
  2964.  
  2965. end-of-file              M->    Move cursor to the end of the current buffer
  2966.  
  2967. end-of-line              ^E     Move to the end of the current line
  2968.  
  2969. end-of-word        FN^F    Move to the beginning of the next word
  2970.  
  2971. entab-region             ^X^E   Change multiple spaces to tabs where possible
  2972.  
  2973. exchange-point-and-mark  ^X^X   Move cursor to the last marked spot,
  2974.                 make the original position be marked
  2975.  
  2976. execute-buffer          (none)  Execute a buffer as a macro
  2977.  
  2978. execute-command-line    (none)  Execute a line typed on the command
  2979.                 line as a macro command
  2980.  
  2981. execute-file            (none)  Execute a file as a macro
  2982.  
  2983. execute-macro            ^XE    Execute the keyboard macro (play back
  2984.                 the recorded keystrokes)
  2985.  
  2986. execute-macro-<n>       (none)  Execute numbered macro <N> where <N> is
  2987.                 an integer from 1 to 40
  2988.  
  2989. execute-named-command    M-X    Execute a command by name
  2990.  
  2991. execute-procedure        M-^E   Execute a procedure by name
  2992.  
  2993. execute-program         ^X$     Execute a program directly (not through
  2994.                 an intervening shell)
  2995.  
  2996. exit-emacs               ^X^C   Exit EMACS. If there are unwritten,
  2997.                 changed buffers EMACS will ask to confirm
  2998.  
  2999. fill-paragraph           M-Q    Fill the current paragraph
  3000.  
  3001. filter-buffer            ^X#    Filter the current buffer through an
  3002.                 external filter
  3003.  
  3004. find-file                ^X^F   Find a file to edit in the current window
  3005.  
  3006. find-screen        A-F    Find or create a new screen
  3007.  
  3008. forward-character        ^F     Move cursor one character to the right
  3009.  
  3010. goto-line                M-G    Goto a numbered line
  3011.  
  3012. goto-mark         M-^G    Goto a numbered mark
  3013.  
  3014. goto-matching-fence      M-^F   Goto the matching fence
  3015.  
  3016. grow-window              ^X^    Make the current window larger
  3017.  
  3018. handle-tab               ^I     Insert a tab or set tab stops
  3019.  
  3020. help                     M-?    Read EMACS.HLP into a buffer and display it
  3021.  
  3022. hunt-backward            A-R    Hunt for the last match of the last
  3023.                 search string
  3024.  
  3025. hunt-forward             A-S    Hunt for the next match of the last
  3026.                 search string
  3027.  
  3028. i-shell                  ^XC    Shell up to a new command processor
  3029.  
  3030. incremental-search       ^XS    Search for a string, incrementally
  3031.  
  3032. indent-region         M-)    Indent all text in a region by a tab stop
  3033.  
  3034. insert-file              ^X^I   insert a file at the cursor in the current file
  3035.  
  3036. insert-space             ^C     Insert a space to the right of the cursor
  3037.  
  3038. insert-string           (none)  Insert a string at the cursor
  3039.  
  3040. kill-paragraph           M-^W   Delete the current paragraph
  3041.  
  3042. kill-region              ^W     Delete the current marked region,
  3043.                 moving it to the kill buffer
  3044.  
  3045. kill-to-end-of-line      ^K     Delete the rest of the current line
  3046.  
  3047. label-function-key    (none)    Set the contents of a function key
  3048.                 label (only on some hardware)
  3049.  
  3050. list-buffers             ^X^B   List all existing buffers
  3051.  
  3052. list-screens         A-B    List all existing screens
  3053.  
  3054. macro-to-key        (none)    Bind a macro to a key
  3055.  
  3056. meta-prefix              <ESC>  Key used to precede all META commands
  3057.  
  3058. mouse-move-down          MSa
  3059.  
  3060. mouse-move-up            MSb
  3061.  
  3062. mouse-region-down        MSe
  3063.  
  3064. mouse-region-up          MSf
  3065.  
  3066. mouse-resize-screen      MS1
  3067.  
  3068. move-window-down         ^X^N   Move all the lines in the current window down
  3069.  
  3070. move-window-up           ^X^P   Move all the lines in the current window up
  3071.  
  3072. name-buffer              M-^N   Change the name of the current buffer
  3073.  
  3074. narrow-to-region         ^X<    hides all text not in the current region
  3075.  
  3076. newline                  ^M     Insert a <NL> at the cursor
  3077.  
  3078. newline-and-indent       ^J     Insert a <NL> at the cursor and indent
  3079.                 the new line the same as the preceding line
  3080.  
  3081. next-buffer              ^XX    Bring the next buffer in the list into
  3082.                 the current window
  3083.  
  3084. next-line                ^N     Move the cursor down one line
  3085.  
  3086. next-page                ^V     Move the cursor down one page
  3087.  
  3088. next-paragraph           M-N    Move cursor to the next paragraph
  3089.  
  3090. next-screen         A-N    Skip to the next existing screen
  3091.  
  3092. next-window              ^XO    Move cursor to the next window
  3093.  
  3094. next-word                M-F    Move cursor to the beginning of the next word
  3095.  
  3096. nop                     (none)  Does nothing
  3097.  
  3098. open-line                ^O     Open a line at the cursor
  3099.  
  3100. overwrite-string        (none)  Overwrite a string at the cursor
  3101.  
  3102. pipe-command             ^X@@   Execute an external command and place
  3103.                 its output in a buffer
  3104.  
  3105. pop-buffer        (none)    Pop up a buffer
  3106.  
  3107. previous-line            ^P     Move cursor up one line
  3108.  
  3109. previous-page            ^Z     Move cursor up one page
  3110.  
  3111. previous-paragraph       M-P    Move back one paragraph
  3112.  
  3113. previous-screen         A-P    Move to last existing screen
  3114.  
  3115. previous-window          ^XP    Move the cursor to the last window
  3116.  
  3117. previous-word            M-B    Move the cursor to the beginning of the
  3118.                 word to the left of the cursor
  3119.  
  3120. print                   (none)  Display a string on the command line (a
  3121.                 synonim to write-message)
  3122.  
  3123. query-replace-string     M-^R   Replace all of one string with another
  3124.                 string, interactively querying the user
  3125.  
  3126. quick-exit               M-Z    Exit EMACS, writing out all changed buffers
  3127.  
  3128. quote-character          ^Q     Insert the next character literally
  3129.  
  3130. read-file                ^X^R   Read a file into the current buffer
  3131.  
  3132. redraw-display           M-^L   Redraw the display, centering the current line
  3133.  
  3134. remove-mark        (none)    Eliminate a mark
  3135.  
  3136. replace-string           M-R    Replace all occurrences of one string
  3137.                 with another string from the cursor to the end of the buffer
  3138.  
  3139. resize-window            ^XW    Change the number of lines in the
  3140.                 current window
  3141.  
  3142. restore-window          (none)  Move cursor to the last saved window
  3143.  
  3144. reverse-incremental-search^XR   Search backwards, incrementally
  3145.  
  3146. run                      M-^E   Execute a named procedure
  3147.  
  3148. save-file                ^X^S   Save the current buffer if it is changed
  3149.  
  3150. save-window             (none)  Remember current window (to restore later)
  3151.  
  3152. scroll-next-down         M-^V   Scroll the next window down
  3153.  
  3154. scroll-next-up           M-^Z   Scroll the next window up
  3155.  
  3156. search-forward           ^S     Search for a string
  3157.  
  3158. search-reverse           ^R     Search backwards for a string
  3159.  
  3160. select-buffer            ^XB    Select a buffer to display in the
  3161.                 current window
  3162.  
  3163. set                      ^XA    Set a variable to a value
  3164.  
  3165. set-encryption-key       M-E    Set the encryption key of the current buffer
  3166.  
  3167. set-fill-column          ^XF    Set the current fill column
  3168.  
  3169. set-mark                        Set the mark
  3170.  
  3171. shell-command            ^X!    Causes an external shell to execute a command
  3172.  
  3173. show-files        (none)    Pop-up a list of files
  3174.  
  3175. shrink-window            ^X^Z   Make the current window smaller
  3176.  
  3177. source                  (none)  Execute a file as a macro
  3178.  
  3179. split-current-window     ^X2    Split the current window in two
  3180.  
  3181. store-macro             (none)  Store the following macro lines to a
  3182.                 numbered macro
  3183.  
  3184. store-procedure         (none)  Store the following macro lines to a
  3185.                 named procedure
  3186.  
  3187. transpose-characters     ^T     Transpose the character at the cursor
  3188.                 with the character to the left
  3189.  
  3190. trim-region              ^X^T   Trim any trailing white space from a region
  3191.  
  3192. unbind-key               M-^K   Unbind a key from a function
  3193.  
  3194. undent-region         M-(    Remove one tab stop from region
  3195.  
  3196. universal-argument       ^U     Execute the following command 4 times
  3197.  
  3198. unmark-buffer            M-~    Unmark the current buffer (so it is no
  3199.                 longer changed)
  3200.  
  3201. update-screen           (none)  Force a screen update during macro execution
  3202.  
  3203. view-file                ^X^V   Find a file,and put it in view mode
  3204.  
  3205. widen-from-region        ^X>    restores hidden text (see narrow-to-region)
  3206.  
  3207. wrap-word               (none)  Wrap the current word, this is an
  3208.                 internal function
  3209.  
  3210. write-file               ^X^W   Write the current buffer under a new file name
  3211.  
  3212. write-message           (none)  Display a string on the command line
  3213.  
  3214. yank                     ^Y     Yank the kill buffer into the current
  3215.                 buffer at the cursor
  3216. @end(verbatim)
  3217. @appendix(MicroEMACS Bindings)
  3218.  
  3219.     Below is a complete list of the key bindings used in MicroEMACS.
  3220. This can be used as a wall chart reference for MicroEMACS commands.
  3221.  
  3222. @begin(verbatim)
  3223. @center(@b[Default Key Bindings for MicroEmacs 3.11])
  3224.  
  3225.  ^A   Move to start of line          ESC A   Apropos (list some commands)
  3226.  ^B   Move backward by characters     ESC B   Backup by words
  3227.  ^C   Insert space              ESC C   Initial capitalize word
  3228.  ^D   Forward delete              ESC D   Delete forward word
  3229.  ^E   Goto end of line              ESC E   Reset Encryption Key
  3230.  ^F   Move forward by characters      ESC F   Advance by words
  3231.  ^G   Abort out of things          ESC G   Go to a line
  3232.  ^H   Backward delete              
  3233.  ^I   Insert tab/Set tab stops
  3234.  ^J   Insert <NL>, then indent            
  3235.  ^K   Kill forward              ESC K   Bind Key to function
  3236.  ^L   Refresh the screen          ESC L   Lower case word
  3237.  ^M   Insert <NL>              ESC M   Add global mode
  3238.  ^N   Move forward by lines          ESC N   Goto End paragraph
  3239.  ^O   Open up a blank line          
  3240.  ^P   Move backward by lines          ESC P   Goto Begining of paragraph
  3241.  ^Q   Insert literal              ESC Q   Fill current paragraph
  3242.  ^R   Search backwards              ESC R   Search and replace
  3243.  ^S   Search forward              ESC S   Suspend (BSD only)
  3244.  ^T   Transpose characters               
  3245.  ^U   Repeat command four times       ESC U   Upper case word
  3246.  ^V   Move forward by pages          ESC V   Move backward by pages
  3247.  ^W   Kill region              ESC W   Copy region to kill buffer
  3248.  ^Y   Yank back from killbuffer       ESC X   Execute named command
  3249.  ^Z   Move backward by pages          ESC Z   Save all buffers and exit
  3250.  
  3251.  ESC ^C   Count words in region       ESC ~   Unmark current buffer
  3252.  ESC ^E   Execute named procedure
  3253.  ESC ^F   Goto matching fence          ESC !   Reposition window
  3254.  ESC ^H   Delete backward word          ESC <   Move to start of buffer
  3255.  ESC ^K   Unbind Key from function    ESC >   Move to end of buffer
  3256.  ESC ^L   Reposition window          ESC .  Set mark
  3257.  ESC ^M   Delete global mode          ESC space    Set mark
  3258.  ESC ^N   Rename current buffer       ESC rubout   Delete backward word
  3259.  ESC ^R   Search & replace w/query      rubout   Backward delete
  3260.  ESC ^S   Source command file
  3261.  ESC ^V   Scroll next window down
  3262.  ESC ^W   Delete Paragraph
  3263.  ESC ^X   Execute command line
  3264.  ESC ^Z   Scroll next window up
  3265.  
  3266.  ^X <    Narrow-to-region       ^X ?   Describe a key
  3267.  ^X >    Widen-from-region       ^X !   Run 1 command in a shell
  3268.  ^X =    Show the cursor position   ^X @@   Pipe shell command to buffer
  3269.  ^X ^    Enlarge display window       ^X #   Filter buffer thru shell filter
  3270.  ^X 0    Delete current window       ^X $   Execute an external program
  3271.  ^X 1    Delete other windows       ^X (   Begin macro
  3272.  ^X 2    Split current window       ^X )   End macro
  3273.                    ^X A   Set variable value
  3274.  ^X ^B     Display buffer list       ^X B   Switch a window to a buffer
  3275.  ^X ^C     Exit MicroEMACS       ^X C   Start a new command processor
  3276.  ^X ^D     Detab line           ^X D   Suspend MicroEMACS (BSD4.2 only)
  3277.  ^X ^E     Entab line           ^X E   Execute macro
  3278.  ^X ^F     Find file           ^X F   Set fill column
  3279.  ^X ^I     Insert file
  3280.                    ^X K   Delete buffer
  3281.  ^X ^L     Lower case region
  3282.  ^X ^M     Delete Mode           ^X M   Add a mode
  3283.  ^X ^N     Move window down       ^X N   Rename current filename
  3284.  ^X ^O     Delete blank lines       ^X O   Move to the next window
  3285.  ^X ^P     Move window up        ^X P   Move to the previous window
  3286.  ^X ^R     Get a file from disk       ^X R   Incremental reverse search
  3287.  ^X ^S     Save current file       ^X S   Incremental forward search
  3288.  ^X ^T     Trim line           (Incremental search
  3289.  ^X ^U     Upper case region          not always available)
  3290.  ^X ^V     View file
  3291.  ^X ^W     Write a file to disk       ^X W   resize Window
  3292.  ^X ^X     Swap "." and mark       ^X X   Use next buffer
  3293.  ^X ^Z     Shrink window           ^X Z   Enlarge display window
  3294.  
  3295. @u(Usable Modes)
  3296. WRAP     Lines going past right margin "wrap" to a new line
  3297. VIEW     Read-Only mode where no modifications are allowed
  3298. CMODE     Change behavior of some commands to work better with C
  3299. EXACT     Exact case matching on search strings
  3300. OVER     Overwrite typed characters instead of inserting them
  3301. CRYPT     Current buffer will be encrypted on write, decrypted on read
  3302. MAGIC     Use regular expression matching in searches
  3303. ASAVE     Save the file every 256 inserted characters
  3304.  
  3305. WHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK    Sets foreground color
  3306. white/cyan/magenta/yellow/blue/red/green/black    Sets background color
  3307. @end(verbatim)
  3308. @newpage
  3309. @appendix(Supported machines)
  3310.  
  3311.     The following table lists all the hardware/compilers for which I
  3312. currently support MicroEMACS. This is not exclusive of all machines
  3313. which MicroEMACS will run on, but I have either run it myself, or had a
  3314. first hand report of it running.
  3315.  
  3316. @begin(verbatim)
  3317. @u(Hardware    OS        Compiler    Comments)
  3318. VAX 780     UNIX V5     native
  3319.         UNIX V7     native
  3320.         BSD 4.2     native        job control supported
  3321.         VMS        native        SMG & ANSI support
  3322.  
  3323. SUN        SUNOS 3 & 4    native
  3324.                 gcc
  3325.  
  3326. NCR Tower    UNIX V5     native
  3327.  
  3328. IBM-RT PC    BSD 4.3     native
  3329.         AIX        native
  3330.  
  3331. HP9000        UNIX V5     native
  3332.  
  3333. Fortune 32:16    UNIX V7     native
  3334.  
  3335. IBM-PC        MSDOS        LATTICE 3    Large CODE/Large DATA
  3336.          2.0 & 3.2    AZTEC 3.4e    Large CODE/Large DATA
  3337.                 TURBO C v2.0    LARGE memory model
  3338.                 MSC 6.0
  3339.                 *MWC 86
  3340.         SCO XENIX    native
  3341.  
  3342. HP150        MSDOS        Lattice 2.15    Function key labels
  3343.                         for the touch screen
  3344.  
  3345. HP110        MSDOS        Lattice 2.15
  3346.                 Aztec 3.4e
  3347.  
  3348. *Data General 10
  3349.         MSDOS        Lattice 2.1  Texas Instruments Professional
  3350.         MSDOS        Lattice 2.15
  3351.  
  3352. Amiga        Intuition    Lattice 3.03
  3353.                 Aztec 3.6
  3354.  
  3355. ST520        TOS        Mark Williams C Spawns under MSH
  3356.                 Lattice 3.1    (no shell commands)
  3357.  
  3358. Fujitsu FMR    MSDOS        MSC 6.0
  3359.    series
  3360.  
  3361. NEC 9800    MSDOS        Turbo 2.0    Function key support
  3362.    series            MSC 6.0
  3363.  
  3364. @u[Systems to be supported (IE some code is already written:)]
  3365. Macintosh    System 7    Lightspeed C
  3366.  
  3367. *means that I do not own or have access to the listed compiler and/or
  3368.  machine and must rely upon others to help support it. 
  3369. @end(verbatim)
  3370. @newpage
  3371. @appendix(Function Keys)
  3372.  
  3373.     All environments now support a set of machine independant
  3374. bindings for function keys. Below is a list of these bindings (not all
  3375. of these are supported on all systems).
  3376.  
  3377. @begin(verbatim)
  3378.             Function keys in MicroEmacs
  3379.  
  3380.     function    Function    ^function    Alt-function
  3381.  f1)      FN1         S-FN1          FN^1          A-FN1
  3382.  f2)      FN2         S-FN2          FN^2          A-FN2
  3383.  f3)      FN3         S-FN3          FN^3          A-FN3
  3384.  f4)      FN4         S-FN4          FN^4          A-FN4
  3385.  f5)      FN5         S-FN5          FN^5          A-FN5
  3386.  f6)      FN6         S-FN6          FN^6          A-FN6
  3387.  f7)      FN7         S-FN7          FN^7          A-FN7
  3388.  f8)      FN8         S-FN8          FN^8          A-FN8
  3389.  f9)      FN9         S-FN9          FN^9          A-FN9
  3390. f10)      FN0         S-FN0          FN^0          A-FN0
  3391.  
  3392. home)      FN<                  FN^<
  3393. CsUp)      FNP                  FN^P
  3394. PgUp)      FNZ                  FN^Z
  3395. CsLf)      FNB                  FN^B
  3396.  5  )
  3397. CsRt)      FNF                  FN^F
  3398.  End)      FN>                  FN^>
  3399. CsDn)      FNN                  FN^N
  3400. PgDn)      FNV                  FN^V
  3401.  Ins)      FNC                  FN^C
  3402.  Del)      FND                  FN^D
  3403. @end(verbatim)
  3404. @newpage
  3405. @appendix(Machine Dependent Notes)
  3406.  
  3407.     This appendix lists some notes specific to individual
  3408. implementations of MicroEMACS.    Every attempt has been made to allow
  3409. EMACS to be identical on all machines, but we have also tried to take
  3410. advantage of function keys, cursor keys, mice, and special screen modes
  3411. where possible.
  3412.  
  3413. @appendixsection(IBM-PC/XT/AT and its clones)
  3414.  
  3415.     The IBM-PC family of computers is supported with a variety of
  3416. different display adapters. EMACS will attempt to discover what adapter
  3417. is connected and use the proper driver for it.    Below is a list of the
  3418. currently supported video adapters:
  3419.  
  3420. @begin(verbatim)
  3421. @u(Adapter            $sres        Original mode used)
  3422. Monochrome Graphics Adapter    MONO        MONO
  3423. Color Graphics Adapter        CGA        CGA
  3424. Enhanced Graphics Adapter    EGA        CGA
  3425. Video Graphics Adapter        VGA        CGA
  3426. @end(verbatim)
  3427.  
  3428.     If a driver for a Microsoft compatable mouse is installed on the
  3429. system, EMACS will use the mouse in text mode and allow the user all the
  3430. standard mouse functions. The mouse cursor will appear to be a block of
  3431. color in the color opposite of it's background.
  3432.  
  3433.     EMACS also takes advantage of various function keys and the keys
  3434. on the keypad on an IBM-PC. The function keys are initially not bound
  3435. to any particular functions (except by the emacs.rc startup file), but
  3436. the keypad keys do default to the following:
  3437.  
  3438. @begin(verbatim)
  3439. @u(Keypad key    Function)
  3440. Home        beginning-of-file
  3441. CSRS UP     previous-line
  3442. Pg Up        previous-page
  3443. CSRS LEFT    backward-character
  3444. CSRS RIGHT    forward-character
  3445. End        end-of-file
  3446. CSRS DOWN    next-line
  3447. Pg Dn        Next-page
  3448. @end(verbatim)
  3449.  
  3450.     All these special keys are indicated in EMACS macroes by use of
  3451. the @b(FN) prefix. Below is a list of many of the keys and the codes
  3452. used to specify them. Also the codes may be gotten by using the
  3453. describe-key (^X ?) command on the suspect key.
  3454.  
  3455. @flushleft(@b[Compiling under TURBO C])
  3456.  
  3457.     To compile MicroEMACS under TURBO C, set the TURBO integrated
  3458. environment with the following options:
  3459.  
  3460.     Memory model        LARGE
  3461.     Floating point        NONE
  3462.     Default char type    UNSIGNED
  3463.     Data alignment        BYTE
  3464.     Merge duplicate strings ON
  3465.     Standard stack frame    off
  3466.     Test stack overflow    off
  3467.  
  3468.     Optimize for            SIZE
  3469.     Use register optimization    ON
  3470.     Register optimization        ON
  3471.     Jump optimization        ON
  3472.  
  3473.     Initialize segments    OFF
  3474.     Stack warnings        OFF
  3475.  
  3476.     Names: Code names
  3477.         Segment name    *
  3478. @newpage
  3479. @appendixsection(HP 150)
  3480.  
  3481.     This machine from Hewlett Packard is very unusual for an MSDOS
  3482. machine. It has a touch screen and is very function key oriented. An
  3483. additional command, @i(label-function-key)@index(label-function-key)
  3484. allows you to place labels on the on screen function key labels. A
  3485. numeric argument indicates which function key to label (one through
  3486. eight) and then the program prompts for a 16 character label, which will
  3487. be used as two lines of eight characters. To label function key three
  3488. with "save file" from a macro, you would use:
  3489.  
  3490. @verbatim(3 label-function-key "save    file")
  3491.  
  3492.     Notice the 4 spaces after "save". This forces "file" to begin on
  3493. the second line of the label.
  3494. @newpage
  3495. @appendixsection(Atari 520/1040ST)
  3496.  
  3497.     The ATARI ST family of computers have a dual personality. They
  3498. may use either a monochrome or a color screen.    EMACS supports two
  3499. screen resolutions on each monitor. 
  3500.  
  3501. @center(@b[NOTE])
  3502.  
  3503. @quotation(When you set MicroEMACS up on your system, please remember to
  3504. install it on the desktop as a GEM application. If you have EMACS set
  3505. as a TOS application, the mouse will not function properly, and EMACS
  3506. will alert you to this problem by beeping the bell.)
  3507.  
  3508. @begin(verbatim)
  3509. @u(Monitor $sres size #color $palette format)
  3510. Color    LOW    40x25    16    000111222333444555666777
  3511.     MEDIUM    80x25    4    000111222333
  3512. Mono    HIGH    80x25    2    000
  3513.     DENSE    80x50    2    000
  3514. @end(verbatim)
  3515.  
  3516.     The $palette environment variable can be used to change what
  3517. color is associated with each color name. With a color monitor, each
  3518. group of three digits indicates an octal number specifying the RED,
  3519. GREEN and BLUE levels of that color. Each color digit can vary from 0
  3520. to 7. For example, the initial setting of $palette in LOW resolution is:
  3521.  
  3522. @begin(verbatim)
  3523.     000700070770007707077777
  3524.  
  3525.     which broken up is:
  3526.  
  3527.     000 700 070 770 007 707 077 777
  3528.  
  3529.     which means:
  3530.  
  3531.     000    Black
  3532.     700    Red
  3533.     070    Green
  3534.     770    Yellow
  3535.     007    Blue
  3536.     707    Magenta
  3537.     077    Cyan
  3538.     777    White
  3539. @end(verbatim)
  3540.  
  3541.     Also the mouse buttons are bound to mouse functions as
  3542. described in the chapter about mice. The cursor keys and the function
  3543. keys are bound similarly to IBM-PC.
  3544.  
  3545.     Files generated by EMACS on the ATARI ST have a single return
  3546. character at the end of each line, unlike the desktop files which want
  3547. to have two returns. This makes it display files strangely from GEM's
  3548. [SHOW] option, but makes the files port to other computers much nicer.
  3549. When compiling MicroEMACS, the ADDCR symbol in @b(estruct.h) will cause
  3550. emacs to generate line ending sequences compatible with GEM.
  3551.  
  3552.     Currently, when operating under the Mark Williams MSH program,
  3553. EMACS can shell out and perform external commands. This capability will
  3554. be added later for the Beckmeyer shell and under GEMDOS.
  3555. @newpage
  3556. @appendixsection(Amiga 1000)
  3557.  
  3558.     The Commodore AMIGA 1000 version of MicroEMACS does fully
  3559. support the mouse, window resizing and the close gadget. It runs in
  3560. medium resolution, using the colors defined for the workbench. 
  3561.  
  3562. @center(Note about Compiling MicroEMACS)
  3563.  
  3564. @begin(quotation)
  3565.     If you are compiling the sources on the AMIGA to produce an
  3566. executable image, and you are using the Lattice compiler, be sure to
  3567. give the CLI command 'STACK 40000' before compiling to make sure the
  3568. compiler has sufficient stack space to successfully complete
  3569. compilation.
  3570. @end(quotation)
  3571. @newpage
  3572. @appendixsection(UNIX V5, V7, and BSD4.[23])
  3573.  
  3574.     MicroEMACS under UNIX utilizes the @b(TERMCAP) @index(termcap)
  3575. library to provide machine independent screen functions. Make sure that
  3576. termcap is available and properly set on your account before attempting
  3577. to use MicroEMACS. 
  3578.  
  3579.     Under systems which support job control, you can use the
  3580. @b(^XD) @i(suspend-emacs) @index(suspend-emacs) command to place EMACS
  3581. into the background. This carries a much smaller overhead than bringing
  3582. up a new shell under EMACS. EMACS will properly redraw the screen when
  3583. you bring it back to the foreground.
  3584.  
  3585.     If the symbol VT100 has been set to 1 in the @i(estruct.h)
  3586. options file, EMACS will recognize the key sequence <ESC>[ as the lead
  3587. in sequence for the FN function key prefix.
  3588.  
  3589.     With the addition of some very machine/operating system specific
  3590. code, EMACS can prevent two or more people from modifying the same file
  3591. at the same time. @index(file locking) The upper level of a set of
  3592. functions to provide file locking exist in the source file @b(LOCK.C). 
  3593. It requires two machine specific functions written and linked into EMACS
  3594. for it to operate properly. 
  3595.  
  3596. @begin(verbatim)
  3597.     char *dolock(fname)
  3598.  
  3599.     char *fname;
  3600.  
  3601.     dolock() locks a file, preventing others from modifying it. If
  3602.     it succeeds, it returns NULL, otherwise it returns a pointer to
  3603.     a string in the form "LOCK ERROR: explanation".
  3604.  
  3605.     char *undolock(fname)
  3606.  
  3607.     char *fname;
  3608.  
  3609.     undolock() unlocks a file, allowing others to modifying it. If
  3610.     it succeeds, it returns NULL, otherwise it returns a pointer to
  3611.     a string in the form "LOCK ERROR: explanation".
  3612. @end(verbatim)
  3613. @newpage
  3614. @appendixsection(DEC VMS operating system)
  3615.  
  3616. @flushleft(@b[TERMINALS])
  3617.  
  3618.     Depending upon the options set in ESTRUCT.H, MicroEMACS uses
  3619. either the capabilities of VMS SMG, working with any terminal that is
  3620. defined in SMGTERMS.TXT or TERMTABLE.TXT (see your SMG manual for more
  3621. information), or the ANSI escape sequences. Full keyboard support, with
  3622. function keys and everything, is provided for VT100 and VT200 series
  3623. compatible terminals. Mouse support is provided under the ANSI version
  3624. only at this time. Mouse support is provided for the VSII
  3625. workstation's VT220 terminal emulator, and other terminal emulators
  3626. that use the same escape sequences for mouse control. (There is some
  3627. partial support for the BBN BitGraph mouse sequences in the sources,
  3628. but this is not yet complete). Terminals may have up to 100 lines and
  3629. 160 columns. 
  3630.  
  3631.     The maximum terminal size is 256 columns and 72 row. If you
  3632. run MicroEMACS on a terminal that is larger than this, MicroEMACS will
  3633. reduce it to these limits while you are editing.
  3634.  
  3635. @flushleft(@b[Flow control])
  3636.     Some terminals will require the use of XON/XOFF flow control
  3637. when used with MicroEMACS. When XON/XOFF flow control is used, you
  3638. will not be able to use functions bound to ^S or ^Q, and should use
  3639. bind-to-key to put these functions on other keys. MicroEMACS does not
  3640. change the flow control characteristics of your terminal line while it
  3641. is running. If your terminal requires flow control, you should:
  3642.  
  3643.     $ SET TERM/HOSTSYNC/TTSYNC
  3644.  
  3645.     before entering MicroEMACS. If you are on a VSII emulated
  3646. workstation terminal, are using the SSU multi-session protocol (VT330
  3647. and VT340 with SSU enabled), or are certain that your terminal does not
  3648. require XON/XOFF flow control, you should
  3649.  
  3650.     $ SET TERM /HOSTSYNC/NOTTSYNC
  3651.  
  3652.     This will allow you to use ^S and ^Q for MicroEMACS commands.
  3653. Note that if you are using a VSII with VWS V3.2 or later, you must
  3654. leave the /HOSTSYNC enabled in order for the cross/session cut and
  3655. paste capability to work properly.
  3656.  
  3657.  
  3658. @flushleft(@b[KEYBOARD])
  3659.  
  3660.     The VMS version understands the LK201 functions of VT200
  3661. series, vt300 series, and compatible terminals and terminal emulators,
  3662. and allows you to bind to them as function keys. In addition, the
  3663. VT100 numeric keypad, in application mode, is available as function
  3664. keys. MicroEMACS will only put the keypad into application mode for
  3665. you if the KEYPAD option is set in ESTRUCT.H. In this situation,
  3666. MicroEmacs will detect your kepad's state, and restore it to that state
  3667. upon exiting. If MicroEMACS has not been compiled with this option,
  3668. you may still put the keypad into application mode by issuing the
  3669. command "SET TERM /APPLICATION" before entering MicroEMACS. 
  3670.  
  3671. @begin(verbatim)
  3672. @u(VT200 keys)
  3673.  
  3674. Note that F1 through F5 are local function keys on DEC terminals.
  3675.  
  3676. F6         = FN6    FIND = FNS
  3677. FN7        = FN7    INSERT = FNC
  3678. F8         = FN8    REMOVE = FND
  3679. F9         = FN9    SELECT = FN@@
  3680. F10        = FN0    PREV = FNZ
  3681. F11        = S-FN1    NEXT = FNV
  3682. F12        = S-FN2    Arrow Up = FNP
  3683. F13        = S-FN3    Arrow Down = FNN
  3684. F14        = S-FN4    Arrow Right = FNF
  3685. HELP (F15) = S-FN5    Arrow Left = FNB
  3686. DO (F16)   = S-FN6
  3687. F17        = S-FN7
  3688. F18        = S-FN8
  3689. F19        = S-FN9
  3690. F20        = S-FN0
  3691.  
  3692. @u(VT100 and VT200 numeric keypad in application mode)
  3693.  
  3694. PF1 = FN^1    PF2 = FN^2    PF3 = FN^3    PF4   = FN^4
  3695. 7   = A-7    8   = A-8    9   = A-9    -     = A--
  3696. 4   = A-4    5   = A-5    6   = A-6    ,     = A-,
  3697. 1   = A-1    2   = A-2    3   = A-3    ENTER = A-E
  3698. 0   = A-0    .  = A-.
  3699. @end(verbatim)
  3700.  
  3701. @center(@b[WARNING])
  3702.  
  3703. @begin(quotation)
  3704.     The VMS version contains code for interpreting function keys
  3705. that are sent as Ansi sequences that begin with the ESC character. 
  3706. Because of this, MicroEMACS cannot process an incoming ESC until it
  3707. knows what character follows it. This can cause problems with
  3708. terminating search and replace strings. If you use ESC as the
  3709. meta-prefix character (which is the default) you must type one
  3710. additional keystroke following ESC before emacs will recognize that you
  3711. have edited the search command prompt, and are continuing. (The
  3712. additional character is processed normally be MicroEMACS, it is NOT
  3713. discarded.)
  3714.  
  3715.     MicroEMACS must wait long enough for the network delay
  3716. that might be involved between seeing the ESC and seeing the
  3717. characters that follow it. If holding down one of the arrow keys causes
  3718. characters to drop into your file, then you may want to alter the delay
  3719. yourself. The logical variable MICROEMACS$SHORTWAIT may be set to vary
  3720. that delay. The default delay is 400ms (4 tenths of a second). The
  3721. equivalent value in MICROEMACS$SHORTWAIT is 4000000.
  3722. @end(quotation)
  3723.  
  3724. @flushleft(@b[Special case for BBN BItGraph])
  3725.  
  3726.     If you are using the BBN BitGraph, execute the following commands
  3727. before entering MicroEMACS, and you will get mouse support:
  3728.  
  3729. @begin(verbatim)
  3730.     $ esc[0,8] = 27
  3731.     $ microemacs$mouse_enable == esc+":5;6;L"+esc+":0;63;;;;;;;;;9;16;c"
  3732.     $ microemacs$mouse_disable == esc+":5;1;L"+esc+":0;0c"
  3733.     $ exit
  3734. @end(verbatim)
  3735.  
  3736.     Do NOT do this for any other terminals.
  3737.  
  3738. @flushleft(@b[Search List for EMACS.RC])
  3739.  
  3740.     VMS MicroEMACS will first search logical name MICROEMACS$LIB:,
  3741. then SYS$LOGIN:, then the current directory, and finally
  3742. "sys$sysdevice:[vmstools]" when looking for startup files or help
  3743. files.
  3744.  
  3745.     Please use MICROEMACS$LIB:, and allow the secondary search of
  3746. [vmstools] to become archaic. If desired, MICROEMACS$LIB may be
  3747. defined to be a VMS search list that first searches a user directory,
  3748. and then a system directory. 
  3749.  
  3750.     Generally, you should create a private directory where you keep
  3751. all your .CMD files, and in your LOGIN.COM $DEFINE a logical name to
  3752. point to this area.
  3753.  
  3754.     In addition to whatever commands you have in your EMACS.RC file,
  3755. one command you should certainly include is "set $ssave FALSE". The
  3756. "safe save" mechanism, which writes a buffer to a temporary file,
  3757. deletes the old version of a file, and then moves the temporary file to
  3758. its permanent name, works wonderfully on most systems, but makes no
  3759. sense on VMS, which maintains older versions of a file.
  3760.  
  3761. @flushleft(@b[Using MicroEMACS as a subprocess])
  3762.     MicroEmacs can now be kept in a subprocess. You can arrange to
  3763. start emacs only once in a job, and to re-attach to it each time you
  3764. want to use it. This is optional. To use this feature, install
  3765. MicroEMACS in the following way:
  3766.  
  3767. @begin(verbatim)
  3768. 1. MicroEMACS contains two images. ME.EXE is a small program for
  3769.     starting and stopping the Emacs subprocess. The source for ME.
  3770.     is in ME.C, and should not be linked into MESHR.EXE. MESHR.EXE
  3771.     is the actual MicroEMACS image. The name "MESHR" is required for
  3772.     MAIL/NOTES support, see next section for details.
  3773.  
  3774. 2. Make sure that the SYS$SHARE search list includes MESHR.EXE. If you
  3775.    don't have the privilages to move MESHR.EXE into SYS$SHARE, you
  3776.    can $ DEFINE the MESHR logical name to be the full name and location of
  3777.    the MESHR.EXE program. For example, you could store all of these
  3778.    programs in the MICROEMACS$LIB: search list, and say:
  3779.  
  3780.         $ DEFINE MESHR microemacs$lib:meshr.exe
  3781.  
  3782. 3. Put ME.EXE in MICROEMACS$LIB and the following line in your LOGIN.COM:
  3783.  
  3784.         $ me :== $microemacs$lib:me
  3785.  
  3786. 4. Put a line in your EMACS.RC that will
  3787.  
  3788.         bind-to-key suspend-emacs ^C  ; use your usual exit-emacs key
  3789. @end(verbatim)
  3790.  
  3791.     Now, use the "$ ME" command to invoke microemacs. Subseqeuent
  3792. invocations in the same job will re-use the existing subprocess. You
  3793. can use the full capabilty of the microemacs command line in the first
  3794. and in all subsequent invocations of ME.
  3795.  
  3796.     WARNING:
  3797.  
  3798.     MicroEMACS will ALWAYS read in new copies of any files you
  3799. specify on the command line, even if you are already editing it. If
  3800. you edit a file a second time with the same MicroEMACS, you will get a
  3801. NEW buffer with ANOTHER copy of the file. The old buffer is still
  3802. there also. It is easy, in this situation, to accidently edit in a
  3803. WRONG BUFFER, and if you write out an obsolete buffer, you will loose
  3804. earlier edits!
  3805.  
  3806.     This is considered a bug and may be fixed in a later version of
  3807. MicroEMACS. To avoid this situation, do not specify a file on the
  3808. command line if MicroEMACS already has that file in a buffer. Use the
  3809. "find-file" MicroEMACS command instead.
  3810.  
  3811.  
  3812.     @b(Using MICROEMACS with MAIL and NOTES:)
  3813.  
  3814.     With VMS V5 and later versions, the MAIL interface to
  3815. Microemacs is much simplified. With VMS V5, the MESHR.EXE image does
  3816. NOT have to be installed as a known image to be used as a callable
  3817. editor from MAIL. Therefore, to use MicroEMACS as your VMS MAIL
  3818. editor, simply add the following lines to your LOGIN.COM:
  3819.  
  3820. @begin(verbatim)
  3821.         $ DEFINE MAIL$EDIT CALLABLE_ME
  3822.         $ MAIL :== MAIL/EDIT
  3823. @end(verbatim)
  3824.  
  3825.     and make sure that the SYS$SHARE search list includes
  3826. MESHR.EXE. If you don't have privs or permission to move MESHR.EXE
  3827. into SYS$SHARE, you can $ DEFINE the MESHR logical name to be the full
  3828. name and location of the MESHR.EXE program. For example, you could
  3829. store all of these programs in the MICROEMACS$LIB: search list, and
  3830. say:
  3831.  
  3832.         $ DEFINE MESHR microemacs$lib:meshr.exe
  3833.  
  3834.     Note that this is the same location as is required for using kept
  3835. MicroEMACS.
  3836.  
  3837.     To abort sending a message, exit MicroEMACS without writing out
  3838. the mail message file.
  3839.  
  3840.     To use MicroEMACS as your VAX NOTES editor, issue the following
  3841. command to VAX NOTES:
  3842.  
  3843.         NOTES> SET PROFILE/EDIT=(ME,CALL)
  3844.  
  3845.     Note, if you are still in the dark ages of VMS V4, you will
  3846. have to either install MESHR as a known image, or following the
  3847. original "Second way" instructions given in the existing appendix F.6
  3848. of the older MicroEMACS manual (previous to version 3.10).
  3849.  
  3850. @flushleft(@b[Second way, as described in older versions])
  3851.  
  3852.     In the event that you cannot get your system manager to INSTALL
  3853. MicroEMACS as known image, you can use the following technique:
  3854.  
  3855. @begin(verbatim)
  3856. 1. In MICROEMACS$LIB:MEMAIL.COM, put the following command file:
  3857.  
  3858. $! Use on VAX/VMS as MAIL$EDIT for using MicroEMACS as mail editor.
  3859. $ if "''P1'" .NES. "_NL:" then if "''P1'" .NES. "" then copy 'P1' 'P2'
  3860. $ define/user sys$input sys$output
  3861. $ me 'P2'
  3862. $ exit
  3863.  
  3864. This file may have come with your MicroEMACS kit.
  3865.  
  3866. 2. In your LOGIN.COM, put the following lines:
  3867.  
  3868. $    me :== $MICROEMACS$LIB:MESHR.EXE ! Assumes meshr.exe is there
  3869. $    define mail$edit microemacs$lib:me_edit.com
  3870.  
  3871. 3. In NOTES, give the command
  3872.  
  3873. NOTES> SET PROFILE/EDIT=(@@MicroEMACS$lib:me_edit.com,SPAWN)
  3874.  
  3875. @flushleft(@b[Building MicroEMACS for VMS])
  3876.  
  3877. The configuration options are set in file estruct.h:
  3878.  
  3879. - Under the category of "Machine/OS definitions", set VMS to "1" and all
  3880. others to "0". 
  3881.  
  3882. - Under "Compiler definitions", set all selections to "0". Selecting
  3883. VMS implies that you are using VAXC.
  3884.  
  3885. - Under "Special keyboard definitions", be sure "VT100" is set to "0". 
  3886. This option is not required for the VMS version, it is for other
  3887. systems using ANSI terminal support. VMS in combination with SMG or
  3888. ANSI already handles the special characteristics of Ansi keyboards.
  3889.  
  3890. - Under "Terminal Output definitions", set either ANSI or SMG to "1"
  3891. and all others to "0". As stated previously, only ANSI supports the
  3892. mouse at this time.
  3893.  
  3894. - Under "Configuration options", you may select as you wish, with the
  3895. following notes:
  3896.  
  3897.     - COLOR    support does not exist for VMS, even when using
  3898.         color workstations.
  3899.     - MOUSE    support should be enabled if you have any VSII
  3900.         workstations. Only supported under the ANSI driver.
  3901.     - KEYPAD    support recognises whether your keypad is already
  3902.         in application mode or not, and puts your keypad
  3903.         in its correct state on exit.
  3904.     - XNONOFF    automatically allows you to use control-S or
  3905.         control-Q in MicroEMACS, by disabling the TTSYNC
  3906.         characteristic. This option should not be set if
  3907.         MicroEMACS might be used on DecStations or VT100s.
  3908.         It also should not be used with slow terminals or
  3909.         terminal emulators connected to fast terminal lines.
  3910.     - RMSIO    support should absolutely be used. This option
  3911.         allows the writing and reading of files in VMS's
  3912.         variable-length format, as opposed to STREAM-LF,
  3913.         and cuts down on file writing and reading time by
  3914.         approximately two thirds.
  3915.     - OPTMEM    support may be used on VMS versions 5.0 and higher.
  3916.         It substitutes the C library's memory allocation
  3917.         calls for the native VAX calls, and gives a speed
  3918.         improvement.
  3919. @end(verbatim)
  3920.  
  3921.     If you have MMS, you can use the supplied DESCRIP.MMS to build
  3922. MicroEMACS. Otherwise, the command file MEMAKE.COM has been provided.
  3923. These files assume that you are using SMG as your terminal driver. If
  3924. you are using ANSI, then you must replace SMG with ANSI in the command
  3925. and opt files. If you do not have MMS or are missing MEMAKE.COM,
  3926. simply compile each module with "CC", and link with the command:
  3927.  
  3928.     $ LINK MESHR/OPTION/SHARE
  3929.  
  3930.     Note that the executable filename must end in "SHR" in order
  3931. for MicroEMACS to be used as a callable editor from MAIL or NOTES. 
  3932. (Method 1 above.)
  3933.  
  3934.     If you edit any of the Emacs sources, note that any global or
  3935. external data must be declared as "noshare" in order for the VMS
  3936. callable editor support to work properly. This applies to all global
  3937. data used in the VMS version, but not to routines or to "static "data. 
  3938. The "noshare" declaration is #define'd away on non-VMS systems. If you
  3939. fail to do this, VMS will not allow you to INSTALL MicroEMACS as a
  3940. sharable library.
  3941. @newpage
  3942. @appendix(Mode Flags)
  3943.  
  3944.     The two environment variables, $cmode and $gmode, contain a
  3945. number the corresponds to the modes set for the current buffer and
  3946. the editor as a whole.    These are encoded as the sum of the following
  3947. numbers for each of the possible modes:
  3948.  
  3949. @begin(verbatim)
  3950. WRAP      1        Word wrap
  3951. CMODE      2        C indentation and fence match
  3952. SPELL      4        Interactive spell checking (Not Implemented Yet)
  3953. EXACT      8        Exact matching for searches
  3954. VIEW     16        Read-only buffer
  3955. OVER     32        Overwrite mode
  3956. MAGIC     64        Regular expressions in search
  3957. CRYPT    128        Encryption mode active
  3958. ASAVE    256        Auto-save mode
  3959. @end(verbatim)
  3960.  
  3961.     So, if you wished to set the current buffer to have CMODE,
  3962. EXACT, and MAGIC on, and all the others off, you would add up the values
  3963. for those three, CMODE 2  +  EXACT 8  +  MAGIC 64 = 74, and use a
  3964. statement like:
  3965.  
  3966. set $cmode 74
  3967.  
  3968.     or, use the binary or operator to combine the different modes:
  3969.  
  3970. set $cmode &bor &bor 2 8 64
  3971.  
  3972. @flushleft(@big[Internal Flags])
  3973.  
  3974.     Some of the ways EMACS controls its internal functions can be
  3975. modified by the value in the $gflags@index($gflags) environment
  3976. variable. Each bit in this variable will be used to control a
  3977. different function.
  3978.  
  3979. @begin(verbatim)
  3980. GFFLAG        1    If this bit is set to zero, EMACS will not
  3981.             automatically switch to the buffer of the
  3982.             first file after executing the startup macros.
  3983. @end(verbatim)
  3984.  
  3985. @flushleft(@big[Current buffer flags])
  3986.  
  3987.     The $cbflags@index($cbflags) environment variable allows the
  3988. user to modify some of the characteristics of the current buffer. The
  3989. various characteristics are encoded as the sum of the following
  3990. numbers:
  3991.  
  3992. @begin(verbatim)
  3993. BFINVS        1    Internal invisible buffer
  3994. BFCHG        2    Changed since last write
  3995. BFTRUNC     4    buffer was truncated when read
  3996. BFNAROW     8    buffer has been narrowed
  3997. @end(verbatim)
  3998.  
  3999.     Only the invisible and changed flags can be modified by setting
  4000. the $cbflags variable.    The truncated file and narrowed flags are read
  4001. only.
  4002.