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

  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 (2 of 6)
  5. Message-ID: <5815@ncoast.UUCP>
  6. Date: 26 Nov 87 04:14:19 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Lines: 1189
  9. Approved: allbery@ncoast.UUCP
  10. X-Archive: comp.sources.misc/8711/13
  11.  
  12. Xvalue used to reset $ACOUNT after a save occurs. 
  13. X
  14. X@section(CMODE mode)@index(CMODE mode)
  15. X
  16. X    CMODE is useful to C programmers.  When CMODE is active, EMACS
  17. Xwill try to assist the user in a number of ways.  This mode is set
  18. Xautomatically with files that have a .c or .h extension. 
  19. X
  20. X    The <NL> key will normally attempt to return the user to the next
  21. Xline at the same level of indentation as the current line, unless the
  22. Xcurrent line ends with a open brace ({) in which case the new line will
  23. Xbe further indented by one tab position.
  24. X
  25. X    A close brace (}) will delete one tab position preceeding itself
  26. Xas it is typed.  This should line up the close brace with its matching
  27. XIF, FOR or WHILE statement. 
  28. X
  29. X    A pound sign (#) with only leading whitespace will delete all
  30. Xthe whitespace preceeding itself. This will always bring preprocessor
  31. Xdirectives flush to the left margin.
  32. X
  33. X    Whenever any close fence is typed, ie )]>}, if the matching open
  34. Xfence is on screen in the current window, the cursor will briefly flash
  35. Xto it, and then back. This makes balancing expressions, and matching
  36. Xblocks much easier.
  37. X
  38. X@section(CRYPT mode)@index(CRYPT mode)
  39. X
  40. X    When a buffer is in CRYPT mode, @index(encryption) it is
  41. Xencrypted whenever it is written to a file, and decrypted when it is
  42. Xread from the file.  The encryption key can be specified on the command
  43. Xline with the -k switch, or with the @b(M-E) @i(set-encryption-key)
  44. X@index(set-encryption-key) command.  If you attempt to read or write a
  45. Xbuffer in crypt mode and now key has not been set, EMACS will execute
  46. X@i(set-encryption-key) automatically, prompting you for the needed key. 
  47. XWhenever EMACS prompts you for a key, it will not echo the key to your
  48. Xscreen as you type it (ie make SURE you get it right when you set it
  49. Xoriginally).
  50. X
  51. X    The encryption algorithm used changes all characters into normal
  52. Xprinting characters, thus the resulting file is suitable for sending via
  53. Xelectronic mail.  All version of MicroEMACS should be able decrypt the
  54. Xresulting file regardless of what machine encrypted it.  Also available
  55. Xwith EMACS is the stand alone program, MicroCRYPT, which can en/decrypt
  56. Xthe files produced by CRYPT mode in EMACS.
  57. X
  58. X@section(EXACT mode)@index(EXACT mode)
  59. X
  60. X    All string searches and replacements will take upper/lower case
  61. Xinto account. Normally the case of a string during a search or replace
  62. Xis not taken into account.
  63. X
  64. X@section(MAGIC mode)@index(MAGIC mode)
  65. X
  66. X     In the MAGIC mode certain characters gain special meanings when
  67. Xused in a search pattern.  Collectively they are know as regular
  68. Xexpressions, and a limited number of them are supported in MicroEmacs. 
  69. XThey grant greater flexibility when using the search command.  However,
  70. Xthey do not affect the incremental search command. 
  71. X
  72. X     The symbols that have special meaning in MAGIC mode are
  73. X^, $, ., &, *, [ (and ], used with it), and \.
  74. X
  75. X     The characters ^ and $ fix the search pattern to the beginning and
  76. Xend of line, respectively.  The ^ character must appear at the beginning
  77. Xof the search string, and the $ must appear at the end, otherwise they
  78. Xloose their meaning and are treated just like any other character.  For
  79. Xexample, in MAGIC mode, searching for the pattern "t$" would put the
  80. Xcursor at the end of any line that ended with the letter 't'.  Note that
  81. Xthis is different than searching for "t<NL>", that is, 't' followed by a
  82. Xnewline character.  The character $ (and ^, for that matter) matches a
  83. Xposition, not a character, so the cursor remains at the end of the line. 
  84. XBut a newline is a character that must be matched, just like any other
  85. Xcharacter, which means that the cursor is placed just after it - on the
  86. Xbeginning of the next line. 
  87. X
  88. X     The character .  has a very simple meaning -- it matches any single
  89. Xcharacter, except the newline.  Thus a search for "bad.er" could match
  90. X"badger", "badder" (slang), or up to the 'r' of "bad error". 
  91. X
  92. X     The character * is known as closure, and means that zero or more of
  93. Xthe preceding character will match.  If there is no character preceding,
  94. X* has no special meaning, and since it will not match with a newline, *
  95. Xwill have no special meaning if preceded by the beginning of line symbol
  96. X^ or the literal newline character <NL>. 
  97. X
  98. X     The notion of zero or more characters is important.  If, for
  99. Xexample, your cursor was on the line
  100. X
  101. X@quotation(This line is missing two vowels.)
  102. X
  103. Xand a search was made for "a*", the cursor would not move, because it is
  104. Xguaranteed to match no letter 'a' , which satifies the search
  105. Xconditions.  If you wanted to search for one or more of the letter 'a',
  106. Xyou would search for "aa*", which would match the letter a, then zero or
  107. Xmore of them. 
  108. X
  109. X     The character [ indicates the beginning of a character class.  It
  110. Xis similar to the 'any' character ., but you get to choose which
  111. Xcharacters you want to match.  The character class is ended with the
  112. Xcharacter ].  So, while a search for "ba.e" will match "bane", "bade",
  113. X"bale", "bate", et cetera, you can limit it to matching "babe" and
  114. X"bake" by searching for "ba[bk]e".  Only one of the characters inside
  115. Xthe [ and ] will match a character.  If in fact you want to match any
  116. Xcharacter except those in the character class, you can put a ^ as the
  117. Xfirst character.  It must be the first character of the class, or else
  118. Xit has no special meaning.  So, a search for [^aeiou] will match any
  119. Xcharacter except a vowel, but a search for [aeiou^] will match any vowel
  120. Xor a ^.
  121. X
  122. XIf you have a lot of characters in order that you want to put in the
  123. Xcharacter class, you may use a dash (-) as a range character.  So, [a-z]
  124. Xwill match any letter (or any lower case letter if EXACT mode is on),
  125. Xand [0-9a-f] will match any digit or any letter 'a' through 'f', which
  126. Xhappen to be the characters for hexadecimal numbers.  If the dash is at
  127. Xthe beginning or end of a character class, it is taken to be just a
  128. Xdash. 
  129. X
  130. X     The character & (ampersand) is a replacement character, and
  131. Xrepresents the characters which matched the search string.  When used in
  132. Xthe @b[M-R] @i(replace-string) @index(replace-string) or the @b[M-^R]
  133. X@i(query-replace-string) @index(query-replace-string) commands, the &
  134. Xwill be substituted for the search string. 
  135. X
  136. X     The escape character \ is for those times when you want to be in
  137. XMAGIC mode, but also want to use a regular expression character
  138. Xto be just a character.  It turns off the special meaning of the
  139. Xcharacter.  So a search for "it\." will search for a line with "it.",
  140. Xand not "it" followed by any other character.  The escape character
  141. Xwill also let you put ^, -, or ] inside a character class with no
  142. Xspecial side effects.
  143. X
  144. X@section(OVER mode)@index(OVER mode)
  145. X
  146. X    OVER mode stands for overwrite mode.  When in this mode, when
  147. Xcharacters are typed, instead of simply inserting them into the file,
  148. XEMACS will attempt to overwrite an existing character past the point. 
  149. XThis is very useful for adjusting tables and diagrams. 
  150. X
  151. X@section(WRAP mode)@index(WRAP mode)
  152. X
  153. X    Wrap mode is used when typing in continuous text.  Whenever the
  154. Xcursor is past the currently set fill column @index(fill column) (72 by
  155. Xdefault) and the user types a space or a <NL>, the last word of the line
  156. Xis brought down to the beginning of the next line.  Using this, one just
  157. Xtypes a continuous stream of words and EMACS automatically inserts <NL>s
  158. Xat appropriate places.
  159. X
  160. X@center(NOTE to programmers:)
  161. X
  162. X@quotation{EMACS actually calls up the function bound to the illegal
  163. Xkeystroke M-FNW.  This is bound to the function @i(wrap-word)
  164. X@index(wrap-word) by default, but can be re-bound to activate different
  165. Xfunctions and macros at wrap time.}
  166. X
  167. X@section(VIEW mode)@index(VIEW mode)
  168. X
  169. X    VIEW mode disables all commands which can change the current
  170. Xbuffer.  EMACS will display an error message and ring the bell every
  171. Xtime you attempt to change a buffer in VIEW mode.
  172. X@newpage
  173. X@heading(Chapter @value(chapter) Summary)
  174. X
  175. XIn Chapter @value(chapter) you learned about modes and their effects.
  176. X
  177. X@begin{verbatim}
  178. X@u(Key Binding        Keystroke               Effect)
  179. XAdd-Mode        @b(^X-M)    Add a mode to the current buffer
  180. X
  181. XDelete-Mode        @b(^X-^M)    Delete a mode from the current buffer
  182. X
  183. XAdd-Global-Mode        @b(M-M)        Add a global mode to the
  184. X                    current buffer
  185. X
  186. XDelete-Global-Mode    @b(M-^M)    Delete a global mode from the
  187. X                    current buffer
  188. X@end(verbatim)
  189. X@chapter(Files)
  190. X
  191. XA file is simply a collection of related data.  In EMACS we are dealing
  192. Xwith text files -- named collections of text residing on a disk (or some
  193. Xother storage medium).  You will recall that the major entities EMACS
  194. Xdeals with are buffers.  Disk-based versions of files are only active in
  195. XEMACS when you are reading into or writing out of buffers.  As we have
  196. Xalready seen, buffers and physical files are linked by associated
  197. Xfile names.  For example, the buffer "ch7.txt" which is associated with
  198. Xthe physical disk file "ch7.txt." You will notice that the file is
  199. Xusually specified by the drive name or (in the case of a hard drive) a
  200. Xpath.  Thus you can specify full file names in EMACS,
  201. X
  202. Xe.g. disk:\directories\filename.extension
  203. X
  204. XIf you do not specify a disk and directories, the default disk is used.
  205. X
  206. XIMPORTANT -- If you do not explicitly save your buffer to a file, all your
  207. Xedits will be lost when you leave EMACS (although EMACS will prompt you
  208. Xwhen you are about to lose edits by exiting).  In addition, EMACS does
  209. Xnot protect your disk-based files from overwriting when it saves files. 
  210. XThus when you instruct EMACS to save a file to disk, it will create a
  211. Xfile if the specified file doesn't exist, or it will overwrite the
  212. Xpreviously saved version of the file thus replacing it.  Your old
  213. Xversion is gone forever. 
  214. X
  215. XIf you are at all unsure about your edits, or if (for any reason) you
  216. Xwish to keep previous versions of a file, you can change the name of the
  217. Xassociated file with the command @b{^X-N}.  When this file is saved
  218. Xto disk, EMACS will create a new physical file under the new name.  The
  219. Xearlier disk file will be preserved.
  220. X
  221. XFor example, let's load the file @b{fang.txt} into EMACS.  Now, type
  222. X@b{^X-N}.  The EMACS command line prompts "name:".  Enter a new name
  223. Xfor the file -- say @b(new.txt) and press <NL>.  The file will be
  224. Xsaved under the new filename, and your disk directory will show both
  225. X@b(fang.txt) and @b(new.txt).
  226. X
  227. XAn alternative method is to write the file directly to disk under a new
  228. Xfilename.  Let's pull our "publish.txt" file into EMACS.  To write this
  229. Xfile under another filename, type @b{^X-^W}.  EMACS will prompt
  230. Xyou "write file:".  Enter an alternate filename -- @b{desktop.txt}. 
  231. XYour file will be saved as the physical file "desktop.txt".
  232. X
  233. XNote that in the examples above, although you have changed the names of
  234. Xthe related files, the buffer names remain the same.  However, when you
  235. Xpull the physical file back into EMACS, you will find that the buffer
  236. Xname now relates to the filename.
  237. X
  238. XFor example -- You are working with a buffer "fang.txt" with the related
  239. Xfile "fang.txt".  You change the name of the file to "new.txt".  EMACS
  240. Xnow shows you working with the buffer "fang.txt" and the related file
  241. X"new.txt".  Now pull the file "new.txt" into EMACS.  Notice that the
  242. Xbuffer name has now changed to "new.txt". 
  243. X
  244. XIf for any reason a conflict of buffer names occurs,(if you have files
  245. Xof the same name on different drives for example) EMACS will prompt
  246. Xyou "use buffer:".  Enter an alternative buffer name if you need to. 
  247. X
  248. XFor a list of file related commands (including some we`ve already
  249. Xseen), see the summary page.
  250. X@newpage
  251. X@heading(Chapter @value(chapter) Summary)
  252. X
  253. XIn Chapter @value(chapter) you learned some of the more advanced
  254. Xconcepts of file naming and manipulation.  The relationship between
  255. Xfiles and buffers was discussed in some detail. 
  256. X
  257. X@begin(verbatim)
  258. X@u(Key Binding    Keystroke    Effect)
  259. X
  260. XSave-file    @b{^X-^S}    Saves contents of current buffer with
  261. X                associated filename on default disk/
  262. X                directory (if not specified)
  263. X
  264. XWrite-File    @b{^X-^W}    Current buffer contents will be
  265. X                saved under specified name 
  266. X
  267. XChange-File-name
  268. X        @b{^X-N}    The associated filename is changed
  269. X                (or associated if not previously
  270. X                specified) as specified
  271. X
  272. XFind-File    @b{^X-^F}    Reads specified file into buffer and 
  273. X                switches you to that buffer, or switches
  274. X                to buffer in which the file has previously
  275. X                been read
  276. X
  277. XRead-File    @b{^X-^R}    Reads file into buffer thus overwriting
  278. X                buffer contents.  If file has already
  279. X                been read into another buffer, you will
  280. X                be switched to it
  281. X
  282. XView-File    @b{^X-^V}    The same as read-file except the buffer
  283. X                is automatically put into VIEW mode thus 
  284. X                preventing any changes from being made
  285. X@end{verbatim}
  286. X@chapter(Screen Formatting)
  287. X
  288. X@section<Wrapping Text>
  289. X
  290. XAs we learned in the introduction, EMACS is not a word processor, but an
  291. Xeditor.  Some simple formatting options are available however, although
  292. Xin most cases they will not affect the appearence of the finished text
  293. X@index(wrapping text) when it is run through the formatter.  We have
  294. Xalready encountered WRAP mode which wraps lines longer than a certain
  295. Xlength (default is 75 characters).  You will recall that WRAP is enabled
  296. Xby entering @b{^X-M} and responding to the command line prompt with
  297. X@b{wrap}. 
  298. X
  299. XYou can also set your own wrap margin with the command @b{^X-F}
  300. X@i(set-fill-column) @index(set-fill-column).  Notice EMACS responds
  301. X"[Fill column is 1]." Now try typing some text.  You'll notice some very
  302. Xstrange things happening -- your text wraps at every word!! This effect
  303. Xoccurs because the set wrap margin command must be preceeded by a
  304. Xnumeric argument or EMACS sets it to the first column.  Thus any text
  305. Xyou type that extends past the first column will wrap at the most
  306. Xconvenient line break. 
  307. X
  308. XTo reset the wrap column to 72 characters, press the @b{<META>} key and
  309. Xenter 72.  EMACS will respond "Arg: 72".  Now press @b<^X-F>.  EMACS
  310. Xwill respond "[Fill column is 72]".  Your text will again wrap at the
  311. Xmargin you've been using up to this point.
  312. X
  313. X@section<Reformatting Paragraphs>
  314. X
  315. XAfter an intensive editing session, you may find that you have
  316. Xparagraphs containing lines of differing lengths.  Although this
  317. Xdisparity will not affect the formatted text, aesthetic and technical
  318. Xconcerns may make it desirable to have consistent paragraph blocks on
  319. Xthe screen.  If you are in WRAP mode, you can reformat a paragraph with
  320. Xthe command @b{M-Q} @i(fill-paragraph) @index(fill-paragraph).  This
  321. Xcommand 'fills' the current paragraph reformatting it so all the lines
  322. Xare filled and wrap logically.  The process is complex, and (especially
  323. Xwith longer paragraphs) may take a little time. 
  324. X
  325. X@section<Changing Case>
  326. X
  327. XThere may be occasions when you find it necessary to change the case of
  328. Xthe text you've entered.  EMACS allows you to change the case of even
  329. Xlarge amounts of text with ease.  Let's try and convert a few of the
  330. Xoffice traditionalists to the joy of word processing.  Type in the
  331. Xfollowing text:
  332. X
  333. X@quotation{Throw away your typewriter and learn to use a word processor. 
  334. XWord processing is relatively easy to learn and will increase your
  335. Xproductivity enormously.  Enter the Computer Age and find out just how
  336. Xmuch fun it can be!!}
  337. X
  338. XLet's give it a little more impact by capitalizing the first four words. 
  339. XThe first step is to define the region of text just as you would if you
  340. Xwere doing an extensive deletion.  Set the mark at the beginning of the
  341. Xparagraph with @b{M-<space>} @i(set-mark) and move the cursor to the
  342. Xspace beyond "typewriter." Now enter @b{^X-^U} @i(case-region-upper). 
  343. XYour text should now look like this:
  344. X
  345. X@quotation{THROW AWAY YOUR TYPEWRITER and learn to use a word processor. 
  346. XWord processing is relatively easy to learn and will increase your
  347. Xproductivity enormously.  Enter the Computer Age and find out just how
  348. Xmuch fun it can be!!}
  349. X
  350. XIf you want to change the text back to lower case, type @b{^X-^L}
  351. X@i(case-region-lower) @index(case-region-lower).  You can also
  352. Xcapitalize individual words.  To capitalize the word "fun", position the
  353. Xcursor in front of the word and type @b{M-U} @i(case-word-upper)
  354. X@index(case-word-upper).  The word is now capitalized.  To change it
  355. Xback to lower case, move the cursor back to the beginning of the word
  356. Xand type @b{M-L} @i(case-word-lower) @index(case-word-lower). 
  357. X
  358. XYou may also capitalize individual letters in EMACS.  The command
  359. X@b{M-C} @i(case-word-capitalize) @index(case-word-capitalize)
  360. Xcapitalizes the first letter after the point.  This command would
  361. Xnormally be issued with the cursor positioned in front of the first
  362. Xletter of the word you wish to capitalize.  If you issue it in the
  363. Xmiddle of a word, you can end up with some strAnge looking text. 
  364. X
  365. X@section<Tabs>
  366. X
  367. XUnless your formatter is instructed to take screen text literally (as
  368. XMicroSCRIBE does in the 'verbatim' environment for example), tabs in
  369. XEMACS generally affect screen formatting only. 
  370. X
  371. XWhen EMACS is first started, it sets the default tab to every eighth
  372. Xcolumn.  As long as you stay with default, every time you press the tab
  373. Xkey a tab character, @b(^I) is inserted.  This character, like other
  374. Xcontrol characters, is invisible -- but it makes a subtle and
  375. Xsignificant difference to your file and editing. 
  376. X
  377. XFor example, in default mode, press the tab key and then type the word
  378. X@b{Test}.  "Test" appears at the eighth column.  Move your cursor to the
  379. Xbeginning of the word and delete the backward character.  The word
  380. Xdoesn't move back just one character, but flushes to the left margin. 
  381. XThe reason for this behavior is easily explained.  In tab default, EMACS
  382. Xinserts a 'real' tab character when you press the tab key.  This
  383. Xcharacter is inserted at the default position, but NO SPACES are
  384. Xinserted between the tab character and the margin (or previous tab
  385. Xcharacter).  As you will recall, EMACS only recognizes characters (such
  386. Xas spaces or letters) and thus when the tab character is removed, the
  387. Xtext beyond the tab is flushed back to the margin or previous tab mark.
  388. X
  389. XThis situation changes if you alter the default configuration.  The
  390. Xdefault value may be changed by entering a numeric argument before
  391. Xpressing the tab key.  As we saw earlier, pressing the @b{META} key and
  392. Xentering a number allows you to specify how EMACS performs a given
  393. Xaction.  In this case, let's specify an argument of 10 and hit the tab
  394. Xkey. 
  395. X
  396. XNow hit the tab key again and type @b{Test}.  Notice the word now
  397. Xappears at the tenth column.  Now move to the beginning of the word and
  398. Xdelete the backward character.    "Test" moves back by one character. 
  399. X
  400. XEMACS behaves differently in these circumstances because the @b(^I)
  401. X@index(tab handling) @i(handle-tab) @index(handle-tab) function deals
  402. Xwith tabbing in two distinct ways.  In default conditions, or if the
  403. Xnumeric argument of zero is used, @i(handle-tab) inserts a true tab
  404. Xcharacter.  If, however, a non-zero numeric argument is specified,
  405. X@i(handle-tab) inserts the correct number of spaces needed to position
  406. Xthe cursor at the next specified tab position.  It does NOT insert the
  407. Xsingle tab character and hence any editing functions should take account
  408. Xof the number of spaces between tabbed columns. 
  409. X
  410. XMany times you would like to take a line which has been created using
  411. Xthe tab character and change it to use just spaces.  The command
  412. X@b(^X-^D) @i(detab-line) @index(detab-line) changes any tabs from the
  413. Xpoint to the end of the current line into the right number of spaces so
  414. Xthe line does not change.  This is very useful for times when the file
  415. Xmust be printed or transfered to a machine which does not understand
  416. Xtabs. 
  417. X
  418. XAlso, the inverse command, @b(^X-^E) @i(entab-lines) @index(entab-lines)
  419. Xchanges multiple spaces to tabs where possible.  This is a good way to
  420. Xshrink the size of large documents, especially with data tables.  Both
  421. Xof these commands can take a numeric argument which will be interpeted
  422. Xas the number of lines to en/detab. 
  423. X@newpage
  424. X@heading(Chapter @value(chapter) Summary)
  425. X
  426. XIn Chapter @value(chapter) introduced some of the formatting features of
  427. XEMACS. Text-wrap, paragraph reformatting, and tabs were discussed in
  428. Xsome detail.  The commands in the following table were covered in the
  429. Xchapter. 
  430. X
  431. X@begin{verbatim}
  432. X
  433. X@u(Key Binding        Keystroke            Effect)
  434. XAdd-Mode/WRAP        @b{^X-M}[WRAP]    Add wrap mode to current buffer
  435. X
  436. XDelete-Mode/WRAP    @b{^X-^M}[WRAP]    Remove wrap mode from current buffer
  437. X
  438. XSet-Fill-Column        @b{^X-F}     Set fill column to given numeric
  439. X                    argument  
  440. X
  441. XFill-Paragraph        @b{M-Q}        Logically reformats the current
  442. X                    paragraph
  443. X
  444. XCase-Word-Upper     @b{M-U}        Text from point to end of the
  445. X                    current word is changed to uppercase
  446. X
  447. XCase-Word-Lower     @b{M-L}        Text from point to end of the 
  448. X                    current word is changed to lowercase
  449. X
  450. XCase-Word-Capitalize    @b{M-C}        First word (or letter) after the
  451. X                    point is capitalized
  452. X
  453. XCase-Region-Upper    @b{^X-^U}    The current region is uppercased
  454. X
  455. XCase-Region-Lower    @b{^X-^L}    The current region is lowercased
  456. X
  457. XHandle-Tab        @b{^I}        Tab interval is set to the given
  458. X                    numeric argument
  459. XEntab-Line        @b(^X-^E)    Changes multiple spaces to tabs
  460. X                    characters where possible
  461. XDetab-Line        @b(^X-^D)    Changes tab characters to the
  462. X                    appropriate number of spaces
  463. X@end{verbatim}
  464. X@chapter(Access to the Outside World)
  465. X
  466. X    EMACS has the ability to interface to other programs and the
  467. Xenvironment of the computer outside of itself.  It does this through a
  468. Xseries of commands that allow it to talk to the computer's @b(command
  469. Xprocessor) @index(command processor) or @b(shell) @index(shell).  Just
  470. Xwhat this is varies between different computers.  Under MSDOS or PCDOS
  471. Xthis is the @b(command.com) @index(command.com) command processor. 
  472. XUnder UNIX it is the @b(csh) @index(cshell) shell.  On the Atari ST is
  473. Xcan be the Mark Williams @b(MSH) or the Beckmeyer shell.  In each case,
  474. Xit is the part of the computer's operating system that is responcable
  475. Xfor determining what programs are executed, and when. 
  476. X
  477. X    The @b(^X-!) @i(shell-command) @index(shell-command) command
  478. Xprompts the user for a command line to send out to the shell to execute.
  479. XThis can be very useful for doing file listings and changing the
  480. Xcurrent directory or folder.  EMACS gives control to the shell, which
  481. Xexecuted the command, and then types @b([END]) and waits for the user to
  482. Xtype a character before redrawing the screen and resuming editing. If
  483. Xthe @i(shell-command) command is used from within the macro language,
  484. Xthere is no pause.
  485. X
  486. X    @b(^X-@@) @i(pipe-command) @index(pipe-command) command allows
  487. XEMACS to execute a shell command, and if the particular computer allows
  488. Xit, send the results into a buffer which is automatically displayed on
  489. Xthe screen. The resulting buffer, called "command" can be manipulated
  490. Xjust like any other editing buffer. Text can be copied out of it or
  491. Xrearanged as needed. This buffer is originally created in @b(VIEW) mode,
  492. Xso remember to @b(^X-^Mview<NL>) in order to change it.
  493. X
  494. X    Many computers provide tools which will allow you to @b(filter)
  495. X@index(filter) text, making some modifications to it along the way. A
  496. Xvery common tool is the @b(SORT) program which accepts a file, sorts it,
  497. Xand prints the result out.  The EMACS command, @b(^X-#) @i(filter-buffer)
  498. Xsends the current buffer through such a filter.  Therefore, if you
  499. Xwished to sort the current buffer on a system which supplied a sort
  500. Xfilter, you would type @b(^X-#sort<NL>).  You can also create your own
  501. Xfilters by writing programs and utilities which read text from the
  502. Xkeyboard and display the results.  EMACS will use any of these which
  503. Xwould normally be available from the current shell.
  504. X
  505. X    If you would like to execute another program directly, without
  506. Xthe overhead of an intervening shell, you can use the @b(^X-$)
  507. X@i(execute-program) @index(execute-program) command. It will prompt you
  508. Xfor an external program and its arguments and attempt to execute it. 
  509. XLike when EMACS looks for command files, EMACS will look first in the
  510. XHOME directory, then down the execute PATH, and finally in the current
  511. Xdirectory for the named program. On some systems, it will automatically
  512. Xtack the proper extension on the file name to indicate it is a program.
  513. XOn some systems that don't support this function, @b(^X-$) will be
  514. Xequivalent to @b(^X-!) @i(shell-command).
  515. X
  516. X    Sometimes, you would like to get back to the shell and execute
  517. Xother commands, without losing the current contents of EMACS.  The
  518. X@b(^X-C) @i(i-shell) @index(i-shell) command shells out of EMACS,
  519. Xleaving EMACS in the computer and executing another command shell.  Most
  520. Xsystems would allow you to return to EMACS with the "exit" command. 
  521. X
  522. X@i(    On some systems, mainly advanced versions of UNIX, you can
  523. Xdirect EMACS to "go into the background" with the @b(^X-D) suspend-emacs
  524. X@index(suspend-emacs) command.  This places EMACS in the background
  525. Xreturning you to the original command shell. EMACS can then be returned
  526. Xto at any time with the "fg" foreground command.)
  527. X@newpage
  528. X@heading(Chapter @value(chapter) Summary)
  529. X
  530. XIn Chapter @value(chapter) introduced different ways to access the
  531. Xcomputers shell or command processor from within EMACS.  The commands
  532. Xin the following table were covered in the chapter. 
  533. X
  534. X@begin{verbatim}
  535. X
  536. X@u(Key Binding        Keystroke            Effect)
  537. XExecute-program        @b(^X-$)    Execute an external program
  538. X                    directly
  539. X
  540. XFilter-command        @b(^X-#)    Send the current buffer through
  541. X                    a shell filter
  542. X
  543. XI-shell            @b(^X-C)    Escape to a new shell
  544. X
  545. XPipe-command        @b(^X-@@)    Send the results of an external
  546. X                    shell command to a buffer
  547. X
  548. XShell-command        @b(^X-!)    Execute one shell command
  549. X
  550. XSuspend-emacs        @b(^X-D)    Place EMACS in the background
  551. X                    (some UNIX systems only)
  552. X@end{verbatim}
  553. X@chapter(Keyboard Macros)
  554. X
  555. XIn many applications, it may be necessary to repeat a series of
  556. Xcharacters or commands frequently.  For example, a paper may require the
  557. Xfrequent repetition of a complex formula or a long name.  You may also
  558. Xhave a series of EMACS commands that you invoke frequently.  Keyboard
  559. Xmacros offer a convenient method of recording and repeating these
  560. Xcommands. 
  561. X
  562. XImagine, for example, you are writing a scholarly paper on @i{Asplenium
  563. Xplatyneuron}, the spleenwort fern.  Even the dedicated botanist would
  564. Xprobably find it a task bordering on the agonizing to type
  565. X@i{Asplenium platyneuron} frequently throughout the paper.  An
  566. Xalternative method is 'record' the name in a keyboard macro.  Try it
  567. Xyourself.
  568. X
  569. XThe command @b{^X-(} @i(begin-macro) @index(begin-macro) starts
  570. Xrecording the all the keystrokes and commands you input.  After you've
  571. Xtyped it, enter @b{Asplenium platyneuron}.  To stop recording, type
  572. X@b{^X-)} @i(end-macro) @index(end-macro).  EMACS has stored all the
  573. Xkeystrokes between the two commands.  To repeat the name you've stored,
  574. Xjust enter @b{^X-E} @i(execute-macro) @index(execute-macro), and the
  575. Xname "Asplenium platyneuron" appears.  You can repeat this action as
  576. Xoften as you want, and of course as with any EMACS command, you may
  577. Xprecede it with a numerical argument. 
  578. X
  579. XBecause EMACS records keystrokes, you may freely intermix commands and
  580. Xtext.  Unfortunately, you can only store one macro at a time.  Thus, if
  581. Xyou begin to record another macro, the previously defined macro is
  582. Xlost. Be careful to ensure that you've finished with one macro before
  583. Xdefining another.  If you have a series of commands that you would like
  584. Xto 'record' for future use, use the macro or procedure facilities
  585. Xdetailed in chapter <X>.
  586. X@newpage
  587. X@heading(Chapter @value(chapter) Summary)
  588. X
  589. XChapter @value(chapter) covered keyboard macros.  You learned how to
  590. Xrecord keystrokes and how to repeat the stored sequence. 
  591. X
  592. X@begin{verbatim}
  593. X@u(Key Binding        Keystroke        Effect)
  594. X
  595. XStart-Macro        @b{^X-(}    Starts recording all keyboard input
  596. X
  597. XEnd-Macro        @b{^X-)}    Stops recording keystrokes for macro
  598. X
  599. XExecute-Macro        @b{^X-E}    Entire sequence of recorded
  600. X                    keystrokes is replayed
  601. X@end{verbatim}
  602. X@chapter(MicroEMACS Macros)
  603. X
  604. X    Macros are programs that are used to customize the editor and to
  605. Xperform complicated editing tasks.  They may be stored in files or
  606. Xbuffers and may be executed using an appropriate command, or bound to a
  607. Xparticular keystroke.  Portions of the standard start-up file are
  608. Ximplemented via macros, as well as the example menu system.  The
  609. X@i(execute-macro-<n>) @index(execute-macro-<n>) commands cause the
  610. Xmacro, numbered from 1 to 40, to be executed.  The @i(execute-file)
  611. X@index(execute-file) command allows you to execute a macro stored in a
  612. Xdisk file, and the @i(execute-buffer) @index(execute-buffer) command
  613. Xallows you to execute a macro stored in a buffer.  Macros are stored for
  614. Xeasy execution by executing files that contain the store-macro command. 
  615. X
  616. X    If you need more than 40 macros, named macroes, called
  617. X@b(procedures), @index(procedures) can be used.  The @i(store-procedure)
  618. X@index(store-procedure) command takes a string argument which is the
  619. Xname of a procedure to store.  These procedures than can be executed
  620. Xwith the @b(M-^E) @i(execute-procedure) @index(execute-procedure) or the
  621. X@i(run) @index(run) commands. 
  622. X
  623. X    There are many different aspects to the macro language within
  624. XMicroEMACS.  Editor commands are the various commands that manipulate
  625. Xtext, buffers, windows, etc, within the editor.  Directives are commands
  626. Xwhich control what lines get executed within a macro.  Also there are
  627. Xvarious types of variables.  Environmental variables both control and
  628. Xreport on different aspects of the editor.  User variables hold string
  629. Xvalues which may be changed and inspected.  Buffer variables allow text
  630. Xto be placed into variables.  Interactive variable allow the program to
  631. Xprompt the user for information.  Functions can be used to manipulate
  632. Xall these variables. 
  633. X
  634. X@section(Constants)
  635. X
  636. X    All constants and variable contents in EMACS are stored as
  637. Xstrings of characters. Numbers are stored digit by digit as characters.
  638. XThis allows EMACS to be "typeless", not having different variables types
  639. Xbe legal in different contexts. This has the disadvantage of forcing the
  640. Xuser to be more carefull about the context of the statements variables
  641. Xare placed in, but in turn gives them more flexibility in where they
  642. Xcan place variables. Needless to say, this also allows EMACS's expression
  643. Xevaluator to be both consice and quick.
  644. X
  645. X    Wherever statements need to have arguments, it is legal to place
  646. Xconstants.  A constant is a double quote character, followed by a string
  647. Xof characters, and terminated by another double quote character. To
  648. Xrepresent various special characters within a constant, the tilde (~)
  649. Xcharacter is used. The character following the tilde is interpeted
  650. Xaccording to the following table:
  651. X
  652. X@begin(verbatim)
  653. X@u(Sequence    Result)
  654. X~n        ^J    linefeed/newline, (EMACS newline character)
  655. X~r        ^M    carraige return
  656. X~~        ~
  657. X~b        ^H    backspace
  658. X~f        ^L    formfeed
  659. X~t        ^I    tab
  660. X~"        "
  661. X@end(verbatim)
  662. X
  663. X    Any character not in the table which follows a tilde will be
  664. Xpassed unmodified.  This action is similar to the @b(^Q)
  665. X@i(quote-character) command available from the keyboard. 
  666. X
  667. X    The double quotes around constants are not needed if the
  668. Xconstant contains no internal whitespace and it also does not happen to
  669. Xmeet the rules for any other EMACS commands, directives, variables, or
  670. Xfunctions. This is reasonable useful for numeric constants.
  671. X
  672. X@section(Variables)
  673. X
  674. X    Variables in MicroEMACS can be used to return values within
  675. Xexpressions, as repeat counts to editing commands, or as text to be
  676. Xinserted into buffers and messages.  The value of these variables is set
  677. Xusing the set (^X-A) command.  For example, to set the current fill
  678. Xcolumn to 64 characters, the following macro line would be used:
  679. X
  680. X    set $fillcol 64
  681. X
  682. X    or to have the contents of @b(%name) inserted at the point in the
  683. Xcurrent buffer, the command to use would be:
  684. X
  685. X    insert-string %name
  686. X@newpage
  687. X@subsection(Environmental Variables)
  688. X
  689. X    "What good is a quote if you can't change it?"
  690. X
  691. X    These variables are used to change different aspects of the way
  692. Xthe editor works.  Also they will return the current settings if used as
  693. Xpart of an expression.  All environmental variable names begin with a
  694. Xdollar sign ($) and are in lower case.
  695. X
  696. X@begin(description)
  697. X$acount@\The countdown of inserted characters until the next save-file.
  698. X
  699. X$asave@\The number of inserted characters between automatic file-saves
  700. Xin ASAVE mode. 
  701. X
  702. X$cbufname@\Name of the current buffer
  703. X
  704. X$cfname@\File name of the current buffer
  705. X
  706. X$cmode@\Integer containing the mode of the current buffer. (See Appendix F
  707. Xfor values)
  708. X
  709. X$curchar@\Character currently at the point
  710. X
  711. X$curcol@\Current column of point in current buffer
  712. X
  713. X$curline@\Current line of point in current buffer
  714. X
  715. X$curwidth@\Number of columns used currently
  716. X
  717. X$cwline@\Current display line in current window
  718. X
  719. X$debug@\Flag to trigger macro debugging (try it... you'll like it!)
  720. X
  721. X$discmd@\Flag to disable the echoing of messages on the command line
  722. X
  723. X$disinp@\Flag to disable the echoing of characters during command line input
  724. X
  725. X$fillcol@\Current fill column
  726. X
  727. X$flicker@\Flicker Flag set to TRUE if IBM CGA set to FALSE for most others
  728. X
  729. X$gflags@\Global flags controlling some EMACS internal functions (See
  730. Xappendix G for details)
  731. X
  732. X$gmode@\Global mode flags. (See Appendix F for values)
  733. X
  734. X$lastkey@\[READ ONLY]Last keyboard character typed
  735. X
  736. X$line@\The current line in the current buffer can be retrieved and
  737. Xset with this environment variable
  738. X
  739. X$lwidth@\[READ ONLY]Returns the number of characters in the current line
  740. X
  741. X$match@\[READ ONLY]Last string matched in a magic mode search
  742. X
  743. X$pagelen@\Number of screen lines used currently
  744. X
  745. X$palette@\string used to control the palette register settings on
  746. Xgraphics versions.  The usually form consists of groups of three octal
  747. Xdigits setting the red, green, and blue levels. 
  748. X
  749. X$pending@\[READ ONLY]Flag to determine if there are user keystrokes
  750. Xwaiting to be processed.
  751. X
  752. X$progname@\[READ ONLY]Always contains the string "MicroEMACS" for
  753. Xstandard MicroEMACS.  Could be something else if EMACS is incorporated
  754. Xas part of someone else's program
  755. X
  756. X$replace@\Current default replace string
  757. X
  758. X$rval@\This contains the return value from the last subprocess which was
  759. Xinvoked from EMACS
  760. X
  761. X$search@\Current default search string
  762. X
  763. X$seed@\Integer seed of the random number generator
  764. X
  765. X$sres@\Current screen resolution (CGA, MONO or EGA on the IBM-PC driver. 
  766. XLOW, MEDIUM, HIGH or DENSE on the Atari ST1040, NORMAL on all others)
  767. X
  768. X$status@\[READ ONLY]Status of the success of the last command (TRUE or
  769. XFALSE).  This is usually used with !force to check on the success of a
  770. Xsearch, or a file operation. 
  771. X
  772. X$target@\Current target for line moves (setting this fool's EMACS into
  773. Xbelieving the last command was a line move)
  774. X
  775. X$tpause@\Controls the length of the pause to display a matched fence
  776. Xwhen the current buffer is in CMODE and a close fence has been typed
  777. X
  778. X$version@\[READ ONLY]Contains the current MicroEMACS version number
  779. X
  780. X$wline@\Number of display lines in current window
  781. X@end(description)
  782. X
  783. X    Obviously, many more of these variables will be availible in
  784. Xfuture releases of MicroEMACS. (Yes, send a vote for your favorite new
  785. Xenvironmental variables today).
  786. X
  787. X@subsection(User variables)
  788. X
  789. X    User variables allow you, the user, to store strings and
  790. Xmanipulate them.  These strings can be pieces of text, numbers (in text
  791. Xform), or the logical values @b(TRUE) and @b(FALSE).  These variables
  792. Xcan be combined, tested, inserted into buffers, and otherwise used to
  793. Xcontrol the way your macros execute.  At the moment, up to 255 user
  794. Xvariables may be in use in one editing session.  All users variable
  795. Xnames must begin with a percent sign (%) and may contain any printing
  796. Xcharacters.  Only the first 10 characters are significant (ie
  797. Xdifferences beyond the tenth character are ignored).  Most operators
  798. Xwill truncate strings to a length of 128 characters. 
  799. X
  800. X@subsection(Buffer Variables)
  801. X
  802. X    Buffer variables are special in that they can only be queried
  803. Xand cannot be set.  What buffer variables are is a way to take text from
  804. Xa buffer and place it in a variable. For example, if I have a buffer by
  805. Xthe name of RIGEL2, and it contains the text:
  806. X
  807. X@begin(verbatim)
  808. X@begin(group)
  809. X    Richmond
  810. X    Lafayette
  811. X    <*>Bloomington        (where <*> is the current point)
  812. X    Indianapolis
  813. X    Gary
  814. X    =* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt =====
  815. X@end(group)
  816. X@end(verbatim)
  817. X
  818. X    and within a command I reference #rigel2, like:
  819. X
  820. X    insert-string #rigel2
  821. X
  822. X    MicroEMACS would start at the current point in the RIGEL2
  823. Xbuffer and grab all the text up to the end of that line and pass that
  824. Xback.  Then it would advance the point to the beginning of the next line.
  825. XThus, after our last command executes, the string "Bloomington" gets
  826. Xinserted into the current buffer, and the buffer RIGEL2 now looks like
  827. Xthis:
  828. X
  829. X@begin(verbatim)
  830. X@begin(group)
  831. X    Richmond
  832. X    Lafayette
  833. X    Bloomington
  834. X    <*>Indianapolis        (where <*> is the current point)
  835. X    Gary
  836. X    =* MicroEMACS 3.9e (WRAP) == rigel2 == File: /data/rigel2.txt =====
  837. X@end(group)
  838. X@end(verbatim)
  839. X
  840. X    as you have probably noticed, a buffer variable consists of the
  841. Xbuffer name, preceded by a pound sign (#).
  842. X
  843. X@subsection(Interactive variables)
  844. X
  845. X    Interactive variables are actually a method to prompt the user
  846. Xfor a string.  This is done by using an at sign (@@) followed either with
  847. Xa quoted string, or a variable containing a string.  The string is the
  848. Xplaced on the bottom line, and the editor waits for the user to type in
  849. Xa string.  Then the string typed in by the users is returned as the
  850. Xvalue of the interactive variable.  For example:
  851. X
  852. X@begin(verbatim)
  853. X    set %quest "What file? "
  854. X    find-file @@%quest
  855. X@end(verbatim)
  856. X
  857. X    will ask the user for a file name, and then attempt to find it.
  858. XNote also that complex expressions can be built up with these
  859. Xoperators, such as:
  860. X
  861. X@verbatim(@@&cat &cat "File to decode[" %default "]: ")
  862. X
  863. X    which prompts the user with the concatinated string.
  864. X
  865. X@section(Functions)
  866. X
  867. X    Functions can be used to manipulate variables in various ways. 
  868. XFunctions can have one, two, or three arguments.  These arguments will
  869. Xalways be placed after the function on the current command line.  For
  870. Xexample, if we wanted to increase the current fill column by two, using
  871. Xemacs's set (^X-A) command, we would write:
  872. X
  873. X@begin(group)
  874. X@begin(verbatim)
  875. X    set $fillcol &add $fillcol 2
  876. X     \    \      \      \     \____second operand
  877. X      \     \    \      \_________first operand
  878. X       \      \     \_______________function to execute
  879. X        \      \_____________________variable to set
  880. X         \___________________________set (^X-A) command
  881. X@end(verbatim)
  882. X@end(group)
  883. X
  884. X    Function names always begin with the ampersand (&) character,
  885. Xand are only significant to the first three characters after the
  886. Xampersand.  Functions will normal expect one of three types of
  887. Xarguments, and will automatically convert types when needed.
  888. X
  889. X@begin(description)
  890. X<num>@\an ascii string of digits which is interpeted as a numeric value. 
  891. XAny string which does not start with a digit or a minus sign (-) will be
  892. Xconsidered zero. 
  893. X
  894. X<str>@\An arbitrary string of characters.  At the moment, strings are
  895. Xlimited to 128 characters in length. 
  896. X
  897. X<log>@\A logical value consisting of the string "TRUE" or "FALSE". 
  898. XNumeric strings will also evaluate to "FALSE" if they are equal to zero,
  899. Xand "TRUE" if they are non-zero.  Arbitrary text strings will have the
  900. Xvalue of "FALSE". 
  901. X@end(description)
  902. X
  903. X    A list of the currently availible functions follows: (Once
  904. Xagain, send in those votes on what kind of functions you would like to
  905. Xsee added!) Functions are always used in lower case, the uppercase
  906. Xletters in the function table are the short form of the function (ie
  907. X&div for ÷).
  908. X
  909. X@begin(verbatim)
  910. XNumeric Functions:    (returns <num>)
  911. X
  912. X&ADD        <num> <num>    Add two numbers
  913. X&SUB        <num> <num>    Subtract the second number from the first
  914. X&TIMes        <num> <num>    Multiply two numbers
  915. X&DIVide        <num> <num>    Divide the first number by the second
  916. X                giving an integer result
  917. X&MOD        <num> <num>    Return the reminder of dividing the
  918. X                first number by the second
  919. X&NEGate        <neg>        Multiply the arg by -1
  920. X&LENgth        <str>        Returns length of string
  921. X&SINdex        <str1> <str2>    Finds the position of <str2> within
  922. X                <str1>. Returns zero if not found.
  923. X&ASCii        <str>        Return the ascii code of the first
  924. X                character in <str>
  925. X&RND        <num>        Returns a random integer between 1 and <num>
  926. X&ABS        <num>        Returns the absolute value of <num>
  927. X&BANd        <num> <num>    Bitwise AND function
  928. X&BOR        <num> <num>    Bitwise OR function
  929. X&BXOr        <num> <num>    Bitwise XOR function
  930. X&BNOt        <num>        Bitwise NOT function
  931. X
  932. XString manipulation functions:    (returns <str>)
  933. X
  934. X&CAT        <str> <str>    Concatinate the two strings to form one
  935. X&LEFt        <str> <num>    return the <num> leftmost characters
  936. X                from <str>
  937. X&RIGht        <str> <num>    return the <num> rightmost characters
  938. X                from <str>
  939. X&MID        <str> <num1> <num2>
  940. X                Starting from <num1> position in <str>,
  941. X                return <num2> characters.
  942. X&UPPer        <str>        Uppercase <str>
  943. X&LOWer        <str>        lowercase <str>
  944. X&CHR        <num>        return a string with the character
  945. X                represented by ascii code <num>
  946. X>K                return a string containing a single
  947. X                keystroke from the user
  948. X&ENV        <str>        If the operating system is capable, this
  949. X                returns the environment string associated
  950. X                with <str>
  951. X&BIND        <str>        return the function name bound to the
  952. X                keystroke <str>
  953. X&ENV        <str>        Returns the operating system value
  954. X                attached to environmental variable <str>
  955. X&FINd        <str>        Find the named file <str> along the
  956. X                path and return its full file specification
  957. X                or an empty string if none exists
  958. X
  959. XLogical Testing functions:    (returns <log>)
  960. X
  961. X&NOT        <log>        Return the opposite logical value
  962. X&AND        <log1> <log2>    Returns TRUE if BOTH logical arguments
  963. X                are TRUE
  964. X&OR        <log1> <log2>    Returns TRUE if either argument
  965. X                is TRUE
  966. X&EQUal        <num> <num>    If <num> and <num> are numerically
  967. X                equal, return TRUE
  968. X&LESs        <num1> <num2>    If <num1> is less than <num2>, return
  969. X                TRUE.
  970. X&GREater    <num1> <num2>    If <num1> is greater than, or equal to
  971. X                <num2>, return TRUE.
  972. X&SEQual        <str1> <str2>    If the two strings are the same, return
  973. X                TRUE.
  974. X&SLEss        <str1> <str2>    If <str1> is less alphabetically than
  975. X                <str2>, return TRUE.
  976. X&SGReater    <str1> <str2>    If <str1> is alphabetically greater than
  977. X                or equal to <str2>, return TRUE.
  978. X&FINd        <str>        Does the named file <str> exist?
  979. X
  980. XSpecial Functions:
  981. X
  982. X&INDirect    <str>        Evaluate <str> as a variable.
  983. X@end(verbatim)
  984. X
  985. X    This last function deserves more explanation. The &IND function
  986. Xevaluates its argument, takes the resulting string, and then uses it as
  987. Xa variable name.  For example, given the following code sequence:
  988. X
  989. X@begin(verbatim)
  990. X    ; set up reference table
  991. X
  992. X    set %one    "elephant"
  993. X    set %two    "giraffe"
  994. X    set %three    "donkey"
  995. X
  996. X    set %index "two"
  997. X    insert-string &ind %index
  998. X@end(verbatim)
  999. X
  1000. X    the string "giraffe" would have been inserted at the point in
  1001. Xthe current buffer.  This indirection can be safely nested up to about
  1002. X10 levels.
  1003. X
  1004. X@section(Directives)
  1005. X
  1006. X    Directives are commands which only operate within an executing
  1007. Xmacro, ie they do not make sense as a single command. As such, they
  1008. Xcannot be called up singly or bound to keystroke. Used within macros,
  1009. Xthey control what lines are executed and in what order.
  1010. X
  1011. X    Directives always start with the exclamation mark (!) character
  1012. Xand must be the first thing placed on a line.  Directives executed
  1013. Xinteractively (via the execute-command-line command) will be ignored. 
  1014. X
  1015. X@subsection(!ENDM Directive)
  1016. X
  1017. X    This directive is used to terminate a macro being stored. For
  1018. Xexample, if a file is being executed contains the text:
  1019. X
  1020. X@begin(verbatim)
  1021. X    ;    Read in a file in view mode, and make the window red
  1022. X
  1023. X    26    store-macro
  1024. X        find-file @@"File to view: "
  1025. X        add-mode "view"
  1026. X        add-mode "red"
  1027. X    !endm
  1028. X
  1029. X    write-message "[Consult macro has been loaded]"
  1030. X@end(verbatim)
  1031. X
  1032. X    only the lines between the store-macro command and the !ENDM
  1033. Xdirective are stored in macro 26.  Both numbered macroes and named
  1034. Xprocedures (via the @i(store-procedure) command) should be terminated with
  1035. Xthis directive.
  1036. X
  1037. X@subsection(!FORCE Directive)
  1038. X
  1039. X    When MicroEMACS executes a macro, if any command fails, the
  1040. Xmacro is terminated at that point. If a line is preceeded by a !FORCE
  1041. Xdirective, execution continues weather the command succeeds or not. For
  1042. Xexample:
  1043. X
  1044. X@begin(verbatim)
  1045. X    ;    Merge the top two windows
  1046. X
  1047. X    save-window        ;remember what window we are at
  1048. X    1 next-window        ;go to the top window
  1049. X    delete-window        ;merge it with the second window
  1050. X    !force restore-window    ;This will continue regardless
  1051. X    add-mode "red"
  1052. X@end(verbatim)
  1053. X
  1054. X@subsection(!IF, !ELSE, and !ENDIF Directives)
  1055. X
  1056. X    This directive allows statements only to be executed if a
  1057. Xcondition specified in the directive is met.  Every line following the
  1058. X!IF directive, until the first !ELSE or !ENDIF directive, is only
  1059. Xexecuted if the expression following the !IF directive evaluates to a
  1060. XTRUE value.  For example, the following macro segment creates the
  1061. Xportion of a text file automatically.  (yes believe me, this will be
  1062. Xeasier to understand then that last explanation....)
  1063. X
  1064. X@begin(verbatim)
  1065. X    !if &sequal %curplace "timespace vortex"
  1066. X        insert-string "First, rematerialize~n"
  1067. X    !endif
  1068. X    !if &sequal %planet "earth"    ;If we have landed on earth...
  1069. X        !if &sequal %time "late 20th century"  ;and we are then
  1070. X            write-message "Contact U.N.I.T."
  1071. X        !else
  1072. X            insert-string "Investigate the situation....~n"
  1073. X            insert-string "(SAY 'stay here Sara')~n"
  1074. X        !endif
  1075. X    !else
  1076. X        set %conditions @@"Atmosphere conditions outside? "
  1077. X        !if &sequal %conditions "safe"
  1078. X            insert-string &cat "Go outside......" "~n"
  1079. X            insert-string "lock the door~n"
  1080. X        !else
  1081. X            insert-string "Dematerialize..try somewhen else"
  1082. X            newline
  1083. X        !endif
  1084. X    !endif
  1085. X@end(verbatim)
  1086. X
  1087. X@subsection(!GOTO Directive)
  1088. X
  1089. X    Flow can be controlled within a MicroEMACS macro using the !GOTO
  1090. Xdirective. It takes as an argument a label. A label consists of a line
  1091. Xstarting with an asterisk (*) and then an alphanumeric label.  Only
  1092. Xlabels in the currently executing macro can be jumped to, and trying to
  1093. Xjump to a non-existing label terminates execution of a macro.  For
  1094. Xexample..
  1095. X
  1096. X@begin(verbatim)
  1097. X    ;Create a block of DATA statements for a BASIC program
  1098. X
  1099. X        insert-string "1000 DATA "
  1100. X        set %linenum 1000
  1101. X
  1102. X    *nxtin
  1103. X        update-screen        ;make sure we see the changes
  1104. X        set %data @@"Next number: "
  1105. X        !if &equal %data 0
  1106. X            !goto finish
  1107. X        !endif
  1108. X
  1109. X        !if &greater $curcol 60
  1110. X            2 delete-previous-character
  1111. X            newline
  1112. X            set %linenum &add %linenum 10
  1113. X            insert-string &cat %linenum " DATA "
  1114. X        !endif
  1115. X
  1116. X        insert-string &cat %data ", "
  1117. X        !goto nxtin
  1118. X
  1119. X    *finish
  1120. X
  1121. X        2 delete-previous-character
  1122. X        newline
  1123. X@end(verbatim)
  1124. X
  1125. X@subsection(!WHILE and !ENDWHILE Directives)
  1126. X
  1127. X    This directive allows you to set up repetitive tasks easily and
  1128. Xefficiently. If a group of statements need to be executed while a
  1129. Xcertain condition is true, enclose them with a while loop. For example,
  1130. X
  1131. X@begin(verbatim)
  1132. X    !while &less $curcol 70
  1133. X        insert-string &cat &cat "[" #stuff "]"
  1134. X    !endwhile
  1135. X@end(verbatim)
  1136. X
  1137. X    places items from buffer "item" in the current line until the
  1138. Xcursor is at or past column 70.  While loops may be nested and can
  1139. Xcontain and be the targets of !GOTOs with no ill effects. Using a while
  1140. Xloop to enclose a repeated task will run much faster than the
  1141. Xcorresponding construct using !IFs.
  1142. X
  1143. X@subsection(!BREAK Directive)
  1144. X
  1145. X    This directive allows the user to abort out of the currently
  1146. Xmost inner while loop, regardless of the condition.  It is often used
  1147. Xto abort processing for error conditions.  For example:
  1148. X
  1149. X@begin(verbatim)
  1150. X;    Read in files and substitute "begining" with "beginning"
  1151. X
  1152. X    set %filename #list
  1153. X    !while ¬ &seq %filename "<end>"
  1154. X!force        find-file %filename
  1155. X        !if &seq $status FALSE
  1156. X            write-message "[File read error]"
  1157. X            !break
  1158. X        !endif
  1159. X        beginning-of-file
  1160. X        replace-string "begining" "beginning"
  1161. X        save-file
  1162. X        set %filename #list
  1163. X    !endwhile
  1164. X@end(verbatim)
  1165. X
  1166. X    This while loop will process files until the list is exhausted
  1167. Xor there is an error while reading a file.
  1168. X
  1169. X@subsection(!RETURN Directive)
  1170. X
  1171. X    The !RETURN Directive causes the current macro to exit, either
  1172. Xreturning to the caller (if any) or to interactive mode.  For example:
  1173. X
  1174. X@begin(verbatim)
  1175. X    ;    Check the monitor type and set %mtyp
  1176. X
  1177. X    !if &sres "CGA"
  1178. X        set %mtyp 1
  1179. X        !return
  1180. X    !else
  1181. X        set %mtyp 2
  1182. X    !endif
  1183. X
  1184. X    insert-string "You are on a MONOCHROME machine!~n"
  1185. X@end(verbatim)
  1186. X@appendix(MicroEMACS Command Line Switches and Startup Files)
  1187. X
  1188. X@index(startup files)
  1189. X    When EMACS first executes, it always searches for a file,
  1190. Xcalled @b(.emacsrc) @i(under most UNIX systems) or @b(emacs.rc) @i(on
  1191. Xmost other systems) @index(emacs.rc) @index(.emacsrc) which it will
  1192. Xexecute as EMACS macros before it reads in the named source files. This
  1193. Xfile normally contains EMACS macroes to bind the function keys to
  1194. Xuseful functions and load various usefull macros.  The contents of this
  1195. Xfile will probably vary from system to system and can be modified by the
  1196. Xuser as desired.
  1197. X
  1198. X    When searching for this file, EMACS looks for it in this order. 
  1199. XFirst, it attempts to find a definition for "@b(HOME)" in the
  1200. Xenvironment.  It will look in that directory first.  Then it searches
  1201.