jr@LF-SERVER-2.BBN.COM (John Robinson) (06/26/87)
With all this talk about what is the right binding of which key, and what termcap lacks, it seems the time is ripe for someone to build (in elisp) an interactive keymap builder. It prompts for a key to bind, you type it, it asks what function to put there (or what other key's binding to copy), and so on. Output would be elisp to set your keymap that way (based perhaps on the terminal type you are using at the time). Perhaps it also knows about or tracks function key labels; this could be used by help-w (where-is). Then load the keymap as part of your .emacs. Collect 'em and trade 'em with your friends. Anyone twiddling their thumbs this summer? /jr
rbbb@RICE.EDU (David Chase) (06/27/87)
Rather than do it interactively, we (= a number of graduate students here at Rice) use this approach in our profiles (in Unipress/Gosling emacs): 1) load key-decls This declares the variables F0-F12, L0-L10, R1-R15, UP, DOWN, LEFT, RIGHT, etc. 2) load (concat (getenv "TERM") "keys") this assigns the terminal specific values to all of the keys. Of course, some terminals lack keys, so those are not assigned. At the moment I have key definition files for a Visual 200, VT100 (as emulated by "X"), adm31 (really "uw" on a macintosh keyboard, so rather odd), IBM RT, Sun, and a wyse 75. 3) load key-bindings This binds commands to the key-strokes associated with the variables defined in step 1. Whenever a new terminal appears (fairly infrequent occasion, actually) the first one of us to be forced to use it cranks out a "...keys.ml" file for that terminal and gives it to the other people (or rather, they ask around before re-inventing the wheel). This operation is actually not too painful; I hacked out the Wyse keyboard in about 10 minutes when I needed an editor in a machine room. This is usually done by editing a template; position the cursor in the middle of the keystroke string, type ^Q, and punch the button. This even works for the Macintosh running uw. It has no function keys at all, but it does have a key sending ^C, a meta key and a control key. For function keys I bound ^C 1 through = to F1 through F12. It lacks a keypad, but has excellent mouse support (up AND down transitions are reported) and passes my ^S and ^Q characters. The biggest advantage to this approach is that all the keyboards act alike. I can wander from Mac to Sun, to RT, to X, to a wyse, all in one afternoon, without too much disorientation. Another real advantage to this is that the naming and the binding are separated; one person can do the naming, once, and other people can use his work. With the interactive binding described in John Robinson's letter, each person must run the key binder (even though it is fairly painless). If this ever caught on really big, I imagine that people would trade terminal keystroke descriptions across the net. I expect that they are rather emacs-independent, since all they are is a large bunch of SETQ's. Even MockLisp has setq. Problems with this approach: 1) Not all keyboards are alike. For function row keys use key number (i.e, F1, F2, etc) and for keypad keys we go by "position" as much as possible. Keys that are not on all terminals are bound to less-useful functions or bound to "bind-to-key". I bind and use F2 through F9 and R1 through R15 (with holes at R8, 10, 12, 14; see the next problem). 2) Different people have different ideas of the "shape" of the keypad. The most notable instance of this here is the treatment of the arrow keys on the Sun 2 and 3 keyboards; they are also R8, 10, 12, and 14. I decided that I wanted them to be arrow keys for cursor movement; my brother decided that he wanted them to be bound to other functions. The reason that this is a problem is that we want to call them different things; I call them up, down, left, and right, but he calls them R8, etc. This means that we use different keyboard description files for Suns (but not for other terminals). Another real problem keyboard is the IBM RT's; running "X", somehow the Number Lock key is real and sends characters, but not running "X" I have not been able to convince it to do this. Since I happen to like windows, dvi previewers, mice and the X keypad, I run X. NB--in a pinch, if a terminal happens to need flow control (these things happen) that can also be placed in this file (assuming that your emacs can place the tty in the correct mode. A combination of LITOUT and CBREAK and trashing out the special characters does the trick for 4.2+ BSD systems. I can supply the code to anyone that needs it, since I wrote it.) comments? David