home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / WP / M10.ZIP / M.TUT < prev   
Text File  |  1994-01-31  |  45KB  |  868 lines

  1.         The M Tutorial File
  2.  
  3. You may ask why this editor is called M...  It is called M because it is My
  4. editor... the editor I wrote, Mine.  It can be your editor too.
  5.  
  6. In this file I will walk you through the features of M.  To walk around in
  7. this text, use the arrow keys, [pageUp], and [pageDown].  They behave like
  8. you would expect them to...  As a preliminary, I'll explain notation. 
  9. Characters in square brackets are M commands...  (This is to set them off
  10. from the rest of the text.)  The Alternate and Control keys are used like
  11. the shift key. In this tutorial I'll abreviate Control by a caret "^" and
  12. Alternate by "Alt".  
  13.     For example: 
  14. [^X] is Control_X
  15. [Alt G 2] is Alt_G and then 2.
  16. [^X ^F] is Control_X Control_F
  17. [Alt ^M] is Alt_Control_M
  18.  
  19. In the event you want to EXIT right away... there are two principal ways to
  20. exit M...  The first is the exit without saving [^X ^C], if there are no
  21. modified files you will be out.  If there are modified files you will be
  22. told of that fact and asked if you want to save them.  If yes, you will be
  23. asked about each file on your way out.  ([Escape] and [^G] will abort the
  24. exit.)  The second exit method is the save all files and exit [Alt Z]. 
  25. (The mnemonic is that Z is the last letter in the alphabet, [Alt Z] is the
  26. last thing you type before leaving.)
  27.  
  28.     I begin with an introductory note on the general theory of M.  In M
  29. there are windows and buffers (buffers = files).  A window is a view into a
  30. buffer and is only loosely connected to a buffer.  You can switch the
  31. buffer a window is connected to very easily.  You can have many more
  32. buffers open than you have windows to view them.  You can also have many
  33. windows open on the same buffer.  All combinations are possible.  Every
  34. window has a StatusLine with sundry information about the current buffer. 
  35. Every window has a current cursor position (although only the active window
  36. has a visible cursor).  Every window has a mark.  The mark is an old cursor
  37. position used in block delete and block copys.  (Occasionally I may refer
  38. to the cursor as the point, I use the terms point and cursor
  39. interchangeably.)  The actual location of the cursor is between letters... 
  40. The cursor visible on the screen is underneath a letter, the real cursor
  41. location is just in front of that character.
  42.     The [Escape] is not treated like other keys in M, typing an
  43. [Escape] prior to another key is equivalent to holding down Alt while
  44. typing that key.  You can think of the letters you type as a stream of
  45. characters coming to the program.  When you type an [Alt Z] for example I
  46. stick into the character stream first an [Escape] and then a [Z]...  You
  47. can just as easily type an [Escape] and then a [Z] yourself...  (In some
  48. contexts I peek if there is a character behind the [Escape]...  If there
  49. isn't one I know that you have typed a lone [Escape] and not a Alt key
  50. combination.  In some situations I interpret a lone [Escape] as an
  51. abort...)
  52.  
  53. When a new command is described in this text, try it!  If that command is
  54. destructive add some garbage text to play with...
  55.  
  56.  
  57. For those who are familiar with emacs, M's command structure is very
  58. similar to that.  Most common emacs commands are supported with the key
  59. strokes you are used to.
  60.  
  61.  
  62. Cursor Motion:
  63.     The arrow keys, [pageUp] and [pageDown] keys move like you expect
  64. them... The analogous emacs move cursor commands [^F] forward, [^B]
  65. backward, [^P] up, [^N] down, [Alt V] pageUp and [^V] pageDown keys are
  66. supported.  The [Home] and [End] keys work slightly differently than
  67. expected...  When you first type [Home] the cursor moves to the front of
  68. the line, the second time it moves to the top of the page, the third time
  69. to the top of the file.  The [End] key works similarly.  
  70.  
  71. The emacs commands [^A] front of line, [^E] end of line [Alt <] top of
  72. file, [Alt >] end of file also work. 
  73.  
  74. [^RightArrow] moves right by one word (same as [Alt F]). 
  75. [^LeftArrow] moves left by one word (save as [Alt B]).
  76. [^UpArrow] moves up by paragraphs (in Cmode a paragragh is a curly brace).
  77. [^DownArrow] moves down by paragraphs (in Cmode a paragragh is a curly brace).
  78.  
  79. Notice as you move the cursor the 2 numbers on the StatusLine followin the
  80. buffer name change... they are the line number and the column number. You
  81. can move to a particular line using the goto command [Alt G (number)
  82. Enter].  (You can abort this dialog with an [Escape] or a [^G]; [^G] is
  83. the all purpose abort.)
  84.  
  85. The last of the simple cursor movement commands is the exchange cursor and
  86. mark command [^X .].  Prior to executing this it is useful to set a mark to
  87. a particular location.   Both [Alt Spacebar] and [^Spacebar] set the mark
  88. to the current cursor position.  Try setting a mark and switching the mark
  89. and the cursor.
  90.  
  91. As a final suggestion, I like it better when the cursor moves quickly...  I
  92. use the dos mode command in my autoexec.bat to do this for me.  In my
  93. autoexec I have:
  94.     mode con rate=32, delay=1
  95.  
  96. Deleting and Copying:
  97.     M has a killBuffer that it stores things in.  It uses the
  98. killBuffer as a clipboard for block copys and pastes.  There are a number
  99. of ways to put text into the killBuffer.  The first way is to copy a block
  100. into it.  Set a mark [Alt Spacebar] (or [^Spacebar]), move the cursor to a
  101. new position, and do an alt wipe [Alt W].  The text between the mark and
  102. the cursor has been copied into the killBuffer.  Next move the cursor to an
  103. empty line and do a Yank [^Y].  Do another Yank, and another...  You now
  104. have multiple copies of the text. 
  105.     Another way to get text into the killBuffer is to do a control
  106. wipe.  Like the last time, set a mark [Alt Spacebar] or [^Spacebar], move
  107. the cursor, and Wipe [^W].  This Wipe deletes the text while moving it into
  108. the killBuffer.  The deleted text can now be yanked anywhere you want it. 
  109.     There are more methods of putting text into the killBuffer.  You
  110. can kill individual lines with [Alt K] and [^K].  [^K] kills from the
  111. cursor to the end of the line.  [Alt K] kills the whole line irrespective
  112. of where the cursor is in the line.  If one kill command directly follows
  113. another, instead of throwing out the old killBuffer and replacing it with
  114. the new kill, the killBuffer appends the new kill to the existing
  115. killBuffer.  Try killing a whole bunch of lines in a row and yanking them
  116. all back in one yank.
  117.     There are a few more ways to wipe text into the killBuffer, you can
  118. kill by words.  The [^Backspace] and the [^Delete] are word delete left and
  119. word delete right.  Again multiple consecutive kills append into the
  120. killBuffer.  
  121.     Finally there are some word copys into the killBuffer, [Alt
  122. Backspace] and [Alt Delete].  Multiple consecutive copys append into the
  123. killBuffer.  Notice the control commands [^W] [^Backspace] and [^Delete]
  124. are kills while the alt commands [Alt W] [Alt Backspace] and [Alt Delete]
  125. are copys.
  126.     There is one more yank feature, the yankPop [Alt Y].  It is easiest
  127. to describe what it does by actually doing it.  Move to the line of 1's and
  128. do an [Alt K] immediately followed by a [^Y], do the same thing on the line
  129. of 2's, next on the 3's, and finally on the 4's.  Now we are in a position
  130. to show off the yankPop.  Move the cursor to a blank line and yankPop [Alt
  131. Y].  And [Alt Y] again and again and again...  There is really a ring of 4
  132. different killBuffers.  When you kill something it is put into the next
  133. killBuffer so that the last 4 kills are always available.  The [^Y]'s yank
  134. the current killBuffer again and again and again.  The [Alt Y]'s pivot the
  135. last yank with previous yanks in the killBuffer ring.
  136.  
  137. 11111111111111111111111111
  138. 222222222222222222222222222222222222
  139. 3333333333333
  140. 444444444444444444444
  141.  
  142.  
  143.     The simple one character [Delete] and [Backspace] do not go into
  144. the killBuffer.  (The word deletes do.)  (The emacs commands [^D] delete
  145. right and [Alt D] delete word right are also supported.)
  146.  
  147.     There are 2 special White Space deletes, the [Alt ,] which deletes
  148. whitespace right, and the [Alt .] which deletes right and left whitespace.
  149. Try putting your cursor in the middle of the line 5 lines down (between the
  150. ABC and the DEF), and type [Alt ,].   Then move your cursor left a little
  151. bit and  [Alt .].  These white space deletes are particularly useful in 
  152. macros...
  153.  
  154. ABC                                       DEF
  155.  
  156.     There are a five other commands that I am listing under the
  157. category of Deletes and Copys... they are:
  158. [^T] transpose characters
  159. [Alt L] lowercase word        [Alt U] uppercase word
  160. [Alt C] capitalize word        [^C] uncapitalize work
  161.  
  162. Try them out!  Notice for example that the transpose command transposes the
  163. letter the cursor is on with the letter before the cursor except at the end
  164. of line... (there is no character past the end of line)
  165.  
  166.  
  167. Undo and Redo:
  168.     One of the most useful (important) features in M is the [^-] undo
  169. and the [Alt -] redo.  If you hold the [^-] key down, you will undo all the
  170. editing of this file this session.  If you hold the [Alt -] key down, you
  171. will see that editing redone.  The undo/redo history is essentially
  172. infinite, you are limited by your disk space.  Only commands that change
  173. the content of the file are recorded in the undo file.  (cursor motion,
  174. searches, etc. are not recorded)
  175.     M supports only one undoFuture per file, I'll elaborate.  Suppose
  176. you have made 5 changes to a file and you undo the last two of them.  At
  177. this point there are still three changes in your history and now a future
  178. of two changes.  If you type a letter (make any change to the file) you
  179. will cutoff your old future and begin a new one.  You will still have your
  180. history, it will be your old history of three changes plus your newest
  181. insertion.  But you will not be able to undo to the earlier state of 5
  182. changes to the file.  Hence, be very careful of what you type when you do a
  183. large undo and you plan on redoing...  
  184.     One of the most common things I do with undo/redo (other than
  185. undoing some command I don't like) is to recover a piece of code that I
  186. deleted very early in the current M edit session...  I undo to when the
  187. code block existed.  I set a mark [Alt space] and do an [Alt W] copy into
  188. the killbuf.   (the copying does not change the file hence has no effect on
  189. the undo/redo history)  Immediately I return to the future with [Alt -],
  190. then yank [^Y] the desired block.  Now, try undoing back to the beginning
  191. of these instructions...
  192.     In the rest of this tutorial you can recover from any command by
  193. [^-] undoing.
  194.  
  195.  
  196. Window Control:
  197.     The primary window manipulation commands are 
  198. [^X 1] make one fullsized window    [^X 0] remove this window 
  199. [^X 2] split window horizontally    [^X 5] split window vertically 
  200. [^L] center the cursorline
  201.  
  202. Try typing [^X 2] [^X 1] and then [^X 5] [^X 1].
  203.  
  204. (both [^X 2] and [^X 5] gives you two windows... the 5 stands for .5)
  205.  
  206.  
  207.     The normal window splitting commands keep your screen windows
  208. tiled...  M actually supports messy screens of overlapping windows.  You
  209. can rearrange and resize your windows to your hearts content with the
  210. following commands.  I use these commands only occasionally, they are less
  211. useful...
  212.  
  213. [Alt endkey] grow window right        [Alt homekey] shrink window left
  214. [Alt pagedownkey] grow window down    [Alt pageupkey] shrink window up
  215. [Alt (arrow key)] move window
  216.  
  217.     After rearranging the window layout on the screen, the next thing
  218. to do is to put a variety of files in those screens.  To open a file type
  219. [^X ^F] and then a filename.  If the file does not exist, it will open a
  220. new file.  Type [^X 2] and then [^X ^F] [\autoexec.bat].  The [Insert]
  221. pivots through the open files.  The [Shift Insert] pivots the other
  222. direction.  [^Insert] moves from window to window.  (The emacs commands 
  223. [^X X] next buffer and the [^X O] other window are supported.)  You can
  224. also go to a buffer by name by using the [^X B <bufferName> ] command or
  225. the [^X ^F <fileName>] command.
  226.  
  227.     There is one more major item under window control.  They are screen
  228. bookMarks.  The current screen configuration can be stored on a stack.  You
  229. can push a screen configuration on to the stack with the [Alt +] command
  230. and pop it off with the [Alt =]...  When it is popped off that screen is
  231. restored.  The [Alt J] command can also be used push or pop screens...  You
  232. can go to a particular pushed screen using the [Alt J <digit>] command. 
  233. Try doing a push, ([Alt J P] notice a 1 appears between the mode
  234. parenthesis of the StatusLine.  Now go to the top of the file with
  235. [Home][Home][Home] and then type [Alt J 1].  You returned to the screen
  236. that was pushed.  Unload the the pushed screen with an [Alt =].  Screen
  237. pushes are done automatically when using a tags file [Alt T].  I will
  238. discuss the use of a Tags file in the search and replace section.
  239.  
  240.  
  241. File Control:
  242.     The next topic is File Control.  We have already used the command
  243. to open a file [^X ^F].
  244.  
  245.     The "save file" commands are:
  246. [^X ^S] save this file            [^X S] save all modified files
  247. [^X ^W] rename and write this file 
  248. [^X ^C] exit querying changed files    [Alt Z] exit saving changed files
  249.  
  250.     The "don't save file" commands are:
  251. [^X R] revert to save            [^X ^C] exit querying changed files
  252. [^X K] kill this file (get rid of this buffer, doesn't touch the disk copy)
  253.  
  254. You can also insert a file at the cursor...
  255. [^X I] insert a file at the cursor
  256.  
  257. In the a number of the above commands, the user is prompted for a
  258. filename.  In these prompt windows there are a number of special
  259. commands...  I will discuss the filePrompt dialogs in more detail later.
  260.  
  261.  
  262. Searching and Replacing:
  263.     There are a number of useful parenthesis matching routines:
  264. [Alt ^B] backward to matching {[(   [Alt ^F] forward to matching )]}
  265. Try them out!
  266.  
  267. Next there are the incremental searches...
  268. [^S] isearch forward        [^R] reverse isearch
  269. [Alt S] repeat last search    [Alt R] repeat last reverse search
  270.  
  271. In Exact Mode searches are case sensitive otherwise searches are lower case
  272. insensitive, upper case sensitive.  This means that lower case matches both
  273. upper and lower case while upper case only matches uppercase.  During an
  274. isearch [bacspace] and [^-] are an undo,  [^S] causes a search again
  275. forward,  [^R] causes a search again reverse, [^G] and [ESCAPE] exit, [^Y]
  276. yanks the first line of the killBuf into the search window, and [Alt /]
  277. does wordContinuation.  In regular expression mode, regular expressions can
  278. be entered into the incremental search prompt.
  279.  
  280.     In addition to the incremental searches there are jumbo
  281. search/searchAndReplace dialogs:
  282. [Alt ^R] jumbo replace dialog        [Alt ^S] jumbo search dialog
  283.  
  284.     When you type either [Alt ^S] or [Alt ^R] you enter a
  285. search/searchMode prompt.  Type an [Alt ^S] and then an [Escape].  You will
  286. have seen a prompt window querying:
  287.  
  288. !! search for: ?   eXact=^X Local=^L Reverse=^R Token=^T regexP=^P liNes=^N
  289.  
  290.     [^G] aborts the search.
  291.     [^X] toggles the case sensitivity.
  292.     [^L] toggles the search to local or global...  if the L flag is not
  293. set, you will be prompted for the directory/filenames (with * and **
  294. wildcards) to search through.  (it's a grep)  If the L flag is set, the
  295. search will be in the current buffer.  If the L flag is not set, (you are
  296. doing a global search) after the search is done the screen will be split
  297. with the lower window containing a list of all the files and lines where
  298. the search string was found...  Use [Alt N] to go to the next one.  (This
  299. works the same as in the compile command.  Search for "[Alt N]" and you
  300. will find a larger discussion of the [Alt N] command later in this text.)
  301.     [^R] toggles a reverse search... it forces a Local search.
  302.     [^T] toggles token searches... the search pattern is considered a
  303. single token, there must be non-word characters around it.  (For example: 
  304. suppose you were searching for "the", with token searches turned on the
  305. search would skip the "the" in "other" because of the "o" and "r" around it.
  306.     [^P] toggles regular expression mode, regular expressions can be
  307. used in your search string.  At this point I will give a very short
  308. discussion of regurlar expressions: 
  309.  
  310.     (NOTE: fill this in later!!!!)
  311.  
  312.  
  313.  
  314.  
  315.  
  316.     During an iSearch [bacspace] and [^-] are and undo,  [^S] causes a
  317. search again forward,  [^R] causes a search again reverse, [^G] and
  318. [ESCAPE] exit, [^Y] yanks the first line of the killBuf into the search
  319. window, and [Alt /] does wordContinuation.  In regular expression mode,
  320. regular expressions can be entered into the incremental search prompt.  In
  321. an iSearch typing the enterKey is the way you search for a newline.  In a
  322. jumbo search/replace dialog the enterKey must be entered using a [^Q]. 
  323. (See the "Quoted Insert" section.)
  324.  
  325.     I include word continuation with search and replace.
  326. Word Continuation:
  327.     Word Coninuation [Alt /] is a very handy command, I use it all the
  328. time.  After you have typed a few letters and then typed [Alt /] M attempts
  329. to guess the word you have started typing.  I do this by looking at the
  330. letters you have typed, do a reverse search for a word with starting with
  331. the letters you have typed and if I find it, I extend the word you are
  332. typing by the word found.  If I search all the way to the top of the
  333. document and find no match I do a forward search.  This feature is a
  334. solution to the problem that I like to have long expressive variable names
  335. but I hate to type them out.  This way I have to type them once when I
  336. declare them and after that I only have to type a few letters and then
  337. extend the name.  It is great for #defines where I can't remember where I
  338. put underscores.  I don't have to remember, I just type a few letters and
  339. continue the word.
  340.  
  341.  
  342. Tag Files:
  343.     I am currently not satisfied with my C/C++ tagging facilities...  I
  344. have turned off this feature and I will be reimplementing something I like
  345. better soon.  If it bothers you that this feature doesn't currently work,
  346. yell!  The squeaky wheel gets the grease...  
  347.  
  348. The [Alt Q] function search has not been turned off, but I don't like it
  349. much either...  (It isn't fast and it isn't pretty.)  Currently it builds a
  350. list of the subroutines in a file and lets you move around in it like an
  351. [Alt ^S] search.
  352.  
  353.  
  354. Diffs:
  355.     [^X E] compares 2 windows (equal)... If you split the screen [^X E]
  356. will compare the two windows starting from the current locations of the
  357. cursors.  If the characters are the same, both cursors are moved
  358. forward...  The cursors will stop at the first differences...  After
  359. finding the first difference.  To find the next difference, we must
  360. reposition the cursors to equivalent places past the first difference and
  361. do another [^X E].  eXact Mode affects the [^X E] command...  When eXact
  362. case is off, the diffs are white space independent...  that all strings of
  363. white space are treated as if there are a single space character.  Then
  364. difference that are only white space differences are ignored...  When eXact
  365. Mode is on, the comparisons must be exact, white space matters.
  366.     [^X D] diffs directories.  You will be prompted for the directories
  367. you want to compare.  The diff happens in 2 passes.  The first pass goes
  368. through the two directories and builds a list of the files that occur in
  369. only one place and the files that occur both places but are not the same. 
  370. After compiling the list the screen is split and the first pair of files
  371. that occurred in both directories but have a difference are opened and a
  372. [^X E] diff is started...  After walking through that file (with multiple
  373. {^X E] diffs) the next pair is called up with an [Alt N] (next)...  After
  374. the last pair, the diff compile buffer is brought up.
  375.  
  376.  
  377. Line Wrapping/Reformatting:
  378.     There are two principle reformatting commands, they are the [Alt P]
  379. reformat the current paragraph command and the [^TAB] retab the line
  380. command.   The [Alt P] command reformats a the current Paragraph.  It uses
  381. the wrapColumn (settable with the [Alt TAB] command or the M environment
  382. variable) as the target line length.  The top of a paragraph is a line with
  383. leading white space or a first character in the first column that is a '.'
  384. or a '\'.  The end of a paragraph is a line with leading whitespace or a '.'
  385. or a '\'.  In Cmode the [Alt P] only affects comments, it reformats them.
  386.     When WrapMode (or Cmode) is on, the spacebar not only inserts a
  387. space it also tests the current line length, and if it is longer than the
  388. wrapColumn it causes a paragraph reformat.  (In Cmode only comments are
  389. affected.)
  390.     [Alt TAB] is used to set both the wrapColumn and tabStops.  You
  391. will first be prompted for a wrapColumn.  Only numbers between 0 and 512
  392. are legal answers.  Answers outside this range are ignored.  Next, you will
  393. be prompted with the current tabStop sequence, for example if the sequence
  394. were:   tabs=2 8 4   the first tabStop is in the 2nd column, the second is
  395. in the 10th column, the third is in the 14th column, the fourth is in the
  396. 18th column, the fifth is in the 22nd column... (it repeats tabStop every 4
  397. columns because of the terminal 4)
  398.     As an aside, M supports two tabbing conventions.  The tab
  399. convention I like the best is that where a tabStop and a tab are the same. 
  400. That is when you hit the tab key, one tab character is inserted into the
  401. text and in the screen drawing I interpret the width of the white space to
  402. be whatever it needs to be to fill to the next tabStop.  Then with the
  403. example tab setting tab=2 8 4, after a newLine, when you first hit a tab,
  404. one tab character is inserted into the file and the cursor moves to column
  405. 2.  When the tab key is hit again a second tab character is put into the
  406. text and the cursor moves to the 10th column.   On the third tab key, a
  407. third tab character is inserted into the file, the cursor is moved to the
  408. 14th column.  This is the default tabbing convention.
  409.     I had a number of users who complained bitterly about this
  410. convention.  They complained that the dumbest printer programs wouldn't
  411. print their files properly.  The convention they wanted was one where
  412. tabStops were disconnected from the tab character.  The tab character
  413. always took you to a column that is a multiple of 8 irrespective of the
  414. tabStops.  The editor uses a combination of tab characters and spaces to
  415. move to a tabStop.  Then in our example (tab=2 8 4) the first time the
  416. person types a tab 2 spaces are inserted, The second time, the two spaces
  417. are removed and a tab character is inserted (taking you to column 8) and
  418. then two more spaces are inserted after the tab character...  In the second
  419. mode, M inserts the most efficient combination of spaces and tabs when a
  420. tab is typed.  You can toggle between the two different tabbing conventions
  421. using the [^X M T] command.  You can also toggle the convention by setting
  422. the M environment variable with the -h (hard tabs) option.
  423.     The [^TAB] command reindents a line.  It is most useful in Cmode
  424. where it does a very "smart" C indentation...  In text mode it just
  425. reindents the same as the first non-blank line it.
  426.  
  427.  
  428.     This brings up the topic of edit Modes...  All Modes are toggles,
  429. Changing Edit Modes:
  430.     [^X M] followed by one of [C] [O] [W] [X] [S] [I] [T] [P] or [B]
  431. Toggle the particular edit modes:
  432. C) Cmode: toggles smart indenting, parenthesis matching, C programming mode
  433. O) Overwrite: toggles between overwriting and inserting
  434. W) Wrap: toggles on/off automatic line wrapping (usually for a text mode)
  435. X) eXact: toggles search case sensitivity
  436. S) Scroll: toggles the vertical scrolling method
  437. I) cIndent: toggles the C indentation method
  438. T) Tab: toggles the use of hard tabs
  439. P) regular exPressions: searches use regular expressions
  440. B) Binary: toggles displaying as a binary
  441.  
  442.     Notes about the modes... 
  443.     Toggling eXact Mode on causes searches to be case sensitive
  444. otherwise searches are lower case insensitive, upper case sensitive.  This
  445. means that lower case matches both upper and lower case while upper case
  446. only matches uppercase.  eXact Mode also affects the [^X E] diffs.
  447.     The Cmode toggle [^X M C] turns on/off the "smart" C indenting,
  448. color comments, comment wrapping, the [^upArrow] [^downArrow] (up/down
  449. paragraph in text mode, up/down to matching '{' or '}' in C mode), etc...
  450.     The Binary mode toggle [^X M B] just displays the text in a hex mode
  451. with 16 characters/line.
  452.     The cIndent toggle [^X M I] toggles between two indenting styles of
  453. Cmode.  The default mode is pretty, the alternate style is gross but I had
  454. a number of people demanding it so I support it.  I don't want to encourage
  455. the use of that style so I won't discuss exactly what it is.  If you must
  456. you can experiment with it.  (It is also setable through the M variable.) 
  457.  
  458.  
  459. Now that I have mentioned all the Mode flags, it is appropriate to I should
  460. redescribe the StatusLine.  The StatusLine I currently have on this file
  461. looks like this:
  462.  
  463. ** m.tut 434 16 (W) c:/work/m/m.tut  #B = 32
  464.  
  465. m.tut is the buffer name.
  466. 434 is the line number the cursor is on.
  467. 16 is the index in the line.
  468. (W) means WrapMode is on.  (all Modes would appear here)
  469. c:/work/m/m.tut is the absolute path name
  470. #B = 32 tells me the number of pages of memory I am currently using
  471.     (See Known Ways to Kill M at the bottom of this file for a further
  472. discussion of this variable)
  473.  
  474. When you first start M the StatusLine has == instead of ** at the beginning
  475. of the StatusLine.  This signifies the file is identical to what is out on
  476. the disk (unchanged).  When I change it the == turns into **.  Some files
  477. come up as %% instead of ==.  This means they are read only.  When you type
  478. a [^X] the second character temporarily becomes a ^.  When you type
  479. an [Escape] the second character temporarily becomes a &.  
  480.  
  481.  
  482.  
  483.  
  484. Macros:
  485.     M supports keystroke macros.  Type [Alt M] to begin recording a
  486. macro.  You will be prompted for the key to bind the macro too, you can
  487. bind it to any unbound key (any key that beeps when you type it, I usually
  488. use a function key).  Then type the characters/commands you want to
  489. execute.  When you are done type [Alt M] again to end the recording.  Now
  490. when you type the key you bound the macro to, the macro will be played. 
  491. Your current set of macros can be saved by typeing [Alt ^M] (save all
  492. current macros).  Whenever you load m you get all your current macros
  493. loaded by default (the live in a file called macrofil.$m$ in your home
  494. directory (the directory specified by the environment variable HOME) (if
  495. you have not set a HOME variable I fall back to using the TMP then TEMP
  496. variables directory.)  There is currently a limitation on the macros, you
  497. can not call another macro from inside of a macro.  (this prevents
  498. recursion)  I will probably lift this restriction sometime.  When an
  499. operation fails, I generally abort the macro... (for example if a search
  500. fails I will not continue the macro...)  Also if you want to stop a macro,
  501. generally [^G] (the all purpose abort) aborts the macro...
  502.     There is another simple macro facility, a repeat execute commmand
  503. [ESCAPE (number) (key)] execute (key) the given (number) of times.  For
  504. example if you type [ESCAPE 27 *] you will get a line of stars 27 long. 
  505. You can invoke a macro with this command.  Suppose you have bound a macro
  506. to F1, you could execute that macro 10 times by typeing [ESCAPE 10 F1].  
  507. The [^G] abort will abort this type of macro too... I should mention the
  508. abort key.
  509.  
  510. Abort:
  511.     [^G] is the all purpose abort.  It aborts most things...  (not
  512. all)  If you notice some operation that you think it should abort and it
  513. doesn't, complain and I'll fix it.  It aborts most searches, macro
  514. executions, etc...  (The reason ^G is the abort key is historical.  ^G
  515. (hex 0x07) was the teletype symbol for the bell...  Typing ^G rings the
  516. bell.)
  517.  
  518.  
  519. Inserting Literals, the Quoted Insert:
  520.     [^Q (any key)] is the quoted insert.  We use this to insert keys as
  521. iterals into text...  For example you can insert a  into the code by
  522. typing a [^Q ^B].  You can alway insert decimal values of ascii codes
  523. by using the numeric keypad keys while holding the Alt key down. 
  524. In a search prompt and any file that is in Binary Mode you can insert hex
  525. directly by typing [^Q] and a two digit hex number e.g. [^Q 9 F].
  526.     
  527.  
  528. Information: 
  529.     There are a few miscellaneous data that you might want to insert
  530. into your text.  By typing [Alt I] and then one of [D], [T], [P], [A], [+],
  531. [-], [=], or a digit string, the following data can be entered into your
  532. text:
  533.  
  534. [Alt I] information, [D]-Date, [T]-Time, [P]-Pathname, [A]-Absolutepath 
  535.  
  536. Entering a digit string sets a static counter...
  537. [Alt I +] outputs the counter and then increments it.
  538. [Alt I -] outputs the counter and then decrements it.
  539. [Alt I =] outputs the counter and leaves the counter unchanged.
  540.  
  541. I find these most useful for use in macros.  For example to document
  542. changes to code I have macros that insert a bunch of boiler plate including
  543. the current date.  The [Alt I] command works correctly in prompt windows.
  544.  
  545.  
  546. Shells:
  547.     You begin a dos shell with [^Z].  Do not confuse this with the exit
  548. saving all changed files command [Alt Z].  When you shell out to dos, you
  549. do not really leave M, you suspend M...  If while out in dos you somehow
  550. crash your machine you will not be able to resume that edit session... 
  551. That means that if have not saved the file you will have lost work.  There
  552. are some very confusing scenarios that can happen for example, suppose you
  553. shell out and forget that your are in a shell and start a new M session on
  554. top of the old one...  (I currently don't catch this...)  Then you open a
  555. file and don't see changes you know you made... (they are in the suspended
  556. M session and haven't been saved yet...) you reimplement those changes, do
  557. even more things finally exit that session, realize you're in a shell,
  558. resume the suspended M session, and find your files translated back to that
  559. earlier state (I don't currently detect that the files changed on
  560. me...)...  Its a bad situation...  If you ever find yourself in this
  561. situation the safest things you can do are a revert to saved (return to the
  562. disk image of the file) or exit without saving anything.  An unsafe thing
  563. that you might try is to save your changed files to a different name... 
  564. Whatever you do it is a bad business.  It can be confusing and frustrating
  565. when you start having multiple M sessions suspended...  I recommend you
  566. don't do it.  I use dos shells to go do something, and then I return
  567. immediately to the M session. (To resume an M session type "exit" at the
  568. dos prompt.  Exit is a normal dos command.)  When I shell out I copy most
  569. of the memory image of M to your "TMP" directory, (I look at the TMP
  570. environment variable, see care and feeding section...) leaving only a small
  571. loader to resume executing later...  You regain most of your ram for the
  572. spawned dos session.
  573.     If you want to execute one dos command and capture the output I use
  574. the [^X N] command.  The default command is make.  I use the [^X N] command
  575. to do compiles.  I attempt to parse the output after the dos command has
  576. run.  I recognize most compiler error messages and I will open the file and
  577. take you to the line number of the error...  I split the screen and put up
  578. the file where the error occurred in the top window and in the bottom
  579. window I put the compile output with the top line showing the current
  580. error.  You can move the cursor to the *compile* buffer and you will notice
  581. the cursor is on the line of the current error...  When [Alt N] is typed
  582. the cursor in the compile buffer is moved down one line and I attempt
  583. parsing from there.  While you are in the *compile* buffer you can position
  584. the cursor one above an error message you are interested in, then typeing
  585. [Alt N] will take you to it.
  586.  
  587.  
  588. Next, I will discuss a topic I have been postponing, the file/buffer dialog
  589. prompts.
  590.  
  591. File/Buffer Dialog Prompts:
  592.     In most file prompting dialogs and in the buffer prompt dialog ([^X
  593. B]) there is a subdialog accessible by typing a space...  When a space is
  594. typed in one of these file/buffer prompts I attempt name completion...  If
  595. there is only one file/buffer with the letters already typed I finish the
  596. typing for you.  If there is more than one name that matches I continue the
  597. typeing up to the point where the names differ and I pop down a subwindow
  598. with a list of the possible matches.  You can move the cursor down with the
  599. arrow keys and select the file you are interested in.  One way to select it
  600. is by moving the cursor to it and hitting the enter key.  For example try
  601. typing [^X B] then a space.  Move the cursor to m.tut and hit [Enter], you
  602. are there.  Try a different buffer...  The same type of thing can be done
  603. after [^X ^F].  Sometimes I use wild cards and the space (for filename
  604. continuation).  I type [^X ^F] and then *.cpp and then finally a [Space], I
  605. get a directory listing of all my .cpp files.  I select more than one file
  606. by moving my cursor to a particular file, hit the spacebar, move to another
  607. hit the spacebar, etc...  (hitting the spacebar is a toggle, hitting it a
  608. second time unselects a file.)  After I have selected all the files I am
  609. interested in I hit [Enter], and they are all loaded.  Just like in the
  610. grep I can use the * in directory names and the ** (the wildcard directory
  611. name that matches the "." and all subdirectories) in the filenames. 
  612. Sometimes I use the [^X ^F] dialog to do a file find for me...  For example
  613. I can search from the root for m.tut by typing in the [^X ^F] prompt:
  614. /**/m.tut and then a spacebar...  M will show you where all the "m.tut"
  615. files live and give you the opportunity to open the ones you are interested
  616. in.
  617.     There are a few other "special" commands active in the [^X ^F]
  618. prompt, the [:] key is special, if you are any where in the prompt and you
  619. type a "c:", when I see the colon I realize you must have just typed a
  620. drive letter and I clean up the prompt and show you the default directory
  621. on the appropriate drive...
  622.     The [/] and [\] keys are also "special".  (In a filename prompt M
  623. considers all types of slashes to be directory seperators...)  If you type
  624. a slash following another slash, I realize two slashes in a row makes no
  625. sense as a directory name... I consider that to be a wild card for the root
  626. directory, I make the prompt be the root directory.
  627.     Another "feature" true in general for all prompt dialogs is that if
  628. the cursor is in the first column and you type a "normal" character, I
  629. empty the prompt first before I insert your character.  Sometimes you don't
  630. want this "feature" to happen, you can turn this behavior off in the
  631. current particular instance by typing an [Insert].
  632.     One last note while I am on the topic of prompting dialogs...  The
  633. prompt windows are not that different from most other windows...  I do
  634. yanks and [Alt W] copys all the time in them...  For example sometimes in
  635. making a batch file I want a list of files in a directory.  I start a [^X
  636. ^F] dialog, hit a spacebar, enter the file list window, set the mark at the
  637. top, go to the bottom, and do an [Alt W] to copy it into the killBuffer.  I
  638. [Escape] out of that dialog and yank the killbuffer into my batch file. 
  639. Then I make up a macro that does something to each file name.
  640.  
  641.  
  642. Help:
  643.     The documentation and online help is sparse...  This tutorial is
  644. the most extensive help discussion I have.  It will not be a static
  645. document, I will be enlarging it with more general discussions about the
  646. internal operations of M.  There are presently 3 online help options, all
  647. of them accessed through a [^H].  They are:
  648.     [^H H] bring up the m.hlp file    [^H B] describe keyBindings
  649.     [^H F] describe Functions
  650.  
  651.     I think the [^H H] is the most useful.  The m.hlp contains a
  652. complete but extremely terse description of all commands.  It is arranged
  653. by topic with some miscellaneii at the end.  As a note, put the m.hlp file
  654. in the same directory as the m.exe executable.  
  655.     The [^H B] command gives a list of active keys and the subroutines
  656. currently bound to them.  
  657.     The [^H B] command is currently only partially implemented.  The
  658. descriptions of the commands are not tabulated, there are only question
  659. marks where descriptions should be.
  660.  
  661.  
  662. Execute By Name:
  663.     Commands in M can executed by name.  The names are the actual
  664. subroutine names of my code.  You begin the execution by typeing [Alt X]
  665. and then in the prompt dialog you type the subroutine name...  The [Space]
  666. does name continuation...  If you type a space at the very beginning you
  667. will get a list of commands (very much like the buffer name list).  You can
  668. continue typing the name or you can move your cursor to the command (using
  669. the arrow keys) and execute the command by typing [Enter].  If you want to
  670. get a copy of this list just set a mark and do an [Alt W] to copy the list
  671. into the killBuf then open a writable file and yank it in.
  672.  
  673.  
  674.  
  675.  
  676. Care and Feeding of M:
  677.  
  678. 1) Put M.EXE and M.HLP in the same directory somewhere on your path
  679.  
  680. 2) Set a TMP environment variable to a directory for temp files (for
  681. example, make a directery off the root called c:\temp and in your autoexec.bat
  682. use a set command to point to it...  put the following line in your
  683. autoexec:
  684.     set TMP=c:\temp
  685.  
  686. M will put its temporary files here...  periodically delete the contents of
  687. this directory...  M usually cleans up after itself but if you exit M
  688. ungracefully, (for example you shell out and crash or reboot before
  689. returning to M) I will have left some garbage in TMP.  (If there is no TMP
  690. variable M will look next for a TEMP variable.  M will complain if it can not
  691. find either of these...)
  692.  
  693. 3) Set a HOME environment variable to a home directory...  The macrofil.$m$
  694. and the startup.$m$ files live here.  If you do not set a HOME variable m
  695. will use the TMP variable.  The downside of not setting a HOME variable is
  696. that if you then delete everything in c:\temp, you will lose the macros you
  697. had saved...  As an example, make a directery off the root called c:\home and
  698. in your autoexec.bat use a set command to point to it...  put the following
  699. line in your autoexec:
  700.     set HOME=c:\home
  701.  
  702. 4) Optionally set SWAPDIRS as a path variable to use for swap files:
  703.     set SWAPDIRS=d:\temp;c:\temp;j:\temp
  704. m will swap to d:\temp until it is full than to c:\temp etc.
  705.  
  706. 5) Optionally set the environment variable M (in the autoexec).  With the M
  707. environment variable you can customize many of the default behaviors of M.
  708. An example set command might be of the form: 
  709.  
  710.     set M= -cXXXXXX -i -p -s -t4 -wDDD
  711.  
  712. There are many different M options, I will list them:
  713.  
  714.     -a1,a2    set alphabets,    a1=wordChars,    default is A-Za-z0-9_
  715.                 a2=symbolChars,    no default
  716.         The alphabets are used to determine beginning/end of words.
  717.  
  718.     -cXXXXXX is a 6-digit hex number specifying colors, each digit
  719.         specifies a color
  720.     
  721.     X1 is the StatusLine backGround color
  722.     X2 is the StatusLine foreground color
  723.     X3 is the text backGround color
  724.     X4 is the text foreground color
  725.     X5 is the Cmode text comment backGround color
  726.     X6 is the Cmode text comment foreground color
  727.  
  728.         The Colors are:
  729.     BLACK        =    0
  730.     BLUE        =    1
  731.     GREEN        =    2
  732.     CYAN        =    3
  733.     RED        =    4
  734.     MAGENTA        =    5
  735.     BROWN        =    6
  736.     LIGHTGRAY    =    7
  737.     DARKGRAY    =    8
  738.     LIGHTBLUE    =    9
  739.     LIGHTGREEN    =    A
  740.     LIGHTCYAN    =    B
  741.     LIGHTRED    =    C
  742.     LIGHTMAGENTA    =    D
  743.     YELLOW        =    E
  744.     WHITE        =    F
  745.  
  746.     The default color choices are -c9f8f8b
  747.  
  748.  
  749.     -h  hard tabs, (indentation is a mix of spaces and tab chars)
  750.         See the discussion in the Line Wrapping/Reformatting section
  751.  
  752.  
  753.     -i  toggle cIndent Mode, same as [^X M I]
  754.         See the discussion in the Edit Modes section
  755.  
  756.     -l  load file lines as text always... (don't auto sense binary)
  757.         
  758.     -p  paid your money, (don't show startup message)
  759.     
  760.     -s  toggle the Scroll Mode, see [^X M S] in the Edit Modes section
  761.  
  762.     -t,-tc  set the tabs...  -t  and -tc refer to tab settings for
  763.         normal file and Cmode files...  You can set both, one or
  764.         neither of them.  Here are some examlpes:
  765.  
  766.         set M= -t4 -tc4
  767.         // sets both normal and cmode tabs to 4
  768.  
  769.         set M= -t8 4 -tc2
  770.         // sets normal tabs to 8, 12, 16, 20, ... cmode tabs to 2
  771.  
  772.         defaults are -t8 -tc4
  773.  
  774.     
  775.  
  776.     -v  attempt checkout of read only files
  777.     
  778.     -wDDD  set wrap column, DDD is a decimal number for example:
  779.         set M= -w78  
  780.         // sets the wrap column to be 78
  781.         
  782.         default is -w76
  783.     
  784.  
  785. 6) Optionally set up an M.CFG file.  M.CFG files are my response to user
  786. demands to set more options than can be comfortably set in an environment
  787. variable.  There are three statement types, they are:
  788.     set X=YYYY
  789.     include FILEXXXX
  790.     bindKey  KEY_TO_BIND FUNCTION_NAME
  791.  
  792. The set command sets environment variables... (you could set the M varaiable)
  793.  
  794. The include command allows you to include files into the M.CFG file
  795.  
  796. The bindKey command allows you to change the default key bindings... You
  797. can move commands to keys that you like...  To get the complete list of
  798. commands see the [Alt X] discussion.  To get correct names for the keys see
  799. the [^H B] command...  I don't recommend you change the bindings because
  800. when someone else uses your machine or you use someone elses, you will
  801. become frustrated, you will not get the bindings you've grown to know and
  802. love.  ;-)
  803.  
  804. M.CFG files are searched for in the following way...  I first search in the
  805. directory you were in when you started M.  I search in that directory's
  806. parent.  I search in your HOME directory.  The first place I find an M.CFG
  807. file I stop and do not look further.  I look up the M environment only
  808. after looking up M.CFG files.  (That way you can set it in your M.CFG file.)
  809. I look up the TMP and HOME variables when I need them.
  810.  
  811.  
  812.  
  813.  
  814. Known Ways To Kill M:
  815.     1) M uses a paged memory scheme for the contents of your files.  
  816. When you first open a file if you are only looking at the beginning of the
  817. file I don't get anything except the beginning of it...  As you try to look
  818. at other parts of the file I bring more of the file into memory.  I bring
  819. it in 2K at a time, 2K buffers.  The number on the StatusLine #B = 39 for
  820. example means I am currently using 39 2K buffers.  If you bring in a really
  821. big file and page through it you will see this number climb and climb and
  822. eventually stop climbing...  Now as you continue looking at new pages old
  823. pages are being swapped out...  (into swap filees in your TMP directory if
  824. they are changed)  At this point I have used up all the system memory and I
  825. must relinquish a page of memory if I need it somewhere else.  (Now we are
  826. getting closer to how to kill M)  Only file contents can be paged out, I
  827. have other memory requirements that can not be paged.  I do not virtualize
  828. the data structures describing the files.  If you open another file I must
  829. relinquish memory for the file descriptors that can not be paged out...  If
  830. you open many files you will see the number of buffers start dropping... 
  831. If you open enough file so that the number of buffers gets to 0, M
  832. crashes.  Don't do this!  If you try to do really big things like open all
  833. the files on your hard disk, M will crash...  I don't have a good bail out
  834. method yet.  That will come in later editions...  If you know you are going
  835. to do something really big, save your files first.  (This whole situation
  836. is rarely a problem, I have had 500 files open at once, I estimate that M
  837. dies on my pc (with my memory configurateion) at ~700 open files.  File
  838. sizes are not an issue at all, only the sheer number of files.)
  839.     2) If you run out of disk space while M is saveing a file... M can
  840. crash in a variety of ways.  M does not cope well with these type of system
  841. errors...  Always maintain some free disk space.
  842.  
  843. If you find more ways to kill M, I am interested, especially if it is
  844. reproducible...  You can send mail to me at:
  845.  
  846.     Greg Gadbois
  847.     18 Hillside Ave
  848.     Amesbury Mass 01913
  849.  
  850.     My current email address is 
  851.     greg@dragonsys.com
  852.  
  853.  
  854. P.S.  I am adding a final note just as I release M Version 1.0... The 1.0
  855. version number denotes the first open release I have had.  That does not
  856. mean that M is a new and buggy product...  M has existed and has been
  857. evolving since 1988 as my personal editor.  I have frozen the current
  858. release as the entry-level shareware version of M.  I continue to evolve M
  859. and I have a "premium" version that has a number of additional features. 
  860. Among them is journal files (a continuous backup method so that even if the
  861. power goes out while editing, no work is lost).  I am charging $25 for the
  862. frozen shareware version of M and $35 for the premium version.  A native
  863. windows version of M also exists but is not yet ready for prime time.  It
  864. will be ready soon.
  865.  
  866.  
  867. P.P.S.  Keep those checks rolling in!  ;-)
  868.