home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume4 / uemacs3.6 / part2 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  39.0 KB

  1. Subject: MicroEMACS 3.6 (Part 2 of 8)
  2. Newsgroups: mod.sources
  3. Approved: jpn@panda.UUCP
  4.  
  5. Mod.sources:  Volume 4, Issue 99
  6. Submitted by: genrad!decvax!ihnp4!itivax!duncan!lawrence
  7.  
  8. echo x - emacs.tut
  9. sed 's/^X//' >emacs.tut <<'*-*-END-of-emacs.tut-*-*'
  10. XYou are looking at the MICRO-EMACS tutorial.  Comments on this document
  11. Xmay be refered to Dana Hoggatt or Dan Lawrance.
  12. X
  13. XEMACS commands generally involve the CONTROL key (sometimes labelled CTRL or 
  14. XCTL) or the META key (generally labelled ESCAPE).  Rather than write out META 
  15. Xor CONTROL each time we want you to prefix a character, we'll use the following
  16. Xabbreviations:
  17. X
  18. X   ^<chr>   means hold the CONTROL key while typing the character <chr>
  19. X            Thus, ^F would be: hold the CONTROL key and type F.
  20. X
  21. X   ESC-<chr>  means type the ESCAPE key and release it, then type the 
  22. X              character <chr>.  The <chr> can be upper or lower case 
  23. X              and it will have the same meaning.
  24. X
  25. XImportant note: if you must exit at some point, type ^X ^C.  
  26. X
  27. XThis tutorial attempts to help you "learn by doing".  The characters ">>" 
  28. Xat the left margin of your screen indicate directions for you to try using 
  29. Xa command.  For instance:
  30. X
  31. X>>  Now type ^V (View next screen) to move to the next screen.
  32. X    (go ahead, do it by depressing the control key and V together).
  33. X
  34. XFrom now on, you'll be expected to type ^V whenever you finish reading the 
  35. Xcurrent screen.
  36. X
  37. XNote that there is an overlap when going from screen to screen; this
  38. Xprovides some continuity when moving through the file.
  39. X
  40. XThe first thing that you need to know is how to move around from place to 
  41. Xplace in the file.  You already know how to move forward a screen, with ^V.  
  42. XTo move backwards a screen, type ^Z. (depress the CTRL key and type Z).
  43. X
  44. X>>  Try typing ^Z and then ^V to move back and forth a few times.
  45. X
  46. X
  47. XSUMMARY
  48. X-------
  49. X
  50. XThe following commands are useful for viewing screenfuls:
  51. X
  52. X     ^V      Move forward one screenful
  53. X     ^Z      Move backward one screenful
  54. X     <ESC>^L Clear screen and redisplay everything
  55. X             putting the text near the cursor at the center.
  56. X
  57. X>> find the cursor and remember what text is near it.
  58. X   Then type a <ESC>^L.
  59. X   Find the cursor again and see what text is near it now.
  60. X
  61. X
  62. XBASIC CURSOR CONTROL
  63. X--------------------
  64. X
  65. XGetting from screenful to screenful is useful, but how do you reposition 
  66. Xyourself within a given screen to a specific place?  There are several ways 
  67. Xyou can do this.  One way (not the best, but the most basic) is to use the 
  68. Xcommands previous, backward, forward and next.  As you can imagine these 
  69. Xcommands (which are given to EMACS as ^P, ^B, ^F, and ^N  respectively) move 
  70. Xthe cursor from where it currently is to a new place in the given direction.  
  71. XHere, in a more graphical form are the commands:
  72. X                          Previous line, ^P
  73. X                                  :
  74. X                                  :
  75. X   Backward, ^B .... Current cursor position .... Forward, ^F
  76. X                                  :
  77. X                                  :
  78. X                          Next line, ^N
  79. X
  80. XYou'll probably find it easy to think of these by letter.  P for
  81. Xprevious, N for next, B for backward and F for forward.  These are
  82. Xthe basic cursor positioning commands and you'll be using them ALL
  83. Xthe time so it would be of great benefit if you learn them now.
  84. X
  85. X>> Do a few ^N's to bring the cursor down to this line.
  86. X
  87. X>> Move into the line with ^F's and then up with several ^P's.
  88. X   See what ^P does when the cursor is in the middle of the line.
  89. X
  90. XLines are separated by a single Linefeed character, which is what
  91. XUnix calls a Newline.
  92. X
  93. X>> Try to ^B at the beginning of a line.  Do a few more ^B's.
  94. X   Then do ^F's back to the end of the line and beyond.
  95. X
  96. XWhen you go off the top or bottom of the screen, the text beyond
  97. Xthe edge is shifted onto the screen so that your instructions can
  98. Xbe carried out while keeping the cursor on the screen.
  99. X
  100. X>> Try to move the cursor off the bottom of the screen with ^N and
  101. X   see what happens.
  102. X
  103. XIf moving by characters is too slow, you can move by words.  ESC-F
  104. X(Meta-F) moves forward a word and ESC-B moves back a word.
  105. X
  106. X>> Type a few ESC-F's and ESC-B's.  Intersperse them with ^F's and ^B's.
  107. X
  108. XNotice the parallel between ^F and ^B on the one hand, and ESC-F and ESC-B on 
  109. Xthe other hand.  Very often Meta characters are used for operations related 
  110. Xto English text whereas Control characters operate on the basic textual units 
  111. Xthat are independent of what you are editing (characters, lines, etc).  There 
  112. Xis a similar parallel between lines and sentences: ^A and ^E move to the 
  113. Xbeginning or end of a line. and ESC-A and ESC-E move to the beginning or end 
  114. Xof a sentence.
  115. X
  116. X###  Note:  ESC-A and ESC-E are not implimented yet (DLH - 1/22/86)  ###
  117. X
  118. X>> Try a couple of ^A's, and then a couple of ^E's.
  119. X   Try a couple of ESC-A's, and then a couple of ESC-E's.
  120. X
  121. XSee how repeated ^A's do nothing, but repeated ESC-A's
  122. Xkeep moving farther.  Do you think that this is right?
  123. X
  124. XTwo other simple cursor motion commands are ESC-< (Meta Less-than),
  125. Xwhich moves to the beginning of the file, and ESC-> (Meta Greater-than),
  126. Xwhich moves to the end of the file.  You probably don't need to try
  127. Xthem, since finding this spot again will be boring.  If you need the
  128. Xshift key to type a "<", then you must also use the shift key to type
  129. XESC-<.  Otherwise, you would be typing ESC-, .
  130. X
  131. XThe location of the cursor within the text is also called "point".  To 
  132. Xparaphrase, the cursor shows on the screen where point is located in the text.
  133. X
  134. XHere is a summary of simple moving operations including
  135. Xthe word and sentence moving commands:
  136. X
  137. X     ^F        Move forward a character
  138. X     ^B        Move backward a character
  139. X
  140. X     ESC-F     Move forward a word
  141. X     ESC-B     Move backward a word
  142. X
  143. X     ^N        Move to next line
  144. X     ^P        Move to previous line
  145. X
  146. X     ESC-N     Move to next paragraph
  147. X     ESC-P     Move to previous paragraph 
  148. X
  149. X     ^A        Move to beginning of line
  150. X     ^E        Move to end of line
  151. X
  152. X     ESC-A     Move back to beginning of sentence  (not functional)
  153. X     ESC-E     Move forward to end of sentence     (not functional)
  154. X
  155. X     ESC-<     Go to beginning of file
  156. X     ESC->     Go to end of file
  157. X
  158. X>> Try all of these commands now a few times for practice.
  159. X   Since the last two will take you away from this screen,
  160. X   you can come back here with ^Z's and ^V's.  These are
  161. X   the most often used commands.
  162. X
  163. XLike all other commands in EMACS, these commands can be given
  164. Xarguments which cause them to be executed repeatedly.  The way you
  165. Xgive a command a repeat count is by typing META and then the digits
  166. Xbefore you type the command.  (Remember META is ususally called ESCAPE)
  167. X
  168. XFor instance, META 8 ^F moves forward eight characters.
  169. X
  170. X>> Try giving a suitable argument to ^N or ^P to come as close
  171. X   as you can to this line in one jump.
  172. X
  173. XThis also applies to the screen moving commands, ^V and ^Z.  When
  174. Xgiven an argument, they scroll the screen up or down by that many
  175. Xscreenfuls.  As a special case, typing just ^U is equivalent to ESC-4.
  176. X
  177. X>> Try typing ESC-3 ^V now.
  178. X
  179. XIf you would like to scroll it down, you can give an argument to ^Z.
  180. X
  181. X
  182. XQUITTING FROM COMMANDS
  183. X----------------------
  184. X
  185. XThe character in EMACS used to quit out of all commands which request
  186. Xinput is ^G.  For example, you can use ^G to discard a numeric argument
  187. Xor the beginning of a command that you don't want to finish.
  188. X
  189. X>> Type ESC-100 to make a numeric arg of 100, then type ^G.
  190. X   Now type ^F.  How many characters does it move?
  191. X   If you have typed an <ESC> by mistake, you can get rid of it
  192. X   with a ^G.
  193. X
  194. X
  195. XIBM CURSOR KEYS
  196. X---------------
  197. X
  198. XOn the IBM-PC version, the cursor keypad has been bound to some of the
  199. Xmore useful screen movement commands. The mappings are as follows:
  200. X
  201. X     Cursor-Right    ^F        Move forward a character
  202. X     Cursor-Left     ^B        Move backward a character
  203. X
  204. X     ^Cursor-Right   ESC-F     Move forward a word
  205. X     ^Cursor-Left    ESC-B     Move backward a word
  206. X
  207. X     Cursor-Down     ^N        Move to next line
  208. X     Cursor-UP       ^P        Move to previous line
  209. X
  210. X     Pg-Dn           ^V        Move to next screen
  211. X     Pg-Up           ^Z        Move to previous screen
  212. X
  213. X     Home            ESC-<     Go to beginning of file
  214. X     End             ESC->     Go to end of file
  215. X
  216. X     Insert          ^O        Open up a new line
  217. X     Delete          ^K        Kill to end of line
  218. X
  219. XUsage of the ^O and ^K commands is described later in the tutorial. A
  220. Xmap of the key layout looks something like this:
  221. X
  222. X              -------------------------------------------------
  223. X              | 7             | 8             | 9             |
  224. X              | Home          | ^             | Pg Up         |
  225. X              |               | |             |               |
  226. X              |     ESC-<     |      ^P       |     ^Z        |
  227. X              -------------------------------------------------
  228. X              | 4             | 5             | 6             |
  229. X              | <--           |               | -->           |
  230. X              |               |               |               |
  231. X              |      ^B       |               |      ^F       |
  232. X              -------------------------------------------------
  233. X              | 1             | 2             | 3             |
  234. X              | End           | |             | Pg Dn         |
  235. X              |               | v             |               |
  236. X              |     ESC->     |      ^N       |      ^V       |
  237. X  -------------------------------------------------------------
  238. X  | 0                         | .                             |
  239. X  | Insert                    | Delete                        |
  240. X  |                           |                               |
  241. X  |             ^O            |             ^K                |
  242. X  -------------------------------------------------------------
  243. X
  244. X>> if you have an IBM-PC, practice using the cursor keypad.
  245. X
  246. X
  247. X
  248. XERRORS
  249. X------
  250. X
  251. XSometimes you may do something which EMACS doesn't allow. If it is
  252. Xsomething simple, such as typing a control key sequence which is not
  253. Xassociated with any command, EMACS will just beep at you. Otherwise,
  254. XEMACS will also display an informative error message at the bottom of
  255. Xthe screen.
  256. X
  257. XSome versions of EMACS do not have all the features described in this
  258. Xtutorial implemented yet.  If you come across such an unimplemented
  259. Xfeature, you may get an error message when you try to use it.  Just
  260. Xtype a space and proceed on to the next section of the tutorial.
  261. X
  262. X
  263. XINSERTING AND DELETING
  264. X----------------------
  265. X
  266. XIf you want to type text, just do it.  Characters which you can see, such 
  267. Xas A, 7, *, etc. are taken by EMACS as text and are immediately inserted.  
  268. XType <Return> (the carriage-return key) to insert a line separator.
  269. X
  270. XYou can delete the last character you typed by typing either <Delete> or ^H.  
  271. XOn some keyboards, there is a dedicated key for creating a ^H.  If so, it is 
  272. Xusually labeled as either "Backspace" or "<--".  <Delete> is a key on the 
  273. Xkeyboard, which may be labeled "Rubout" instead of "Delete" on some terminals.
  274. XMore generally, <Delete> deletes the character immediately before the current 
  275. Xcursor position.
  276. X
  277. X>> Do this now, type a few characters and then delete them by typing
  278. X   <Delete> a few times.  Don't worry about this file being changed;
  279. X   you won't affect the master tutorial.  This is just a copy of it.
  280. X
  281. X>> Now start typing text until you reach the right margin, and keep
  282. X   typing.  When a line of text gets too big for one line on the
  283. X   screen, the line of text is "continued" off the edge of the screen
  284. X   The dollar sign at the right margin indicates a line which has
  285. X   been continued.  EMACS scrolls the line over so you can see what you 
  286. X   are editing.  The '$' at the left or right edge of the screen indicates 
  287. X   that the current line extends off in that direction.  
  288. X
  289. X>> The following line actually goes off the edge.  Trying typing enough ^F's
  290. X   so that you move off the right hand end of this line.  This is a long line of text.  Note the "$"s at each edge.  Keep typing ^F's and watch where EMACS decides to scroll the line.  Now, type ^B's until EMACS decides to scroll the line again.
  291. X
  292. XThis is one of those gizmos which is easier to understand by playing with it 
  293. Xthan by reading about it.
  294. X
  295. X>> Use ^D's or <Delete>s to delete the text until the text line fits on 
  296. X   one screen line again.  The continuation "$" will go away.
  297. X
  298. X>> Move the cursor to the beginning of a line and type <Delete>.  This
  299. X   deletes the line separator before the line and merges the line onto
  300. X   the previous line.  The resulting line may be too long to fit, in
  301. X   which case it has a continuation indication.
  302. X
  303. X>> Type <Return> to insert the separator again.
  304. X
  305. XInternally, EMACS will allow you to have lines of nearly any length, limited 
  306. Xonly by the amount of memory available.  Externally, however, EMACS can only 
  307. Xread or write lines, to or from a file, which are less than or equal to 255 
  308. Xcharacters.
  309. X
  310. XRemember that most EMACS commands can be given a repeat count;  Note
  311. Xthat this includes characters which insert themselves.
  312. X
  313. X>>  Try that now -- type META 8 * and see what happens.
  314. X
  315. XIf you want to create a blank line in between two lines, move to the
  316. Xsecond of the two lines and type ^O.
  317. X
  318. X>>  Try moving to a line and typing ^O now.
  319. X
  320. XYou've now learned the most basic way of typing something in
  321. XEMACS and correcting errors.  You can delete by words or lines
  322. Xas well.  Here is a summary of the delete operations:
  323. X
  324. X     <Delete>      delete the character just before the cursor
  325. X     ^H            delete the character just before the cursor
  326. X     ^D            delete the next character after the cursor
  327. X
  328. X     ESC-<Delete>  kill the word immediately before the cursor
  329. X     ESC-^H        kill the word immediately before the cursor
  330. X     ESC-D         kill the next word after the cursor
  331. X
  332. X     ^K            kill from the cursor position to end of line
  333. X
  334. XNotice that <Delete> and ^D vs ESC-<Delete> and ESC-D extend the parallel
  335. Xstarted by ^F and ESC-F (well, <Delete> isn't really a control
  336. Xcharacter, but let's not worry about that).
  337. X
  338. XNow suppose you kill something, and then you decide that you want to get 
  339. Xit back?  Well, whenever you kill something bigger than a character, EMACS 
  340. Xsaves it for you.  To yank it back, use ^Y.  Note that you don't have to 
  341. Xbe in the same place to do ^Y; This is a good way to move text around.  
  342. XAlso note that the difference between "Killing" and "Deleting" something 
  343. Xis that "Killed" things can be yanked back, and "Deleted" things cannot.  
  344. XGenerally, the commands that can destroy a lot of text save it, while the 
  345. Xones that attack only one character, or nothing but blank lines and spaces, 
  346. Xdo not save.
  347. X
  348. XFor instance, type ^N a couple times to postion the cursor
  349. Xat some line on this screen.
  350. X
  351. X>> Do this now, move the cursor and kill that line with ^K.
  352. X
  353. XNote that a single ^K kills the contents of the line, and a second
  354. X^K kills the line itself, and make all the other lines move up.  If
  355. Xyou give ^K a repeat count, it kills that many lines AND their contents.
  356. X
  357. XThe text that has just disappeared is saved so that you can
  358. Xretrieve it.  To retrieve the last killed text and put it where
  359. Xthe cursor currently is, type ^Y.
  360. X
  361. X>> Try it; type ^Y to yank the text back.
  362. X
  363. XThink of ^Y as if you were yanking something back that someone took away 
  364. Xfrom you.  Notice that if you do several ^K's in a row the text that is 
  365. Xkilled is all saved together so that one ^Y will yank all of the lines.
  366. X
  367. X>> Do this now, type ^K several times.
  368. X
  369. XNow to retrieve that killed text:
  370. X
  371. X>> Type ^Y.  Then move the cursor down a few lines and type ^Y
  372. X   again.  You now see how to copy some text.
  373. X
  374. XWhat do you do if you have some text you want to yank back, and then
  375. Xyou kill something else?  ^Y would yank the more recent kill.
  376. X
  377. X>> Kill a line, move around, kill another line.
  378. X   Then do ^Y to get back the second killed line.
  379. X
  380. X
  381. XFILES
  382. X-----
  383. X
  384. XIn order to make the text you edit permanent, you must put it in a file.
  385. XOtherwise, it will go away when you leave EMACS.  While you are editing a
  386. Xfile in EMACS, your changes are actually being made to a private
  387. X"scratch" copy of the file.  However, the changes still don't become
  388. Xpermanent until you "save" the file.  This is so you can have control to
  389. Xavoid leaving a half-changed file around when you don't want to.
  390. X
  391. XIf you look near the botton of the screen you will see a line that
  392. Xlooks like this:
  393. X
  394. X    =* MicroEMACS 3.1 (NORMAL) == emacs.tut == File: emacs.tut ==========
  395. X                                               ---------------
  396. X
  397. XNote that EMACS indicates the name of the file you are currently editing.
  398. XThis is the name of your own temporary copy of the text of the EMACS
  399. Xtutorial; the file you are now editing.  Whatever file you edit, that
  400. Xfile's name will appear in that precise spot.
  401. X
  402. XThe commands for finding and saving files are unlike the other commands you
  403. Xhave learned in that they consist of two characters. They both start with the
  404. Xcharacter Control-X.  There is a whole series of commands that start with
  405. XControl-X; many of them have to do with files, buffers, and related things,
  406. Xand all of them consist of Control-X followed by some other character.  As
  407. Xwith ESC, the character is interpreted the same regardless of case.
  408. X
  409. XAnother thing about the command for finding a file is that you have to say
  410. Xwhat file name you want.  We say the command "reads an argument from the
  411. Xterminal" (in this case, the argument is the name of the file).  After you
  412. Xtype the command
  413. X
  414. X     ^X ^F   Find a file
  415. X
  416. XEMACS will ask you for the file name.  You should end the name with
  417. Xthe Return key.  After this command, you will see the contents of the
  418. Xfile in your EMACS.  You can edit the contents.  When you wish to make
  419. Xthe changes permanent, issue the command
  420. X
  421. X     ^X ^S   Save the file
  422. X
  423. XA new version of the file will be created.  When the operation is
  424. Xfinished, EMACS prints the name and number of lines saved.
  425. X
  426. XIf you forget to save and edit a different file and then decide to quit,
  427. XEMACS will remind you that you made changes that have not been save and
  428. Xthen ask you whether you really want to quit.  (If you don't save them,
  429. Xthey will be thrown away.  That might be what you want!)  You should
  430. Xanswer with a "N" to save them or a "Y" to throw the changes away.
  431. X
  432. XTo make a new file, just edit it "as if" it already existed.  Then start 
  433. Xtyping in the text.  When you ask to "save" the file, EMACS will really 
  434. Xcreate the file with the text that you have inserted.  From then on, you 
  435. Xcan consider yourself to be editing an already existing file.
  436. X
  437. XIt is not easy for you to try out editing a file and continue with the 
  438. Xtutorial.  But you can always come back into the tutorial by starting it 
  439. Xover and skipping forward.  So, when you feel ready, you should try editing 
  440. Xa file named "FOO", putting some text in it, and saving it; then exit from 
  441. XEMACS and look at the file to be sure that it worked.
  442. X
  443. X
  444. XEXTENDING THE COMMAND SET
  445. X-------------------------
  446. X
  447. X###   The mechanisms for extending the command set and setting   ###
  448. X###   the key bindings has not been installed yet.  Skip forward ###
  449. X###   to the next section (TEXT REPLACEMENT).    DLH  (1/22/86)  ###
  450. X
  451. XThere are many, many more EMACS commands than could possibly be put
  452. Xon all the control and meta characters.  EMACS gets around this with
  453. Xthe X (eXtend) command.  This comes in two flavors:
  454. X
  455. X     ^X       Character eXtend.  Followed by one character.
  456. X     ESC-X    Named command eXtend.  Followed by a long name.
  457. X
  458. XThese are commands that are generally useful but used less than the commands 
  459. Xyou have already learned about.  You have already seen two of them: the file 
  460. Xcommands ^X ^F to Find and ^X ^S to Save.  Another example is the command to 
  461. Xtell EMACS that you'd like to stop editing.  The command to do this is ^X ^C.
  462. X
  463. XThere are many ^X commands.  The ones you need immediately are:
  464. X
  465. X     ^X ^F     Find file.
  466. X     ^X ^S     Save file.
  467. X     ^X ^C     Quit EMACS.  This does not save your files auto-
  468. X                 matically, though if your files have been modi-
  469. X                 fied, EMACS asks if you really want to quit.  The
  470. X                 standard way to save and exit is ^X ^S ^X ^C.
  471. X
  472. XNamed eXtended commands are commands which are used even less
  473. Xfrequently, or commands which are used only in certain modes. These
  474. Xcommands are usually called "functions". An example is the function
  475. X"apropos", which prompts for a keyword and then gives the names of all
  476. Xthe functions that apropos for that keyword. When you type ESC-X, EMACS
  477. Xprompts you at the bottom of the screen with ":" and you should type the
  478. Xname of the function you wish to call; in this case, "apropos". Just
  479. Xtype "apr<Space>" and EMACS will complete the name. EMACS will ask you
  480. Xfor a keyword or phrase and you type the string that you want ask about.
  481. X
  482. X>> Try typing ESC-X, followed by "apropos" or "apr" and then Return.
  483. X   Then try typing "file" followed by a Return.
  484. X
  485. X
  486. XTEXT REPLACEMENT
  487. X---- -----------
  488. X
  489. X>> Move the cursor to the blank line two lines below this one.
  490. X   Then type ESC-r changed<Escape>altered<Escape>.
  491. X
  492. X   Notice how this line has changed: you've replaced
  493. X   the word c-h-a-n-g-e-d with "altered" wherever it occurs
  494. X   after the cursor.
  495. X
  496. XThe more customary command for replacing strings is the interactive
  497. Xcommand query-replace-search, which has several options. In essence, it
  498. Xshows each occurance of the first string and asks you if you want to
  499. Xreplace it or not. You can also choose to edit around the string, or go
  500. Xon and replace all occurances without asking further. It is described in
  501. Xdetail in the EMACS manual.  Also, typing a '?' when it asks you if you
  502. Xwish to replace will list out the various options.
  503. X
  504. X
  505. XMODE LINE
  506. X---------
  507. X
  508. XThe bottom line of the screen is known as the communications line.  This
  509. Xis where EMACS interactively communicates with you.  You have already
  510. Xseen how emacs prompts you for information (like when searching).  EMACS
  511. Xcan also report things to you as well.
  512. X
  513. X>> Type ^X = and see what you get in the communications line.
  514. X
  515. XThe line immediately above the communications line is called the MODE
  516. XLINE. The mode line says something like
  517. X
  518. X    =* MicroEMACS 3.1 (NORMAL) == emacs.tut == File: emacs.tut ==========
  519. X
  520. XThis is a very useful "information" line.
  521. X
  522. XThe star means that you have made changes to the text.  Right after
  523. Xyou visit or save a file, there is no star.
  524. X
  525. XThe buffername is the name EMACS gave to the buffer, and it is usually
  526. Xrelated to the filename. You already know what the filename means -- it
  527. Xis the file you have edited.
  528. X
  529. XThe part of the mode line inside the parentheses is to tell you what
  530. Xmodes you are in. The default mode is NORMAL which is what you are in
  531. Xnow. It is an example of a "major mode". There are several major modes
  532. Xin EMACS for editing different languages and text, such as C mode, Text
  533. Xmode, etc. At any time one and only one major mode is active, and its
  534. Xname can always be found in the mode line just where "NORMAL" is now.
  535. X
  536. XEach major mode makes a few commands behave differently. For example,
  537. Xthere are commands for creating comments in a program, and since each
  538. Xprogramming language has a different idea of what a should look like,
  539. Xeach major mode has to insert comments differently. Each major mode is
  540. Xcontrolled by a EMACS variable which can be manipulated and queried with
  541. Xthe "set" and "print" extended commands.
  542. X
  543. XMajor modes are called major because there are also minor modes. They
  544. Xare called minor because they aren't alternatives to the major modes,
  545. Xjust minor modifications of them. Each minor mode can be turned on or
  546. Xoff by itself, regardless of what major mode you are in, and regardless
  547. Xof the other minor modes. So you can use no minor modes, or one minor
  548. Xmode, or any combination of several minor modes.
  549. X
  550. XOne minor mode which is very useful, especially for editing English
  551. Xtext, is WRAP mode. When this mode is on, EMACS breaks the line in
  552. Xbetween words automatically whenever the line gets too long. You can
  553. Xturn this mode on by doing ^X M wrap <return>. When the mode is on, you
  554. Xcan turn it off by doing ^X ^M wrap <Return>.
  555. X
  556. X>> Type "^X ^M wrap <Return>" now.  Then insert a line of "asdf " over 
  557. X   again until you see it divide into two lines.  You must put in spaces 
  558. X   between them because Auto Fill breaks lines only at spaces.  Note that 
  559. X   "WRAP" appears in the mode line, indicating that you are in WRAP mode.
  560. X
  561. XThe margin is usually set at 72 characters, but it can be shanged.  
  562. XSimply type ESC nn ^X F, where "nn" is the column number for the right 
  563. Xhand margin.  
  564. X
  565. X
  566. XSEARCHING
  567. X---------
  568. X
  569. XEMACS can do searches for strings (these are groups of contiguous
  570. Xcharacters or words) either forward through the file or backward
  571. Xthrough it.  
  572. X
  573. X>> Now type ^S to start a search.  Type the word 'cursor', then ESCAPE.
  574. X
  575. X>> Type ^S ESCAPE to find the next occurrence of "cursor".
  576. X
  577. XThe ^S starts a search that looks for any occurrence of the search
  578. Xstring AFTER the current cursor position.  But what if you want to
  579. Xsearch for something earlier in the text?  To do this one should
  580. Xtype ^R for Reverse search.  Everything that applies to ^S applies
  581. Xto ^R except that the direction of the search is reversed.
  582. X
  583. X
  584. XGETTING MORE HELP
  585. X-----------------
  586. X
  587. XIn this tutorial we have tried to supply just enough information to
  588. Xget you started using EMACS.  There is so much available in EMACS that
  589. Xit would be impossible to explain it all here.  However, you may want
  590. Xto learn more about EMACS since it has numerous desirable features
  591. Xthat you don't know about yet.
  592. X
  593. X###   The on-line help features have not been implimented yet.  DLH   ###
  594. X
  595. XThe most basic HELP feature is the describe-key function which is
  596. Xavailable by typing ^X ? and then a command character. EMACS prints one
  597. Xline line on the bottom of the screen tell what function is bound to
  598. Xthat key.
  599. X
  600. XThe describe-command function ESC-? will prompt for the name of a function
  601. Xand print out the section from the manual about that command. When you
  602. Xare finished reading it, type a Space or a ^G (quit) to bring your text
  603. Xback on the screen.
  604. X
  605. X>> Type ^X ? Control-P.  The message at the bottom of the screen should
  606. X   be something like "^P is bound to previous-line".
  607. X
  608. XMulti-character commands such as ^X ^Z and <ESC>V are also allowed
  609. Xafter ^X ?.
  610. X
  611. XNow lets get more information about the previous-line command.
  612. X
  613. X>> Type ESC-? previous-line.  When you are finished reading the
  614. X   output, type a Space.
  615. X
  616. XThe "name of the function" is important for people who are customizing
  617. XEMACS.  It is what appears in the EMACS CHART as the documentation for
  618. Xthe command character.
  619. X
  620. X
  621. XCONCLUSION
  622. X----------
  623. X
  624. XRemember, to exit use ^X ^C.
  625. X
  626. XThis tutorial is meant to be understandable to all new users, so if
  627. Xyou found something unclear, don't sit and blame yourself - complain!
  628. X
  629. XYou'll probably find that if you use EMACS for a few days you won't
  630. Xbe able to give it up.  Initially it may give you trouble.  But remember
  631. Xthat this is the case with any editor, especially one that can do many,
  632. Xmany things.  And EMACS can do practically everything.
  633. X
  634. X
  635. XAcknowledgements
  636. X----------------
  637. X
  638. XThis is a modified version of the "JOVE Tutorial" by Jonathan Payne 
  639. X(19 January 86). That document was in turn a modified version of the
  640. Xtutorial "Teach-Emacs" from MIT as modified by Steve Zimmerman at
  641. XCCA-UNIX (31 October 85).
  642. X
  643. XThis document was last updated on 2-7-86 by Dana Hoggatt.
  644. X
  645. *-*-END-of-emacs.tut-*-*
  646. echo x - estruct.h
  647. sed 's/^X//' >estruct.h <<'*-*-END-of-estruct.h-*-*'
  648. X/*    ESTRUCT:    Structure and preprocesser defined for
  649. X            MicroEMACS 3.6
  650. X
  651. X            written by Dave G. Conroy
  652. X            modified by Steve Wilhite, George Jones
  653. X            greatly modified by Daniel Lawrence
  654. X*/
  655. X
  656. X#undef    LATTICE        /* don't use their definitions...use ours    */
  657. X#undef    MSDOS
  658. X#undef    CPM
  659. X
  660. X/*    Machine/OS definitions            */
  661. X
  662. X#define AMIGA   0                       /* AmigaDOS            */
  663. X#define ST520   0                       /* ST520, TOS                   */
  664. X#define MSDOS   0                       /* MS-DOS                       */
  665. X#define V7      1                       /* V7 UN*X or Coherent or BSD4.2*/
  666. X#define    BSD    0            /* also needed for BSD 4.2    */
  667. X#define VMS     0                       /* VAX/VMS                      */
  668. X#define CPM     0                       /* CP/M-86                      */
  669. X
  670. X/*    Compiler definitions            */
  671. X#define MWC86   0    /* marc williams compiler */
  672. X#define    LATTICE    0    /* either lattice compiler */
  673. X#define    LAT2    0    /* Lattice 2.15 */
  674. X#define    LAT3    0    /* Lattice 3.0 */
  675. X#define    AZTEC    0    /* Aztec C 3.20e */
  676. X
  677. X/*    Terminal Output definitions        */
  678. X
  679. X#define ANSI    0            /* ansi escape sequences    */
  680. X#define    HP150    0            /* HP150 screen driver        */
  681. X#define    VMSVT    0            /* various VMS terminal entries    */
  682. X#define VT52    0                       /* VT52 terminal (Zenith).      */
  683. X#define VT100   0                       /* Handle VT100 style keypad.   */
  684. X#define LK201   0                       /* Handle LK201 style keypad.   */
  685. X#define RAINBOW 0                       /* Use Rainbow fast video.      */
  686. X#define TERMCAP 1                       /* Use TERMCAP                  */
  687. X
  688. X/*    Configuration options    */
  689. X
  690. X#define CVMVAS  1    /* arguments to page forward/back in pages    */
  691. X#define    NFWORD    1    /* forward word jumps to begining of word    */
  692. X#define    CLRMSG    0    /* space clears the message line with no insert    */
  693. X#define    TYPEAH    1    /* type ahead causes update to be skipped    */
  694. X#define    FILOCK    0    /* file locking under unix BSD 4.2        */
  695. X#define    REVSTA    1    /* Status line appears in reverse video        */
  696. X
  697. X/*    System dependant library redefinitions    */
  698. X
  699. X#if    MSDOS & AZTEC
  700. X#undef    fputc
  701. X#undef    fgetc
  702. X#define    fputc    aputc
  703. X#define    fgetc    agetc
  704. X#endif
  705. X
  706. X/*    internal constants    */
  707. X
  708. X#define    NBINDS    200            /* max # of bound keys        */
  709. X#define NFILEN  80                      /* # of bytes, file name        */
  710. X#define NBUFN   16                      /* # of bytes, buffer name      */
  711. X#define NLINE   256                     /* # of bytes, line             */
  712. X#define    NSTRING    256            /* # of bytes, string buffers    */
  713. X#define NKBDM   256                     /* # of strokes, keyboard macro */
  714. X#define NPAT    80                      /* # of bytes, pattern          */
  715. X#define HUGE    1000                    /* Huge number                  */
  716. X#define    NLOCKS    100            /* max # of file locks active    */
  717. X
  718. X#define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  719. X#define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  720. X#define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  721. X#define EXITCH  0x1D                    /* Exit level,  Control-]       */
  722. X#define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  723. X#define HELPCH  0x1F                    /* Help key,    Control-_       */
  724. X
  725. X#define CTRL    0x0100                  /* Control flag, or'ed in       */
  726. X#define META    0x0200                  /* Meta flag, or'ed in          */
  727. X#define CTLX    0x0400                  /* ^X flag, or'ed in            */
  728. X#define    SPEC    0x0800            /* special key (function keys)    */
  729. X
  730. X#define FALSE   0                       /* False, no, bad, etc.         */
  731. X#define TRUE    1                       /* True, yes, good, etc.        */
  732. X#define ABORT   2                       /* Death, ^G, abort, etc.       */
  733. X
  734. X#define FIOSUC  0                       /* File I/O, success.           */
  735. X#define FIOFNF  1                       /* File I/O, file not found.    */
  736. X#define FIOEOF  2                       /* File I/O, end of file.       */
  737. X#define FIOERR  3                       /* File I/O, error.             */
  738. X#define    FIOLNG    4            /*line longer than allowed len    */
  739. X
  740. X#define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  741. X#define CFKILL  0x0002                  /* Last command was a kill      */
  742. X
  743. X#define    BELL    0x07            /* a bell character        */
  744. X#define    TAB    0x09            /* a tab character        */
  745. X
  746. X/*
  747. X * There is a window structure allocated for every active display window. The
  748. X * windows are kept in a big list, in top to bottom screen order, with the
  749. X * listhead at "wheadp". Each window contains its own values of dot and mark.
  750. X * The flag field contains some bits that are set by commands to guide
  751. X * redisplay; although this is a bit of a compromise in terms of decoupling,
  752. X * the full blown redisplay is just too expensive to run for every input
  753. X * character.
  754. X */
  755. Xtypedef struct  WINDOW {
  756. X        struct  WINDOW *w_wndp;         /* Next window                  */
  757. X        struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  758. X        struct  LINE *w_linep;          /* Top line in the window       */
  759. X        struct  LINE *w_dotp;           /* Line containing "."          */
  760. X        short   w_doto;                 /* Byte offset for "."          */
  761. X        struct  LINE *w_markp;          /* Line containing "mark"       */
  762. X        short   w_marko;                /* Byte offset for "mark"       */
  763. X        char    w_toprow;               /* Origin 0 top row of window   */
  764. X        char    w_ntrows;               /* # of rows of text in window  */
  765. X        char    w_force;                /* If NZ, forcing row.          */
  766. X        char    w_flag;                 /* Flags.                       */
  767. X}       WINDOW;
  768. X
  769. X#define WFFORCE 0x01                    /* Window needs forced reframe  */
  770. X#define WFMOVE  0x02                    /* Movement from line to line   */
  771. X#define WFEDIT  0x04                    /* Editing within a line        */
  772. X#define WFHARD  0x08                    /* Better to a full display     */
  773. X#define WFMODE  0x10                    /* Update mode line.            */
  774. X
  775. X/*
  776. X * Text is kept in buffers. A buffer header, described below, exists for every
  777. X * buffer in the system. The buffers are kept in a big list, so that commands
  778. X * that search for a buffer by name can find the buffer header. There is a
  779. X * safe store for the dot and mark in the header, but this is only valid if
  780. X * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  781. X * the buffer is kept in a circularly linked list of lines, with a pointer to
  782. X * the header line in "b_linep".
  783. X *     Buffers may be "Inactive" which means the files accosiated with them
  784. X * have not been read in yet. These get read in at "use buffer" time.
  785. X */
  786. Xtypedef struct  BUFFER {
  787. X        struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  788. X        struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  789. X        short   b_doto;                 /* Offset of "." in above LINE  */
  790. X        struct  LINE *b_markp;          /* The same as the above two,   */
  791. X        short   b_marko;                /* but for the "mark"           */
  792. X        struct  LINE *b_linep;          /* Link to the header LINE      */
  793. X    char    b_active;        /* window activated flag    */
  794. X        char    b_nwnd;                 /* Count of windows on buffer   */
  795. X        char    b_flag;                 /* Flags                        */
  796. X    char    b_mode;            /* editor mode of this buffer    */
  797. X        char    b_fname[NFILEN];        /* File name                    */
  798. X        char    b_bname[NBUFN];         /* Buffer name                  */
  799. X}       BUFFER;
  800. X
  801. X#define BFTEMP  0x01                    /* Internal temporary buffer    */
  802. X#define BFCHG   0x02                    /* Changed since last write     */
  803. X
  804. X/*    mode flags    */
  805. X#define    NUMMODES    6        /* # of defined modes        */
  806. X
  807. X#define    MDWRAP    0x0001            /* word wrap            */
  808. X#define    MDCMOD    0x0002            /* C indentation and fence match*/
  809. X#define    MDSPELL    0x0004            /* spell error parcing        */
  810. X#define    MDEXACT    0x0008            /* Exact matching for searches    */
  811. X#define    MDVIEW    0x0010            /* read-only buffer        */
  812. X#define MDOVER    0x0020            /* overwrite mode        */
  813. X
  814. X/*
  815. X * The starting position of a region, and the size of the region in
  816. X * characters, is kept in a region structure.  Used by the region commands.
  817. X */
  818. Xtypedef struct  {
  819. X        struct  LINE *r_linep;          /* Origin LINE address.         */
  820. X        short   r_offset;               /* Origin LINE offset.          */
  821. X        short   r_size;                 /* Length in characters.        */
  822. X}       REGION;
  823. X
  824. X/*
  825. X * All text is kept in circularly linked lists of "LINE" structures. These
  826. X * begin at the header line (which is the blank line beyond the end of the
  827. X * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  828. X * number of bytes in the line (the "used" size), the size of the text array,
  829. X * and the text. The end of line is not stored as a byte; it's implied. Future
  830. X * additions will include update hints, and a list of marks into the line.
  831. X */
  832. Xtypedef struct  LINE {
  833. X        struct  LINE *l_fp;             /* Link to the next line        */
  834. X        struct  LINE *l_bp;             /* Link to the previous line    */
  835. X        short   l_size;                 /* Allocated size               */
  836. X        short   l_used;                 /* Used size                    */
  837. X        char    l_text[1];              /* A bunch of characters.       */
  838. X}       LINE;
  839. X
  840. X#define lforw(lp)       ((lp)->l_fp)
  841. X#define lback(lp)       ((lp)->l_bp)
  842. X#define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  843. X#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  844. X#define llength(lp)     ((lp)->l_used)
  845. X
  846. X/*
  847. X * The editor communicates with the display using a high level interface. A
  848. X * "TERM" structure holds useful variables, and indirect pointers to routines
  849. X * that do useful operations. The low level get and put routines are here too.
  850. X * This lets a terminal, in addition to having non standard commands, have
  851. X * funny get and put character code too. The calls might get changed to
  852. X * "termp->t_field" style in the future, to make it possible to run more than
  853. X * one terminal type.
  854. X */
  855. Xtypedef struct  {
  856. X        short   t_nrow;                 /* Number of rows.              */
  857. X        short   t_ncol;                 /* Number of columns.           */
  858. X    short    t_margin;        /* min margin for extended lines*/
  859. X    short    t_scrsiz;        /* size of scroll region "    */
  860. X        int     (*t_open)();            /* Open terminal at the start.  */
  861. X        int     (*t_close)();           /* Close terminal at end.       */
  862. X        int     (*t_getchar)();         /* Get character from keyboard. */
  863. X        int     (*t_putchar)();         /* Put character to display.    */
  864. X        int     (*t_flush)();           /* Flush output buffers.        */
  865. X        int     (*t_move)();            /* Move the cursor, origin 0.   */
  866. X        int     (*t_eeol)();            /* Erase to end of line.        */
  867. X        int     (*t_eeop)();            /* Erase to end of page.        */
  868. X        int     (*t_beep)();            /* Beep.                        */
  869. X    int    (*t_rev)();        /* set reverse video state    */
  870. X}       TERM;
  871. X
  872. X/*    structure for the table of initial key bindings        */
  873. X
  874. Xtypedef struct  {
  875. X        short   k_code;                 /* Key code                     */
  876. X        int     (*k_fp)();              /* Routine to handle it         */
  877. X}       KEYTAB;
  878. X
  879. X/*    structure for the name binding table        */
  880. X
  881. Xtypedef struct {
  882. X    char *n_name;        /* name of function key */
  883. X    int (*n_func)();    /* function name is bound to */
  884. X}    NBIND;
  885. *-*-END-of-estruct.h-*-*
  886. exit
  887.  
  888.  
  889.