home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / cpm / emacs / emacsbin.lzh / mapkeys.doc < prev    next >
Text File  |  1992-03-11  |  10KB  |  223 lines

  1. "Binding" is one of those words of emacs jargon that might
  2. be bothersome, but we have to use it.
  3.  
  4. The idea is that an editor contains a certain set of commands, 
  5. which are always the same commands no matter what keystrokes are 
  6. used to invoke them. The association of a keystroke to a
  7. command is called a "binding".
  8.  
  9. Editors derived from emacs have an internal structure that makes
  10. it easy to change the bindings ( unlike WordStar or VDE ).
  11.  
  12. On a big computer, you can change emacs bindings online; but z80emacs 
  13. has to fit in 64KB, so the bindings are done offline.
  14.  
  15. Z80emacs comes with a default set of bindings already installed. 
  16. These bindings are just fine for the terminal I use, but you 
  17. probably will want to change them in your copy of the program.
  18.  
  19. Here's how:
  20.  
  21. First, make sure you have a copy ( NOT your only copy! ) of ME.COM
  22. on your current disk and user area; make sure you have ZMECMDS.LST,
  23. ME.SYM, MAPKEYS.COM, and MECONFIG.COM.
  24.  
  25. Take a look at ZMECMDS.LST, but don't change it!
  26. This file contains a list of the names of all the commands in 
  27. z80emacs, and for each command there is a number.
  28.  
  29. The command names are in the format of the UECS ( Universal Editor
  30. Command Set ), version 1.0; each name starts with a prefix
  31. that assigns the command to a class of commands.
  32.  
  33. In order to customize the bindings, you will have to run two programs, 
  34. first MAPKEYS.COM and then MECONFIG.COM.
  35.  
  36. MAPKEYS.COM will read the ZMECMDS.LST file as part of its processing.
  37. Another part of its processing will be to read the keyboard, and 
  38. you'll be typing in these names. Fortunately, you won't have to type 
  39. in the whole name ( as we'll see later ).
  40.  
  41. MECONFIG.COM will read a file produced by MAPKEYS ( MAPTABLE.ZME ),
  42. will read ME.COM and ME.SYM, and will write the new bindings out to ME.
  43. COM. It installs the bindings by patching them into the program.
  44.  
  45. ======================================================
  46. =                                                    =
  47. = USING MAPKEYS.COM                                  =
  48. =                                                    =
  49. ======================================================
  50.  
  51. After you start MAPKEYS, it will tell you how many lines it read from 
  52. ZMECMDS.LST, and then ask you to "Enter a name: ".
  53.  
  54. If you just hit RETURN, it will list all the commands, one screenful 
  55. at a time, with "[Return to continue]".
  56.  
  57. Try typing "word" at this prompt ( leave out the quotes, hit RETURN 
  58. at the end of it ). MAPKEYS will list for you about 9 commands that 
  59. include the word "Word", and tell you how many commands it matched.
  60. Neat stuff, huh?
  61.  
  62. If you manage to match exactly one name, MAPKEYS will prompt you to 
  63. "Enter a keystroke sequence: ".
  64.  
  65. You can just type the sequence that you want to use to invoke the 
  66. command, and then hit RETURN. This is easy enough, but how do you 
  67. map something to RETURN? or to LINEFEED?
  68.  
  69. Aha, there's a trick! I figured that you wouldn't want to map the
  70. carat ( "^" ) to anything else ( in fact you can't, as I'll explain 
  71. later when I tell you what you CAN't map ), so:
  72.  
  73.     If you type "^M" ( a carat and an M ), MAPKEYS interprets it
  74.     as meaning ^M ( control-M, or carriage return ).
  75.  
  76. At the "Enter a keystroke sequence: " prompt, if you don't want to 
  77. make a new mapping for this command after all, just hit RETURN right 
  78. away.
  79.  
  80. There's one more trick you need to know about: how to UNMAP a key!
  81.  
  82. The problem is this: there is a predefined amount of space allocated 
  83. for the command dispatch tables. If you map ^J to something, MECONFIG
  84. will see that ^J used to be mapped to something else, and will 
  85. free up the slot in the table that was used by the old mapping.
  86.  
  87. But, if you map ^X^J to something, you've used up one of the empty 
  88. slots! Suppose you map it to EC-Word-Forw; MECONFIG does NOT assume 
  89. that you want to unmap ^F; it's legitimate to have more than one 
  90. sequence bound to the same command!
  91.  
  92. To keep from running out of slots in the table, you may have to 
  93. explicitly UNMAP some sequences by mapping them to
  94. "Undefined-Function".
  95.  
  96. ======================================================
  97. =                                                    =
  98. = WHAT'S A "SEQUENCE"; WHAT YOU CAN'T DO             =
  99. =                                                    =
  100. ======================================================
  101.  
  102. In the standard emacs command-space, there are 384 possible
  103. sequences of keystrokes that could be mapped to commands.
  104. ( but only 382 sequences ).
  105.  
  106. First of all, there are the 128 normal ASCII characters.
  107. In any proper emacs, they are all mappable; but in order to be
  108. able to keep up with your flying fingers, z80emacs had to make 
  109. a few compromises; four special characters, ^U, ^\, ^X, and ESCAPE,
  110. are hardcoded in the program, and can't be reassigned
  111. ( this defect came with the original microemacs code ),
  112. and the printable characters are all forced to be self-inserting
  113. ( type an 'A', get an 'A' in the file ).
  114.  
  115. Secondly, there are 128 "meta-characters", which you type by 
  116. hitting ESCAPE and then hitting any of the 128 normal ASCII 
  117. characters.
  118.  
  119. Third and last, there are 128 "control-X" characters, that you 
  120. enter by hitting ^X and then something else.
  121.  
  122. By the way, lhe other special characters I mentioned,
  123. control-U and control-\, are used when you want to start typing in
  124. a numerical argument to feed to the next regular command.
  125.  
  126. Thus, there are 284 different command sequences that can be 
  127. remapped, which makes z80emacs pretty well customizable, though
  128. not perfectly so.
  129.  
  130. There are only 67 or so commands that you can assign to these 
  131. 380 command sequences, so most sequences will be undefined.
  132. The command space is much larger than the number of commands, so 
  133. multiple mappings are sensible; a multiple mapping is where you 
  134. have two or more sequences bound to the same command, in other words, 
  135. more than one way to do the same thing.
  136.  
  137. Only 4 of the commands are built in to the root segment, and always 
  138. stay in memory: ^G ( CI-Abort-Cancel ), right arrow, left arrow, and
  139. self-insert; self-insert isn't in the internal dispatch table,
  140. and there is only one free slot in this table
  141. ( this is relevant to the discussion about running out of slots; see above ).
  142.  
  143. All the other commands live in overlays, and their dispatch table has 
  144. 5 extra entries. A few commands already have multiple sequences in
  145. the default mapping ( this is because some ASCII teminals send ^J 
  146. for down-arrow, but others send ^V ).
  147.  
  148. If you're running out of space in the overlay dispatch table because 
  149. you are making lots of multiple mappings, there are commands you can 
  150. get rid of:
  151. "deblank", 
  152. "lowercase region", "uppercase region",
  153. "previous window" ( "next window" is good enough, you won't have so 
  154. many windows that you need a "previous window" command ), 
  155. "shrink window" ( you can always change to the other window and enlarge it ), 
  156. "scroll down window" ( you can hit ^\^X^K, "scroll up" with a negative 
  157. parameter ),
  158. "scroll up window" ( to save space, z80emacs doesn't do fancy screen 
  159. updating, so the scrolling commands aren't too great ),
  160. "capitalize word", "lowercase word", "uppercase word".
  161.  
  162. ======================================================
  163. =                                                    =
  164. = CHOOSING A MAPPING; WHY THE DEFAULT IS SO AWFUL    =
  165. =                                                    =
  166. ======================================================
  167.  
  168. If you're used to any of the several standard incompatible
  169. forms of emacs, the default mapping is awful because it isn't
  170. like the one you're used to.
  171.  
  172. The default mapping is a compromise between a newfangled 
  173. "theoretically best" mapping I almost finished working out,
  174. and an oldfashioned desire to be able to use all the fancy
  175. keys on the terminal I used while developing z80emacs.
  176. I should clean this up, of course...
  177.  
  178. The commands labeled ZMAP in "mapping.h" are theoretical;
  179. the theoretical mapping is a compromise between ergonomics
  180. ( frequently-used commands are easy to type, a consideration
  181. that most emacs command sets overlooked; for example, most 
  182. emacses use M-f for word forwards, M-v for page back ), 
  183. and mnemonics ( less-often-used commands try to be easier to 
  184. remember ).
  185.  
  186. The commands with TVI in their comments are based on my function 
  187. keys.
  188.  
  189. Several useful control keys were left unmapped: 
  190.  
  191. ^A because I thought I might put in "magic mode", so I could use 
  192. the FUNCT key on my terminal,
  193.  
  194. ^Q and ^S because lots of terminals eat these,
  195. ( if you can use ^Q, please don't make it "quote" as emacs does;
  196. it's so stupid to use up an easy-to-type character for a 
  197. rarely-used command ),
  198.  
  199. ^W should probably be zmap for delete-word-forward,
  200.  
  201. ^] and ^_ could be used for anything you want.
  202.  
  203. To choose your own mapping, I recommend that you try keeping ZMAP
  204. commands as they are, and remap the TVI commands to whatever your 
  205. terminal does.
  206.  
  207. Of course, if your terminal sends ^[[A for up-arrow, you're out of 
  208. luck. If there's ever another release, this should be fixed.
  209.  
  210. ======================================================
  211. =                                                    =
  212. = PRINTING OUT WHAT MAPPING YOU INSTALLED            =
  213. =                                                    =
  214. ======================================================
  215.  
  216. There should be a program to read ME.COM and report on the 
  217. installed mapping; there isn't.
  218.  
  219. Have fun,
  220.  
  221. Ralph Betza,    October 4, 1991
  222.  
  223.