Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!nike!ucbcad!ucbvax!ernie.Berkeley.EDU!karl From: karl@ernie.Berkeley.EDU (Karl Berry.) Newsgroups: net.emacs Subject: Assigning key bindings. Message-ID: <14754@ucbvax.BERKELEY.EDU> Date: Mon, 7-Jul-86 15:12:00 EDT Article-I.D.: ucbvax.14754 Posted: Mon Jul 7 15:12:00 1986 Date-Received: Tue, 8-Jul-86 05:34:46 EDT Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: karl@ernie.Berkeley.EDU (Karl Berry.) Organization: University of California at Berkeley Lines: 69 The basic advantage of Emacs over, say, vi is that the key bindings can be rebound. The default bindings of Emacs make it just as incomprehensible as vi. (Well, almost -- still no insert mode.) Abut two days after I first learned about Emacs, I realized I would never be able to understand the default key bindings, and started writing my own. Of course, the documentation for every Emacs system I've ever seen (Gosling, Gnumacs, Unipress) is TERRIBLE. (Especially if you're either a novice or a programmer.) Anyway, the problem of assigning new key bindings is rather difficult, because of the tradeoff between rational assignments and usability. One of the ways to assign keys is to come up with a list of functions; say, kill, move forward, move backward, move up, move down. Then assign prefix keys for each function: ^K, ^F, ^B, ^U, ^D. Now add second keys for each object. So, kill a character would be ^K^C. Moving up a line would be ^U^L. It is obviously possible to reverse this -- make the objects the prefix keys, and the functions the second key. Both methods suffer from the same problem: it takes at least two keys to get anything done. For a novice, that is probably acceptable -- until the second week of use. Past that, it is not. So. The solution I came up with is to have hierarchies. For example, ^T transposes two characters. ESC t transposes two words. ^Xt transposes two lines. Thus, as we go from control to ESC to ^X, the object operated on gets larger. ESC and ^X were chosen arbitrarily, because they were prefix keys already. Unfortunately, the key-binding designer has to work under rather severe constraints. Many control keys have already been usurped by manufacturers and/or networks. In order to make my bindings work on every system I've come in contact with, I've had to refrain from using ^S and ^Q. Furthermore, all keyboards use ^I for tab, ^J and ^M are sent when return is hit, and ^H is backspace. Rather a bleak situation. (It is all very well for Stallman to say ``buy a new terminal'' if it uses ^S/^Q flow control, but that's not very practical if I already have one...) Furthermore, the second character should not, I think, distinguish between control and non-control. I spent a frustrating few days before I simply decided to make all key pairs (prefix,control ?) also be (prefix,?). So I also have ^X^T bound to transposing lines. Well. The scheme I outlined above works reasonably well for me. It does not take care of all the cases: I have function prefixes too, for things like killing and inserting larger blocks of text. Since I was only designing for myself, I was free to put in only the functions that I personally used, which made it easier. The problem of deciding what operations should be bound to keys in the first place is more difficult (in general), I think, than deciding what the bindings should be! If anyone has any better ideas about how to assign bindings, I'd love to hear about them. Please do not quote this message in its entirety or in large part! ucbvax!ernie!karl karl@ernie.berkeley.edu