home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume1 / 8711 / 12 < prev    next >
Internet Message Format  |  1990-07-13  |  51KB

  1. Path: uunet!husc6!necntc!ncoast!allbery
  2. From: nwd@j.cc.purdue.edu (Daniel Lawrence)
  3. Newsgroups: comp.sources.misc
  4. Subject: MicroEmacs 3.9 Manual (1 of 6)
  5. Message-ID: <5814@ncoast.UUCP>
  6. Date: 26 Nov 87 04:13:39 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Lines: 1110
  9. Approved: allbery@ncoast.UUCP
  10. X-Archive: comp.sources.misc/8711/12
  11.  
  12. [Sorry for the hiatus.  A short trip out of state turned out to be longer than
  13. I expected; ``the best-laid plans,'' and so on.
  14.  
  15. This shar archive arrived in pieces; you must save the messages, chop off
  16. headers and trailers, concatenate, THEN unshar.  Somewhat bogus, by my
  17. reckoning....  ++bsa]
  18.  
  19. # This is a shar archive.
  20. # Remove everything above this line.
  21. # Run the file through sh, not csh.
  22. # (type `sh this_file')
  23. # If you do not see the message
  24. #    `this_file completed!'
  25. # then the file was incomplete.
  26. echo extracting - emacs.mss
  27. sed 's/^X//' > emacs.mss << 'FRIDAY_NIGHT'
  28. X@style(indent 8 chars, spacing 1 lines)
  29. X@pagefooting()
  30. X
  31. X
  32. X
  33. X
  34. X
  35. X
  36. X
  37. X
  38. X
  39. X
  40. X
  41. X
  42. X        @big(MicroEMACS)
  43. X
  44. X        Full Screen Text Editor
  45. X        Reference Manual (preliminary draft)
  46. X
  47. X        Version 3.9e
  48. X        November 4, 1987
  49. X
  50. X        (C)opyright 1987 by Daniel M. Lawrence
  51. X        Reference Manual (C)opyright 1987
  52. X            by Brian Straight and Daniel M. Lawrence
  53. X        All Rights Reserved
  54. X
  55. X        @i(MicroEMACS 3.9e can be copied and distributed freely
  56. X        for any non-commercial purposes. MicroEMACS 3.9e can
  57. X        only be incorporated into commercial software with
  58. X        the permission of the current author.)
  59. X@newpage
  60. X@newpage
  61. X@flushleft(@big[Introduction])
  62. X
  63. X    MicroEMACS is a tool for creating and changing documents,
  64. Xprograms, and other text files.  It is both relatively easy for the
  65. Xnovice to use, but also very powerful in the hands of an expert.
  66. XMicroEMACS can be extensively customized for the needs of the
  67. Xindividual user.
  68. X
  69. X    MicroEMACS allows several files to be edited at the same time.
  70. XThe screen can be split into different windows, and text may be moved
  71. Xfreely from one window to the next.  Depending on the type of file being
  72. Xedited, MicroEMACS can change how it behaves to make editing simple. 
  73. XEditing standard text files, program files and word processing documents
  74. Xare all possible at the same time.
  75. X
  76. X    There are extensive capabilities to make word processing and
  77. Xediting easier.  These include commands for string searching and
  78. Xreplacing, paragraph reformatting and deleting, automatic word wrapping,
  79. Xword move and deletes, easy case controlling, and automatic word counts.
  80. X
  81. X    For complex and repetitive editing tasks editing macroes can be
  82. Xwritten.  These macroes allow the user a great degree of flexibility in
  83. Xdetermining how MicroEMACS behaves.  Also, any and all the commands can
  84. Xbe used by any keystroke by changing, or rebinding, what commands
  85. Xvarious keys are connected, or bound, to. 
  86. X
  87. X    Special features are also available to perform a diverse set of
  88. Xoperations such as file encryption, automatic backup file generation,
  89. Xentabbing and detabbing lines, executing of DOS commands and filtering
  90. Xof text through other programs (like SORT to allow sorting text).
  91. X
  92. X@flushleft(@big[History])
  93. X
  94. X    EMACS was originally a text editor written by Richard Stahlman
  95. Xat MIT in the early 1970s for Digital Equipment computers. Various
  96. Xversions, rewrites and clones have made an appearence since.
  97. X
  98. X    This version of MicroEMACS is derived from code written by Dave
  99. XG. Conroy in 1985.  Later modifications were performed by Steve Wilhite
  100. Xand George Jones.  In December of 1985 Daniel Lawrence picked up the
  101. Xthen current source (version 2.0) and made extensive modifications and
  102. Xadditions to it over the course of the next two years.  Updates and
  103. Xsupport for the current version are still availible.  The current
  104. Xprogram author can be contacted by writing to:
  105. X
  106. X@begin(verbatim)
  107. X    USMAIL:    Daniel Lawrence
  108. X        617 New York St
  109. X        Lafayette, IN 47901
  110. X
  111. X    UUCP:    ihnp4!pur-ee!pur-phy!duncan!lawrence
  112. X    ARPA:    nwd@@j.cc.purdue.edu
  113. X    FIDO:    Fido 201/2 The Programmer's Room (317) 742-5533
  114. X@end(verbatim)
  115. X@string(ChapterTitle="")
  116. X@set(page = 0)
  117. X@pageheading(odd, left "@title[Chapter]", right "MicroEMACS Reference Manual")
  118. X@pageheading(even, left "MicroEMACS Reference Manual", right "@title[Chapter]")
  119. X@pagefooting(odd, left="@value(page)")
  120. X@pagefooting(even, right="@value(page)")
  121. X@chapter(Basic Concepts)
  122. X
  123. X    The current version of MicroEMACS is 3.9e (Third major re-write,
  124. Xninth public release, fifth minor edit), and for the rest of this
  125. Xdocument, we shall simply refer to this version as "EMACS".  Any
  126. Xmodifications for later versions will be listed in the appendixes at the
  127. Xend of this manual. 
  128. X
  129. X@section(Keys and the Keyboard)
  130. X
  131. X    Many times throughout this manual we will be talking about
  132. X@index(special keys) commands and the keys on the keyboard needed to use
  133. Xthem.  There are a number of "special" keys which can be used and are
  134. Xlisted here:
  135. X
  136. X@begin(description)
  137. X<NL>@\NewLine which is also called RETURN or ENTER, this key is used to
  138. X@index(newline) end different commands. 
  139. X
  140. X^@\The control key can be used before any alphabetic character and some
  141. Xsymbols.  For example, ^C means to hold down the <CONTROL> key and type
  142. X@index(control key) the C key at the same time. 
  143. X
  144. X^X@\The CONTROL-X key is used at the beginning of many different
  145. X@index(control-x) commands. 
  146. X
  147. XMETA or M-@\This is a special EMACS key used to begin many commands as
  148. X@index(meta key) well.  This key is pressed and then released before
  149. Xtyping the next character.  On most systems, this is the <ESC> key, but
  150. Xit can be changed.  (consult appendix E to learn what key is used for
  151. XMETA on your computer).
  152. X@end(description)
  153. X
  154. XWhenever a command is described, the manual will list the actual
  155. Xkeystrokes needed to execute it in @b(boldface) using the above
  156. Xconventions, and also the name of the command in @i(italics).
  157. X@section(Getting Started)
  158. X
  159. X    In order to use EMACS, you must call it up from your system or
  160. Xcomputer's command prompt.  On UNIX and MSDOS machines, just type
  161. X"emacs" from the main command prompt and follow it with the <RETURN> or
  162. X<ENTER> key (we will refer to this key as <NL> for "new-line" for the
  163. Xremainder of this manual).  On the Macintosh, the Amiga, the ATARI ST
  164. Xand other icon based operating systems, double click on the uEMACS icon.
  165. XShortly after this, a screen similar to the one below should appear.
  166. X
  167. X@section(Parts and Pieces)
  168. X
  169. X    The screen is divided into a number of areas or @b<windows>.  On
  170. Xsome systems the top window contains a function list of unshifted and
  171. X@index(windows) shifted function keys.  We will discuss these keys later. 
  172. X@index(mode line) Below them is an EMACS @b<mode line> which, as we will
  173. Xsee, informs you of the present mode of operation of the editor--for
  174. Xexample "(WRAP)" if you set EMACS to wrap at the end of each line. 
  175. X@index(text window) Under the mode line is the @b<text window> where text
  176. Xappears and is manipulated.  Since each window has its own mode line,
  177. Xbelow the text window is it's mode line.  The last line of the screen is
  178. Xthe @b(command line) where EMACS takes commands and reports on what it
  179. Xis doing. 
  180. X
  181. X@begin(verbatim)
  182. X===============================================================================
  183. Xf1 search-> f2 <-search |    MicroEMACS:  Text Editor
  184. Xf3 hunt->   f4 <-hunt   | 
  185. Xf5 fkeys    f6 help     |  Available function key Pages include:
  186. Xf7 nxt wind f8 pg[    ] |    WORD  PROG  BOX
  187. Xf9 save     f10 exit    |  [use the f8 key to load Pages]
  188. X===============================================================================
  189. X-- MicroEMACS 3.9e () -- Function Keys ---------------------------------------
  190. X===============================================================================
  191. X
  192. X
  193. X
  194. X
  195. X
  196. X
  197. X
  198. X
  199. X
  200. X
  201. X
  202. X
  203. X===============================================================================
  204. X-- MicroEMACS 3.9e () -- Main ------------------------------------------------
  205. X===============================================================================
  206. X        Fig 1:    EMACS screen on an IBM-PC
  207. X@end(verbatim)
  208. X
  209. X@section(Entering Text)
  210. X
  211. XEntering text in EMACS is simple.  Type the following sentence fragment:
  212. X
  213. X@quotation<Fang Rock lighthouse, center of a series of mysterious and>
  214. X
  215. X@flushleft(The text is displayed at the top of the text window.  Now type:)
  216. X
  217. X@quotation<terrifying events at the turn of the century>
  218. X
  219. XNotice the text to the left of the cursor disappears and a '$' sign
  220. Xappears.  Don't panic--your text is safe!!! You've just discovered that
  221. XEMACS doesn't "wrap" text to the next line like most word processors
  222. Xunless you hit <NL>.  But since EMACS is used for both word processing,
  223. Xand text editing, it has a bit of a dual personality.  You can change
  224. X@index(modes) the way it works by setting various @b(modes).  In this
  225. Xcase, you need to set @b(WRAP) mode, using the @i(add-mode)
  226. X@index(add-mode) command, by typing @b(^X-M).  The command line at the
  227. Xbase of the screen will prompt you for the mode you wish to add.  Type
  228. X@b<wrap> followed by the <NL> key and any text you now enter will be
  229. Xwrapped.  However, the command doesn't wrap text already entered.  To
  230. Xget rid of the truncated line, delete characters with the <BACKSPACE>
  231. Xkey until the '$' goes away.  Now type in the words you deleted, watch
  232. Xhow EMACS goes down to the next line at the right time.  @i{(In some
  233. Xversions of EMACS, @b<WRAP> is a default mode in which case you don't
  234. Xhave to worry about the instructions relating to adding this mode.)}
  235. X
  236. XNow let's type a longer insert.  Hit <NL> a couple of times to tab
  237. Xdown from the text you just entered.  Now type the following paragraphs. 
  238. XPress <NL> twice to indicate a paragraph break. 
  239. X
  240. X@quotation<Fang Rock lighthouse, center of a series of mysterious and
  241. Xterrifying events at the turn of the century, is built on a rocky island
  242. Xa few miles of the Channel coast.  So small is the island that wherever
  243. Xyou stand its rocks are wet with sea spray. 
  244. X
  245. XThe lighthouse tower is in the center of the island.  A steep flight of
  246. Xsteps leads to the heavy door in its base.  Winding stairs lead up to
  247. Xthe crew room.>
  248. X
  249. X@section<Basic cursor movement>
  250. X
  251. XNow let's practice moving around in this text.  To move the cursor back
  252. Xto the word "Winding," enter @b<M-B> @i(previous-word)
  253. X@index(previous-word).  This command moves the cursor backwards by one
  254. Xword at a time.  Note you have to press the key combination every time
  255. Xthe cursor steps back by one word.  Continuously pressing META and
  256. Xtoggling B produces an error message.  To move forward to the word
  257. X"stairs" enter @b<M-F>, which moves the cursor forward by one word at a
  258. Xtime. 
  259. X
  260. XNotice that EMACS commands are usually mnemonic--F for forward, B for
  261. Xbackward, for example.
  262. X
  263. XTo move the cursor up one line, enter @b<^P> @i(previous-line)
  264. X@index(previous-line), down one line @b<^N> @i(next-line)
  265. X@index(next-line).  Practice this movement by moving the cursor to the
  266. Xword "terrifying" in the second line. 
  267. X
  268. XThe cursor may also be moved forward or backward in smaller increments. 
  269. XTo move forward by one character, enter @b<^F> @i(forward-character)
  270. X@index(forward-character), to move backward, @b<^B>
  271. X@i(backward-character) @index(backward-character).  EMACS also allows
  272. Xyou to specify a number which is normally used to tell a command to
  273. Xexecute many times.  To repeat most commands, press META and then the
  274. Xnumber before you enter the command.  Thus, the command META 5 ^F
  275. X(@b<M-5^F>) will move the cursor forward by five characters.  Try moving
  276. Xaround in the text by using these commands.  For extra practice, see how
  277. Xclose you can come to the word "small" in the first paragraph by giving
  278. Xan argument to the commands listed here. 
  279. X
  280. XTwo other simple cursor commands that are useful to help us move around
  281. Xin the text are @b<M-N> @i(next-paragraph) @index(next-paragraph) which
  282. Xmoves the cursor to the second paragraph, and @b<M-P>
  283. X@i(previous-paragraph) @index(previous-paragraph) which moves it back to
  284. Xthe previous paragraph.  The cursor may also be moved rapidly from one
  285. Xend of the line to the other.  Move the cursor to the word "few" in the
  286. Xsecond line.  Press @b<^A> @i(beginning-of-line)
  287. X@index(beginning-of-line).  Notice the cursor moves to the word "events"
  288. Xat the beginning of the line.  Pressing @b<^E> @i(end-of-line)
  289. X@index(end-of-line) moves the cursor to the end of the line. 
  290. X
  291. XFinally, the cursor may be moved from any point in the file to the end
  292. Xor beginning of the file.  Entering @b{M->} @i(end-of-file)
  293. X@index(end-of-file) moves the cursor to the end of the buffer, @b{M-<}
  294. X@i(beginning-of-file) @index(beginning-of-file) to the first character
  295. Xof the file. 
  296. X
  297. X@i(On the IBM-PC, the ATARI ST and many other machines, the cursor keys
  298. X@index(cursor keys) can also be used to move the cursor about.  Also, if
  299. Xthere is one available, moving the mouse will move the cursor.)
  300. X
  301. XPractice moving the cursor in the text until you are comfortable with
  302. Xthe commands we've explored in this chapter.
  303. X
  304. X@section(Saving your text)
  305. X
  306. XWhen you've finished practicing cursor movement, save your file.  Your
  307. X@index(buffer) file currently resides in a @b<BUFFER>.  The buffer is a
  308. Xtemporary storage area for your text, and is lost when the computer is
  309. Xturned off.  You can save the buffer to a file by entering @b<^X-^S>
  310. X@i(save-file) @index(save-file).  Notice that EMACS informs you that
  311. Xyour file has no name and will not let you save it. 
  312. X
  313. XTo save your buffer to a file with a different name than it's current
  314. Xone (which is empty), press @b<^X^W> @i(write-file) @index(write-file). 
  315. XEMACS will prompt you for the filename you wish to write.  Enter the
  316. Xname @b<fang.txt> and press return.  On a micro, the drive light will
  317. Xcome on, and EMACS will inform you it is writing the file.  When it
  318. Xfinishes, it will inform you of the number of lines it has written to
  319. Xthe disk. 
  320. X
  321. XCongratulations!! You've just saved your first EMACS file!
  322. X@newpage
  323. X@heading(Chapter @value(chapter) Summary)
  324. X
  325. X    In chapter @value(chapter), you learned how to enter text, how
  326. Xto use wrap mode, how to move the cursor, and to save a buffer.  The
  327. Xfollowing is a table of the commands covered in this chapter and their
  328. Xcorresponding key bindings:
  329. X
  330. X@begin{verbatim}
  331. X@u(Key Binding        Keystroke    Effect)
  332. X
  333. Xabort-command        @b<^G>        aborts current command
  334. X
  335. Xadd-mode        @b<^XM>        allows addition of EMACS
  336. X                    mode such as @b(WRAP)
  337. X
  338. Xbackward-character    @b<^B>        moves cursor left one character
  339. X
  340. Xbeginning-of-file    @b{M-<}        moves cursor to beginning of file
  341. X
  342. Xbeginning-of-line    @b<^A>        moves cursor to beginning of line
  343. X
  344. Xend-of-file        @b{M->}        moves cursor to end of file
  345. X
  346. Xend-of-line        @b<^E>        moves cursor to end of line
  347. X
  348. Xforward-character    @b<^F>        moves cursor right one character
  349. X
  350. Xnext-line        @b<^N>        moves cursor to next line
  351. X
  352. Xnext-paragraph        @b<M-N>        moves cursor to next paragraph
  353. X
  354. Xnext-word        @b<M-F>        moves cursor forward one word
  355. X
  356. Xprevious-line        @b<^P>        moves cursor backward by one line
  357. X
  358. Xprevious-paragraph    @b<M-P>        moves cursor to previous paragraph
  359. X
  360. Xprevious-word        @b<M-B>        moves cursor backward by one word
  361. X
  362. Xsave-file        @b<^X-^S>    saves current buffer to a file
  363. X
  364. Xwrite-file        @b<^X-^W>    save current buffer under a new name
  365. X@end(verbatim)
  366. X@newpage
  367. X@chapter(Basic Editing--Simple Insertions and Deletions)
  368. X
  369. X@section<A Word About Windows, Buffers, Screens, and Modes>
  370. X
  371. XIn the first chapter, you learned how to create and save a file in
  372. XEMACS.    Let's do some more editing on this file.  Call up emacs by
  373. Xtyping in the following command.
  374. X
  375. X@b<emacs fang.txt>
  376. X
  377. X@i(On icon oriented systems, double click on the uEMACS icon, usually a
  378. Xfile dialog box of some sort will appear.  Choose @b(FANG.TXT) from the
  379. Xappropriate folder.)
  380. X
  381. XShortly after you invoke EMACS, the text should appear on the screen
  382. Xready for you to edit.  The text you are looking at currently resides in
  383. Xa @b<buffer>.  A buffer is a temporary area of computer memory which is
  384. X@index(buffer) the primary unit internal to EMACS -- this is the place
  385. Xwhere EMACS goes to work.  The mode line at the bottom of the screen
  386. Xlists the buffer name, @b<FANG.TXT> and the name of the file with which
  387. Xthis buffer is associated, @b<FANG.TXT>
  388. X
  389. XThe computer talks to you through the use of its @b(screen).  This
  390. X@index(screen) screen usually has an area of 24 lines each of 80
  391. Xcharacters across.  You can use EMACS to subdivide the screen into
  392. Xseveral separate work areas, or @b(windows), each of which can be
  393. X@index(window) 'looking into' different files or sections of text.  Using
  394. Xwindows, you can work on several related texts at one time, copying and
  395. Xmoving blocks of text between windows with ease.  To keep track of what
  396. Xyou are editing, each window is identified by a @b(mode line) on the
  397. X@index(mode line) @index(buffer) last line of the window which lists the
  398. Xname of the @b(buffer) which it is looking into, the file from which the
  399. Xtext was read, and how the text is being edited. 
  400. X
  401. XAn EMACS @b<mode> tells EMACS how to deal with user input.  As we have
  402. Xalready seen, the mode 'WRAP' controls how EMACS deals with long lines
  403. X(lines with over 79 characters) while the user is typing them in.  The
  404. X'VIEW' mode, allows you to read a file without modifying it.  Modes are
  405. Xassociated with buffers and not with files; hence, a mode needs to be
  406. Xexplicitly set or removed every time you edit a file.  A new file read
  407. Xinto a buffer with a previously specified mode will be edited under this
  408. Xmode.  If you use specific modes frequently, EMACS allows you to set
  409. Xthe modes which are used by all new buffers, called @b<global> modes. 
  410. X
  411. X@section<Insertions>
  412. X
  413. XYour previously-saved text should look like this:
  414. X
  415. X@quotation<Fang Rock lighthouse, center of a series of mysterious and
  416. Xterrifying events at the turn of the century, is built on a rocky island
  417. Xa few miles of the Channel coast.  So small is the island that wherever
  418. Xyou stand its rocks are wet with sea spray. 
  419. X
  420. XThe lighthouse tower is in the center of the island.  A steep flight of
  421. Xsteps leads to the heavy door in its base.  Winding stairs lead up to
  422. Xthe crew room.>
  423. X
  424. XLet's assume you want to add a sentence in the second paragraph after
  425. Xthe word "base."  Move the cursor until it is on the "W" of "Winding".
  426. XNow type the following:
  427. X
  428. X@quotation<This gives entry to the lower floor where the big steam
  429. Xgenerator throbs steadily away, providing power for the electric
  430. Xlantern.>
  431. X
  432. XIf the line fails to wrap and you end up with a '$' sign in the right
  433. Xmargin, just enter @b{M-Q} @i(fill-paragraph) @index(fill-paragraph) to
  434. Xreformat the paragraph.  This new command attempts to fill out a
  435. Xparagraph.  Long lines are divided up, and words are shuffled around to
  436. Xmake the paragraph look nicer. 
  437. X
  438. XNotice that all visible EMACS characters are self-inserting -- all you
  439. Xhad to do was type the characters to insert and the existing text made
  440. Xspace for it.  With a few exceptions discussed later, all non-printing
  441. Xcharacters (such as control or escape sequences) are commands.  To
  442. Xinsert spaces, simply use the space bar.  Now move to the first line of
  443. Xthe file and type @b{^O} @i(open-line) @index(open-line) (Oh, not zero). 
  444. XYou've just learned how to insert a blank line in your text. 
  445. X
  446. X@section<Deletions>
  447. X
  448. XEMACS offers a number of deletion options.  For example, move the cursor
  449. Xuntil it's under the period at the end of the insertion you just did. 
  450. XPress the backspace key.  Notice the "n" on "lantern" disappeared.  The
  451. Xbackspace implemented on EMACS is called a @b<destructive> backspace--it
  452. Xremoves text immediately before the current cursor position from the
  453. Xbuffer.  Now type @b<^H> @i(delete-previous-character)
  454. X@index(delete-previous-character).  Notice that the cursor moves back
  455. Xand obliterates the "r"--either command will backspace the cursor. 
  456. X
  457. XType in the two letters you erased to restore your text and move the
  458. Xcursor to the beginning of the buffer @b{M->} @i(beginning-of-file)
  459. X@index(beginning-of-file).  Move the cursor down one line to the
  460. Xbeginning of the first paragraph. 
  461. X
  462. XTo delete the forward character, type @b{^D} @i(delete-next-character)
  463. X@index(delete-next-character).  The "F" of "Fang" disappears.  Continue
  464. Xto type @b{^D} until the whole word is erased EMACS also permits the
  465. Xdeletion of larger elements of text.  Move the cursor to the word
  466. X"center" in the first line of text.  Pressing @b{M-<backspace>}
  467. X@i(delete-previous-word) @index(delete-previous-word) kills the word
  468. Ximmediately before the cursor.  @b{M-^H} has the same effect. 
  469. X
  470. XNotice that the commands are very similar to the control commands you
  471. Xused to delete individual letters.  As a general rule in EMACS, control
  472. Xsequences affect small areas of text, META sequences larger areas.  The
  473. Xword forward of the cursor position can therefore be deleted by typing
  474. X@b{M-D} @i(delete-next-word) @index(delete-next-word).  Now let's take
  475. Xout the remainder of the first line by typing @b{^K}
  476. X@i(kill-to-end-of-line) @index(kill-to-end-of-line).  You now have a
  477. Xblank line at the top of your screen.  Typing @b{^K} again or @b{^X-^O}
  478. X@i(delete-blank-lines) @index(delete-blank-lines) deletes the blank line
  479. Xand flushes the second line to the top of the text.  Now exit EMACS by
  480. Xtyping @b{^X-^C} @i(exit-emacs) @index(exit-emacs).  Notice EMACS
  481. Xreminds you that you have not saved your buffer.  Ignore the warning and
  482. Xexit.  This way you can exit EMACS without saving any of the changes you
  483. Xjust made. 
  484. X
  485. X@heading(Chapter @value(chapter) Summary)
  486. X
  487. XIn Chapter @value(chapter), you learned about the basic 'building
  488. Xblocks' of an EMACS text file--buffers, windows, and files. 
  489. X
  490. X@begin{verbatim}
  491. X@u(Key binding        Keystroke    Effect)
  492. Xdelete-previous-character
  493. X            @b{^H}        deletes character immediately before
  494. X                    the current cursor position
  495. X
  496. Xdelete-next-character    @b{^D}        deletes character immediately after     
  497. X                    current cursor position
  498. X
  499. Xdelete-previous-word    @b{M-^H}    deletes word immediately before
  500. X                    current cursor position
  501. X
  502. Xdelete-next-word    @b{M-D}        deletes word immediately after
  503. X                    current cursor position
  504. X
  505. Xkill-to-end-of-line    @b<^K>        deletes from current cursor
  506. X                    position to end of line
  507. X
  508. Xinsert-space        @b<^C>        inserts a space to right of cursor
  509. X
  510. Xopen-line        @b{^O}        inserts blank line
  511. X
  512. Xdelete-blank-lines    @b{^X-^O}    removes blank line
  513. X
  514. Xexit-emacs        @b{^X-^C}    exits emacs
  515. X@end(verbatim)
  516. X@chapter(Using Regions)
  517. X
  518. X@section(Defining and Deleting a Region)
  519. X
  520. XAt this point its time to familiarize ourselves with two more EMACS
  521. Xterms--the @b<point> and the @b<mark>.  The point is located directly
  522. X@index(point) @index(mark) behind the current cursor position.  The mark
  523. X(as we shall see shortly) is user defined.  These two elements together
  524. Xare called the current @b(region) and limit the @b<region> of text on
  525. Xwhich EMACS performs many of its editing functions. 
  526. X
  527. XLet's begin by entering some new text.  Don't forget to add @b(wrap)
  528. Xmode if its not set on this buffer.  Start EMACS and open a file called
  529. X@b{PUBLISH.TXT}.  Type in the following text:
  530. X
  531. X@quotation{One of the largest growth areas in personal computing is
  532. Xelectronic publishing.  There are packages available for practically
  533. Xevery machine from elegantly simple programs for the humble Commodore 64
  534. Xto sophisticated professional packages for PC and Macintosh computers. 
  535. X
  536. XElectronic publishing is as revolutionary in its way as the Gutenburg
  537. Xpress.  Whereas the printing press allowed the mass production and
  538. Xdistribution of the written word, electronic publishing puts the means
  539. Xof production in the hands of nearly every individual.  From the class
  540. Xmagazine to the corporate report, electronic publishing is changing the
  541. Xway we produce and disseminate information. 
  542. X
  543. XPersonal publishing greatly increases the utility of practically every
  544. Xcomputer.  Thousands of people who joined the computer revolution of
  545. Xthis decade only to hide their machines unused in closets have
  546. Xdiscovered a new use for them as dedicated publishing workstations.}
  547. X
  548. XNow let's do some editing.  The last paragraph seems a little out of
  549. Xplace.  To see what the document looks like without it we can cut it
  550. Xfrom the text by moving the cursor to the beginning of the paragraph. 
  551. XEnter @b(M-<space>) @i(set-mark) @index(set-mark).  EMACS will respond
  552. Xwith "[Mark set]".  Now move the cursor to the end of the paragraph. 
  553. XYou have just defined a region of text.  To remove this text from the
  554. Xscreen, type @b<^W> @i(kill-region) @index(kill-region).  The paragraph
  555. Xdisappears from the screen. 
  556. X
  557. XOn further consideration, however, perhaps the paragraph we cut wasn't
  558. Xso bad after all.  The problem may have been one of placement.  If we
  559. Xcould tack it on to the end of the first paragraph it might work quite
  560. Xwell to support and strengthen the argument.  Move the cursor to the end
  561. Xof the first paragraph and enter @b<^Y> @i(yank) @index(yank).  Your
  562. Xtext should now look like this:
  563. X
  564. X@quotation{One of the largest growth areas in personal computing is
  565. Xelectronic publishing.  There are packages available for practically
  566. Xevery machine from elegantly simple programs for the humble Commodore 64
  567. Xto sophisticated professional packages for PC and Macintosh computers. 
  568. XPersonal publishing greatly increases the utility of practically every
  569. Xcomputer.  Thousands of people who joined the computer revolution of
  570. Xthis decade only to hide their machines unused in closets have
  571. Xdiscovered a new use for them as dedicated publishing workstations. 
  572. X
  573. XElectronic publishing is as revolutionary in its way as the Gutenburg
  574. Xpress.  Whereas the printing press allowed the mass production and
  575. Xdistribution of the written word, electronic publishing puts the means
  576. Xof production in the hands of nearly every individual.    From the class
  577. Xmagazine to the corporate report, electronic publishing is changing the
  578. Xway we produce and disseminate information.}
  579. X
  580. X@section(Yanking a Region)
  581. X
  582. XThe text you cut initially didn't simply just disappear, it was cut into
  583. Xa buffer that retains the 'killed' text appropriately called the @b<kill
  584. Xbuffer>.  @b<^Y> "yanks" the text back from this buffer into the current
  585. Xbuffer. If you have a long line (indicated, remember, by the "$"
  586. Xsign), simply hit @b{M-Q} to reformat the paragraph. 
  587. X
  588. XThere are other uses to which the kill buffer can be put.  Using the
  589. X@index(kill buffer) method we've already learned, define the last
  590. Xparagraph as a region.  Now type @b<M-W> @i(copy-region)
  591. X@index(copy-region).  Nothing seems to have happened; the cursor stays
  592. Xblinking at the point.  But things have changed, even though you may not
  593. Xbe able to see any alteration. 
  594. X
  595. XTo see what has happened to the contents of the kill buffer, move the
  596. Xcursor down a couple of lines and "yank" the contents of the kill buffer
  597. Xback with @b<^Y>.  Notice the last paragraph is now repeated.  The
  598. Xregion you defined is "tacked on" to the end of your file because
  599. X@b<M-W> @b<copies> a region to the kill buffer while leaving the
  600. Xoriginal text in your working buffer.  Some caution is needed however,
  601. Xbecause the contents of the kill buffer are updated when you delete any
  602. Xregions, lines or words.  If you are moving large quantities of text,
  603. Xcomplete the operation before you do any more deletions or you could
  604. Xfind that the text you want to move has been replaced by the most recent
  605. Xdeletion.  Remember--a buffer is a temporary area of computer memory
  606. Xthat is lost when the machine is powered down or switched off.  In order
  607. Xto make your changes permanent, they must be saved to a file before you
  608. Xleave EMACS.  Let's delete the section of text we just added and save
  609. Xthe file to disk. 
  610. X
  611. X@heading(Chapter @value(chapter) Summary)
  612. X
  613. XIn Chapter @value(chapter), you learned how to achieve longer insertions
  614. Xand deletions.  The EMACS terms @b<point> and @b<mark> were introduced
  615. Xand you learned how to manipulate text with the kill buffer. 
  616. X
  617. X@begin{verbatim}
  618. X@begin(group)
  619. X@u(Key Binding    Keystroke    Effect)
  620. X
  621. XDelete-Region    @b{^W}        Deletes region between point and mark and
  622. X                places it in KILL buffer
  623. X
  624. XCopy-Region    @b{M-W}        Copies text between point and mark into
  625. X                KILL buffer
  626. X
  627. XYank-Text    @b{^Y}        Inserts a copy of the KILL buffer into
  628. X                current buffer at point
  629. X@end(group)
  630. X@end(verbatim)
  631. X@chapter(Search and Replace)
  632. X
  633. X@section<Forward Search>
  634. X
  635. XLoad EMACS and bring in the file you just saved.  Your file should look
  636. Xlike the one below.
  637. X
  638. X@quotation{One of the largest growth areas in personal computing is electronic
  639. Xpublishing.  There are packages available for practically every machine
  640. Xfrom elegantly simple programs for the humble Commodore 64 to
  641. Xsophisticated professional packages for PC and Macintosh computers. 
  642. XPersonal publishing greatly increases the utility of practically every
  643. Xcomputer.  Thousands of people who joined the computer revolution of
  644. Xthis decade only to hide their machines unused in closets have
  645. Xdiscovered a new use for them as dedicated publishing workstations. 
  646. X
  647. XElectronic publishing is as revolutionary in its way as the Gutenburg
  648. Xpress.  Whereas the printing press allowed the mass production and
  649. Xdistribution of the written word, electronic publishing puts the means
  650. Xof production in the hands of nearly every individual.    From the class
  651. Xmagazine to the corporate report, electronic publishing is changing the
  652. Xway we produce and disseminate information.}
  653. X
  654. XLet's use EMACS to search for the word "revolutionary" in the second
  655. Xparagraph.  Because EMACS searches from the current cursor position
  656. Xtoward the end of buffers, and we intend to search forward, move the
  657. Xcursor to the beginning of the text.  Enter @b<^S> @i(search-forward)
  658. X@index(search-forward).  Note that the command line now reads
  659. X
  660. X"Search [] <META>:" 
  661. X
  662. XEMACS is prompting you to enter the @b<search string> -- the text you
  663. Xwant to find.  Enter the word @b<revolutionary> and hit the @b<META>
  664. Xkey.  The cursor moves to the end of the word "revolutionary."
  665. X
  666. XNotice that you must enter the <META> key to start the search.  If you
  667. X@index(<NL>) simply press <NL> the command line responds with "<NL>". 
  668. XAlthough this may seem infuriating to users who are used to pressing the
  669. Xreturn key to execute any command, EMACS' use of <META> to begin
  670. Xsearches allows it to pinpoint text with great accuracy.  After every
  671. Xline wrap or carriage return, EMACS 'sees' a new line character (<NL>). 
  672. XIf you need to search for a word at the end of a line, you can specify
  673. Xthis word uniquely in EMACS. 
  674. X
  675. XIn our sample text for example, the word "and" occurs a number of times,
  676. Xbut only once at the end of a line.  To search for this particular
  677. Xoccurence of the word, move the cursor to the beginning of the buffer
  678. Xand type @b(^S).  Notice that EMACS stores the last specified
  679. X@index(default string) search string as the @b<default> string.  If you
  680. Xpress @b{<META>} now, EMACS will search for the default string, in this
  681. Xcase, "revolutionary."
  682. X
  683. XTo change this string so we can search for our specified "and" simply
  684. Xenter the word @b{and} followed by @b{<NL>}.  The command
  685. Xline now shows:
  686. X
  687. X"search [and<NL>]<META>:"
  688. X
  689. XPress @b{<META>} and the cursor moves to "and" at the end of the second
  690. Xlast line.
  691. X
  692. X@section<Exact Searches>
  693. X
  694. XIf the mode EXACT is active in the current buffer, EMACS searches on a case
  695. Xsensitive basis.  Thus, for example you could search for @b{Publishing}
  696. Xas distinct from @b{publishing}. 
  697. X
  698. X
  699. X@section<Backward Search>
  700. X
  701. XBackward searching is very similar to forward searching except that it
  702. Xis implemented in the reverse direction.  To implement a reverse search,
  703. Xtype @b{^R} @i(search-reverse) @index(search-reverse).  Because EMACS
  704. Xmakes no distinction between forward and backward stored search strings,
  705. Xthe last search item you entered appears as the default string.  Try
  706. Xsearching back for any word that lies between the cursor and the
  707. Xbeginning of the buffer.  Notice that when the item is found, the point
  708. Xmoves to the beginning of the found string (i.e., the cursor appears
  709. Xunder the first letter of the search item). 
  710. X
  711. XPractice searching for other words in your text.
  712. X
  713. X@section<Searching and Replacing>
  714. X
  715. XSearching and replacing is a powerful and quick way of making changes to
  716. Xyour text.  Our sample text is about electronic publishing, but the
  717. Xcorrect term is 'desktop' publishing.  To make the necessary changes we
  718. Xneed to replace all occurences of the word "electronic" with "desktop."
  719. XFirst, move the cursor to the top of the current buffer with the @b(M-<)
  720. Xcommand.  Then type @b[M-R] @i(replace-string) @index(replace-string). 
  721. XThe command line responds:
  722. X
  723. X"Replace []<META>:"
  724. X
  725. Xwhere the square brackets enclose the default string.  Type the word
  726. X@b<electronic> and hit @b{<META>}.  The command line responds:
  727. X
  728. X"with []<META>"
  729. X
  730. Xtype @b{desktop<META>}.  EMACS replaces all instances of the original
  731. Xword with your revision.  Of course, you will have to capitalize the
  732. Xfirst letter of "desktop" where it occurs at the beginning of a
  733. Xsentence.
  734. X
  735. XYou have just completed an @b<unconditional replace>.  In this
  736. Xoperation, EMACS replaces every instance of the found string with the
  737. Xreplacement string. 
  738. X     
  739. X@section<Query-Replace>
  740. X
  741. XYou may also replace text on a case by case basis.  The @b{M-^R}
  742. X@i(query-replace-string) @index(query-replace-string) command causes
  743. XEMACS to pause at each instance of the found string. 
  744. X
  745. XFor example, assume we want to replace some instances of the word
  746. X"desktop" with the word "personal." Go back to the beginning of the
  747. Xcurrent buffer and enter the @b(M-^R) @i(query-replace)
  748. X@index(query-replace) command.  The procedure is very similar to that
  749. Xwhich you followed in the unconditional search/replace option.  When the
  750. Xsearch begins however, you will notice that EMACS pauses at each
  751. Xinstance of "publishing" and asks whether you wish to replace it with
  752. Xthe replacement string.  You have a number of options available for
  753. Xresponse:
  754. X
  755. X@begin(verbatim)
  756. X@u(    Response    Effect)
  757. X    Y(es)    Make the current replacement and skip to the next
  758. X        occurence of the search string
  759. X
  760. X    N(o)    Do not make this replacement but continue
  761. X
  762. X    !    Do the rest of the replacements with no more queries
  763. X
  764. X    U(ndo)    Undo just the last replacement and query for it
  765. X        again (This can only go back ONE time)
  766. X
  767. X    ^G    Abort the replacement command (This action does not
  768. X        undo previously-authorized replacements
  769. X
  770. X    .    Same effect as ^G, but cursor returns to the point at
  771. X        which the replacement command was given
  772. X
  773. X    ?    This lists help for the query replacement command
  774. X@end(verbatim)
  775. X
  776. XPractice searching and searching and replacing until you feel
  777. Xcomfortable with the commands and their effects.
  778. X@begin(group)
  779. X@heading(Chapter @value(chapter) Summary)
  780. X
  781. XIn this chapter, you learned how to search for specified strings of text
  782. Xin EMACS.  The chapter also dealt with searching for and replacing
  783. Xelements within a buffer. 
  784. X
  785. X@begin(verbatim)
  786. X@u(Key Binding        Keystroke             Effect)
  787. X
  788. XSearch-Forward        @b{^S}    Searches from point to end of buffer.
  789. X                Point is moved from current location to
  790. X                the end of the found string
  791. X
  792. XSearch-Backward        @b{^R}    Searches from point to beginning of buffer. 
  793. X                Point is moved from current location to
  794. X                beginning of found string
  795. X
  796. XReplace            @b{M-R} Replace ALL ocurrences of search string with 
  797. X                specified (null) string from point to the
  798. X                end of the current buffer
  799. X
  800. XQuery-Replace           @b{M-^R}    As above, but pause at each found string
  801. X                and query for action
  802. X@end(verbatim)
  803. X@end(group)
  804. X@chapter(Windows)
  805. X
  806. X@section<Creating Windows>@index{Windows, Creating}
  807. X
  808. XWe have already met windows in an earlier chapter.  In this chapter, we
  809. Xwill explore one of EMACS' more powerful features -- text manipulation
  810. Xthrough multiple windowing.  Windows offer you a powerful and easy way
  811. Xto edit text.  By manipulating a number of windows and buffers on the
  812. Xscreen simultaneously, you can perform complete edits and revisions on
  813. Xthe computer screen while having your draft text or original data
  814. Xavailable for reference in another window. 
  815. X
  816. XYou will recall that windows are areas of buffer text that you can see
  817. X@index(windows) on the screen.  Because EMACS can support several screen
  818. Xwindows simultaneously you can use them to look into different places in
  819. Xthe same buffer.  You can also use them to look at text in different
  820. Xbuffers.  In effect, you can edit several files at the same time. 
  821. X
  822. XLet's invoke EMACS and pull back our file on desktop publishing by
  823. Xtyping
  824. X
  825. X@quotation<emacs publish.txt>
  826. X
  827. XWhen the text appears, type the @b{^X-2} @i(split-window)
  828. X@index{split-window} command.  The window splits into two windows.  The
  829. Xwindow where the cursor resides is called the @b<current> window -- in
  830. Xthis case the bottom window.  Notice that each window has a text area
  831. Xand a mode line.  The @b(command line) @index{command line} is however,
  832. Xcommon to all windows on the screen. 
  833. X
  834. XThe two windows on your screen are virtually mirror images of each other
  835. Xbecause the new window is opened into the same buffer as the one you are
  836. Xin when you issue the @i{open-window command} @index{open-window}.  All
  837. Xcommands issued to EMACS are executed on the current buffer in the
  838. Xcurrent window. 
  839. X
  840. XTo move the cursor to the upper window (i.e., to make that window the
  841. Xcurrent window, type @b{^X-P} @i(previous-window) @index{previous-window}.  
  842. XNotice the cursor
  843. Xmoves to the upper or @b<previous> window.  Entering @b{^X-O}
  844. X@i(next-window) moves to the @b{next} window.  Practice moving between
  845. Xwindows.  You will notice that you can also move into the Function Key
  846. Xmenu by entering these commands. 
  847. X
  848. XNow move to the upper window.  Let's open a new file.  On the EMACS disk
  849. Xis a tutorial file.  Let's call it into the upper window by typing:
  850. X
  851. X@quotation<^X-^F>
  852. X
  853. Xand press return.
  854. X
  855. XEnter the filename @b<emacs.tut>.
  856. X
  857. XIn a short time, the tutorial file will appear in the window.  We now have
  858. Xtwo windows on the screen, each looking into different buffers.  We have
  859. Xjust used the @b(^X-^F) @i(find-file) @index{find-file}
  860. Xcommand to find a file and bring
  861. Xit into our current window.
  862. X
  863. XYou can scroll any window up and down with the cursor keys, or with the
  864. Xcommands we've learned so far.    However, because the area of visible
  865. Xtext in each window is relatively small, you can scroll the current
  866. Xwindow a line at a time.  
  867. X
  868. XType @b{^X-^N} @i(move-window-down)@index{move-window-down}
  869. X
  870. XThe current window scrolls down by one line -- the top line of text
  871. Xscrolls out of view, and the bottom line moves towards the top of the
  872. Xscreen.  You can imagine, if you like, the whole window slowly moving
  873. Xdown to the end of the buffer in increments of one line.  The command
  874. X@b{^X-^P} @i(move-window-up)@index{move-window-up} 
  875. Xscrolls the window in the opposite
  876. Xdirection. 
  877. X
  878. XAs we have seen, EMACS editing commands are executed in the current
  879. Xwindow, but the program does support a useful feature that allows you to
  880. Xscroll the @b<next> window.  
  881. X@b<M-^Z> @i(scroll-next-up)@index{scroll-next-up}
  882. Xscrolls the next
  883. Xwindow up, @b{M-^V} @i(scroll-next-down)@index{scroll-next-down} 
  884. Xscrolls it downward.  From the
  885. Xtutorial window, practice scrolling the window with the desktop
  886. Xpublishing text in it up and down. 
  887. X
  888. XWhen you're finished, exit EMACS without saving any changes in your
  889. Xfiles. 
  890. X
  891. X
  892. XExperiment with splitting the windows on your screen.  Open windows into
  893. Xdifferent buffers and experiment with any other files you may have.  Try
  894. Xediting the text in each window, but
  895. Xdon't forget to save any changes you want to keep -- you still have to
  896. Xsave each buffer separately.
  897. X
  898. X@section(Deleting Windows)@index{Windows, Deleting}
  899. XWindows allow you to perform complex editing tasks with ease.  However,
  900. Xthey become an inconvenience when your screen is cluttered with open
  901. Xwindows you have finished using.  The simplest solution is to delete
  902. Xunneeded windows.  The command @b{^X-0} @i{delete-window}
  903. Xwill delete the window you are currently working in and move you to the
  904. Xnext window.
  905. X
  906. XIf you have a number of windows open, you can delete all but the current
  907. Xwindow by entering @b{^X-1} @i{delete-other-windows}.
  908. X
  909. X@section(Resizing Windows)@index{Windows, Resizing} 
  910. X
  911. XDuring complex editing tasks, you will probably find it convenient to
  912. Xhave a number of windows on the screen simultaneously.  However this
  913. Xsituation may present inconveniences because the more windows you have
  914. Xon the screen the smaller they are; in some cases, a window may show
  915. Xonly a couple of lines of text.  To increase the flexibility and utility
  916. Xof the window environment, EMACS allows you to resize the window you are
  917. Xworking in (called, as you will recall, the @b<current> window) to a
  918. Xconvenient size for easier editing, and then shrink it when you no
  919. Xlonger need it to be so large. 
  920. X
  921. XLet's try an example.  Load in any EMACS text file and split the current
  922. Xwindow into two.  Now type @b{^X-^(Shift-6)},
  923. X@i{grow-window}@index{grow-window}.  Your current window should be
  924. Xthe lower one on the screen.  Notice that it increases in size upwards
  925. Xby one line.  If you are in the upper window, it increases in size in a
  926. Xdownward direction.  The command @b{^X-^Z},
  927. X@i{shrink-window}@index{shrink-window} correspondingly decreases window
  928. Xsize by one line at a time. 
  929. X
  930. XEMACS also allows you to resize a window more precisely by entering a
  931. Xnumeric argument specifying the size of the window in lines.  To resize
  932. Xthe window this way, press the META key and enter a numeric argument
  933. X(remember to keep it smaller than the number of lines on your screen
  934. Xdisplay) then press @b{^X-W} @i{resize-window}@index{resize-window}. 
  935. XThe current window will be enlarged or shrunk to the number of lines
  936. Xspecified in the numeric argument.  For example entering:
  937. X
  938. X@quotation{@b[M-8 ^X-W]}will resize the current window to 8 lines.
  939. X
  940. X@section(Repositioning within a Window)
  941. X
  942. XThe cursor may be centered within a window by entering @b{M-! or M-^L}
  943. X@i{redraw-display} @index{redraw-display}.  This command is especially
  944. Xuseful in allowing you to quickly locate the cursor if you are moving
  945. Xfrequently from window to window.  You can also use this command to move
  946. Xthe line containing the cursor to any position within the current
  947. Xwindow.  This is done by using a numeric argument before the command.
  948. XType @b(M-<n> M-^L) where <n> is the number of the line within the
  949. Xwindow that you wish the current line to be displayed.
  950. X
  951. XThe @b{^L} @i{Refresh-screen} @index{refresh-screen} command is useful
  952. Xfor 'cleaning up' a 'messy' screen that can result of using EMACS on a
  953. Xmainframe system and being interupted by a system message. 
  954. X@newpage
  955. X@u<Chapter @value(chapter) summary>
  956. X
  957. XIn Chapter @value(chapter) you learned how to manipulate windows and the
  958. Xediting flexibility they offer. 
  959. X
  960. X@begin(verbatim)
  961. X@u(Key Binding    Keystroke    Effect)
  962. X
  963. XOpen-Window    @b{^X-2}    Splits current window into two windows if
  964. X                space available
  965. X
  966. XClose-Windows    @b{^X-1}    Closes all windows except current window
  967. X
  968. XNext-Window    @b{^X-O}[oh]    Moves point into next (i.e. downward) window
  969. X
  970. XPrevious-Window @b{^XP}        Moves point to previous (i.e. upward) window
  971. X
  972. XMove-Window-Down @b{^X-^N}    Scrolls current window down one line
  973. X
  974. XMove-Window-Up    @b{^X-^P}    Scrolls current window up one line
  975. X
  976. XRedraw-display    @b{M !} or    Window is moved so line with point
  977. X        @b{M ^L}    (with cursor) is at center of window
  978. X
  979. XGrow-Window    @b{M-X ^} or    Current window is enlarged by one
  980. X        @b{M ^L}    line and nearest window is shrunk by 
  981. X                one line
  982. X
  983. XShrink-Window    @b{^X-^Z}    Current window is shrunk by one line
  984. X                and nearest window is enlarged by one line
  985. X
  986. XClear-and-redraw @b{^L}        Screen is blanked and redrawn.  Keeps
  987. X                screen updates in sync with your commands
  988. X
  989. XScroll-Next-Up    @b{M-^Z}    Scrolls next window up by one line
  990. X
  991. XScroll-Next-Down @b{M-^V}    Scrolls next window down by one line
  992. X
  993. XDelete-Window    @b{^X-0}    Deletes current window
  994. X
  995. XDelete-Other-Windows @b{^X-1}    Deletes all but current window
  996. X
  997. XResize-Window    @b{^X-^W}    Resizes window to a given numeric argument
  998. X@end(verbatim)
  999. X@chapter(Buffers)
  1000. X
  1001. X@index(buffer) We have already learned a number of things about buffers. 
  1002. XAs you will recall, they are the major internal entities in EMACS -- the
  1003. Xplace where editing commands are executed.  They are characterized by
  1004. Xtheir @b<names>, their @b<modes>, and by the file with which they are
  1005. Xassociated.  Each buffer also "remembers" its @b(mark) and @b(point). 
  1006. XThis convenient feature allows you to go to other buffers and return to
  1007. Xthe original location in the "current" buffer. 
  1008. X
  1009. XAdvanced users of EMACS frequently have a number of buffers in the
  1010. Xcomputer's memory simultaneously.  In the last chapter, for example, you
  1011. Xopened at least two buffers -- one into the text you were editing, and
  1012. Xthe other into the EMACS on-line tutorial.  If you deal with complex
  1013. Xtext files -- say, sectioned chapters of a book, you may have five or
  1014. Xsix buffers in the computer's memory.  You could select different
  1015. Xbuffers by simply calling up the file with @b{^X-^F} @i(find-file)
  1016. X@index(find-file), and let EMACS open or reopen the buffer.  However,
  1017. XEMACS offers fast and sophisticated buffering techniques that you will
  1018. Xfind easy to master and much more convenient to use. 
  1019. X
  1020. XLet's begin by opening three buffers.  You can open any three you
  1021. Xchoose, for example call the following files into memory: @b(fang.txt),
  1022. X@b(publish.txt), and @b(emacs.tut) in the order listed here.  When
  1023. Xyou've finished this process, you'll be looking at a screen showing the
  1024. XEMACS tutorial.  Let's assume that you want to move to the fang.txt
  1025. Xbuffer.  Enter:
  1026. X
  1027. X@b{^X-X} @i(next-buffer) @index(next-buffer)
  1028. X
  1029. XThis command moves you to the @u<next> buffer.  Because EMACS cycles
  1030. Xthrough the buffer list, which is alphabetized, you will now be in the
  1031. X@b(fang.txt) buffer. Using @b(^X-X) again places you in the
  1032. X@b(publish.txt) buffer. @i(If you are on a machine that supports
  1033. Xfunction keys, using @b[^X-X] again places you in the @b(Function Keys)
  1034. Xbuffer). Using @b(^X-X) one last time cycles you back to the beginning
  1035. Xof the list.
  1036. X
  1037. XIf you have a large number of buffers to deal with, this cycling process
  1038. Xmay be slow and inconvenient.  The command @b{^X-B} @i(select-buffer)
  1039. X@index(select-buffer) allows you to specify the buffer you wish to be
  1040. Xswitched to.  When the command is entered, EMACS prompts, "Use buffer:". 
  1041. XSimply enter the buffer name (NOT the file name), and that buffer will
  1042. Xthen become the current buffer. 
  1043. X
  1044. XMultiple buffer manipulation and editing is a complex activity, and you
  1045. Xwill probably find it very inconvenient to re-save each buffer as you
  1046. Xmodify it.  The command @b{^X-^B} @i(list-buffers) @index(list-buffers)
  1047. Xcreates a new window that gives details about all the buffers currently
  1048. Xknown to EMACS.  Buffers that have been modified are identified by the
  1049. X"buffer changed" indicator (an asterisk in the second column).  You can
  1050. Xthus quickly and easily identify buffers that need to be saved to files
  1051. Xbefore you exit EMACS.  The buffer window also provides other
  1052. Xinformation -- buffer specific modes, buffer size, and buffer name are
  1053. Xalso listed.  To close this window, simply type the close-windows
  1054. Xcommand, @b{^X-1}. 
  1055. X
  1056. XTo delete any buffer, type @b{^X-K} @i(delete-buffer)
  1057. X@index(delete-buffer).  EMACS prompts you "Kill buffer:".  Enter the
  1058. Xbuffer name you want to delete.  As this is destructive command, EMACS
  1059. Xwill ask for confirmation if the buffer was changed and not saved. 
  1060. XAnswer Y(es) or N(o).  As usual @b{^G} cancels the command. 
  1061. X
  1062. X@newpage
  1063. X@heading(Chapter @value(chapter) Summary)
  1064. X
  1065. XIn Chapter @value(chapter) you learned how to manipulate buffers. 
  1066. X
  1067. X@begin{verbatim}
  1068. X@u(Key Binding        Keystroke               Effect)
  1069. XNext-Buffer        @b(^X-^X)    Switch to the next buffer in the
  1070. X                    buffer list
  1071. X
  1072. XSelect-Buffer        @b(^X-B)    Switch to a particular buffer
  1073. X
  1074. XList-Buffers        @b(^X-^B)    List all buffers
  1075. X
  1076. XDelete-Buffer        @b(^X-K)    delete a particular buffer if it
  1077. X                    is off-screen
  1078. X@end(verbatim)
  1079. X@chapter(Modes)
  1080. X
  1081. X    EMACS allows you to change the way it works in order to
  1082. Xcustomized it to the style of editing you are using.  It does this by
  1083. Xproviding a number of different @b(modes) @index(modes).  These modes
  1084. Xcan effect either a single buffer, or any new buffer that is created. 
  1085. XTo add a mode to the current buffer, type @b(^X-M) @i(add-mode)
  1086. X@index(add-mode).  EMACS will then prompt you for the name of a mode to
  1087. Xadd.  When you type in a legal mode name, and type a <NL>, EMACS will
  1088. Xadd the mode name to the list of current mode names in the modeline of
  1089. Xthe current buffer. 
  1090. X
  1091. X    To remove an existing mode, typing the @b(^X-^M) @i(delete-mode)
  1092. X@index(delete-mode) will cause EMACS to prompt you for the name of a
  1093. Xmode to delete from the current buffer.  This will remove that mode from
  1094. Xthe mode list on the current modeline.
  1095. X
  1096. X    Global modes are the modes which are inherited by any new
  1097. Xbuffers which are created.  For example, if you wish to always do string
  1098. Xsearching with character case being significant, you would want global
  1099. Xmode EXACT to be set so that any new files read in inherent the EXACT
  1100. Xmode.  Global modes are set with the @b(M-M) @i(add-global-mode)
  1101. X@index(add-global-mode) command, and unset with the @b(M-^M)
  1102. X@i(delete-global-mode) @index(delete-global-mode) command.  Also, the
  1103. Xcurrent global modes are displayed in the first line of a
  1104. X@b(^X-^B) @i(list-buffers) @index(list-buffers) command.
  1105. X
  1106. X    On machines which are capable of displaying colors,
  1107. X@index(color) the mode commands can also set the background and
  1108. Xforeground character colors.  Using @i(add-mode) or @i(delete-mode) with
  1109. Xa lowercase color will set the background color in the current window. 
  1110. XAn uppercase color will set the foreground color in the current window. 
  1111. XColors that EMACS knows about are: white, cyan, magenta, yellow, blue,
  1112. Xred, green, and black.  If the computer you are running on does not have
  1113. Xeight colors, EMACS will attempt to make some intelligent guess at what
  1114. Xcolor to use when you ask for one which is not there. 
  1115. X
  1116. X@section(ASAVE mode)@index(ASAVE mode)
  1117. X
  1118. X    Automatic Save mode tells EMACS to automatically write out the
  1119. Xcurrent buffer to its associated file on a regular basis.  Normally this
  1120. Xwill be every 256 characters typed into the file.  The environment
  1121. Xvariable $ACOUNT counts down to the next auto-save, and $ASAVE is the
  1122.