Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!mit-eddie!mit-vax!josh From: josh@mit-vax.LCS.MIT.EDU (Joshua Marantz) Newsgroups: comp.emacs Subject: Re: A proposal for a standardized key handling method Message-ID: <2525@mit-vax.LCS.MIT.EDU> Date: Tue, 4-Aug-87 10:35:05 EDT Article-I.D.: mit-vax.2525 Posted: Tue Aug 4 10:35:05 1987 Date-Received: Thu, 6-Aug-87 01:33:51 EDT References: <250@cogent.UUCP> Distribution: world Organization: MIT LCS, Cambridge, MA Lines: 41 In-reply-to: mark@cogent.UUCP's message of 4 Aug 87 08:07:17 GMT Posting-Front-End: GNU Emacs 18.33.1 of Tue Dec 16 1986 on mit-vax (berkeley-unix) Gosling EMACS (and possibly GNU Emacs) had what I consider a cleaner solution, though it didn't use termcap or terminfo. The form of the bind command is: (bind-to-key "function-name" "character-sequence") If "character-sequence" is more than one character long, the first character gets bound to an "auto-generated" keymap, and the second character is the binding within the auto-generated keymap. This recursion can go on indefinitely, allowing for the binding of arbitrarily long escape sequences. For example: (bind-to-key "forward-character" "\^F") (bind-to-key "forward-word" "\ef") (bind-to-key "forward-character" "\e[C") (bind-to-key "backward-character" "\e[D") Would cause the following binding state to exist: Global Map: Control-F --> function "forward-character" Global Map: Escape --> keymap "auto-keymap-1" Auto-keymap-1: f --> function "forward-word" Auto-keymap-1: [ --> keymap "auto-keymap-2" Auto-keymap-2: C --> function "forward-character" Auto-keymap-2: D --> function "backward-character" To avoid "auto-keymap-*", you can first do (define-keymap "ESC-map") (bind-to-key "ESC-map" "\e") (define-keymap "ANSI-prefix-map") (bind-to-key "ANSI-prefix-map" "\e[") This is a good approach because no keyboard information has to be hardwired into the editor. You have to evaluate the tradeoff of whether you want to take advantage of the Unix terminfo/termcap facility, which may not have all you need, and probably won't be supported on other platforms. I vote for the portable, flexible approach described here. -Joshua Marantz Emacs Enthusiast