liberte@CS.UIUC.EDU (Daniel LaLiberte) (03/28/91)
I had asked for responses to the idea of abstract bindings and got the following response which other folks might want to cogitate on. (I also like Jamie Zawinski's idea of layered keymaps instead of just two concurrently active keymaps per buffer as it is now.) Dan LaLiberte uiucdcs!liberte liberte@cs.uiuc.edu liberte%a.cs.uiuc.edu@uiucvmd.bitnet ---------------------------------------- Date: Mon, 18 Mar 91 09:41:47 -0500 From: bsa@telotech.UUCP In your message of Fri, 15 Mar 91 12:23:18 CST, you write: +--------------- | The more general problem is the binding of abstract keys (e.g. | delete-char) to functions rather than binding literal keys (e.g. | \b) to functions as is done now. Any ideas? +--------------- The problem with this is that it's a bit like finding the name of a Unix file given a file descriptor: it may not have a name (pipe/socketpair), or it may have more than one name (hard links). How about something similar to the keypad support? Assign specific keys to "command keys" and then bind the command keys. (setq command-key-alist '((key-backward-char . ?\C-a) ... (key-delete-backward-char . ?\^?))) (defun global-set-command (command-key command) "Bind COMMAND-KEY to COMMAND in the global keymap." (interactive ...) ; should constrain COMMAND-KEY to members of alist ; this is on-the-fly code, I don't have the time to ; fill it in completely, being at work.... (let ((key (assoc command-key command-key-alist))) (if key (global-set-key key command) (error "No key sequence associated with command key %s" (symbol-name command-key))))) ... (global-set-command 'key-backward-char 'backward-char) (As I said in the comment, this is on-the-fly code. It almost certainly *won't* work as typed, but it's the general idea.) Part two might involve a means of associating different areas (keymaps, variables, etc.) that use similar functions: (setq command-binding-alist '((delete-char search-delete-char ...) ... )) Then the definition of (global-set-command) might use a (nil) keymap to look up all binding spots in command-binding-alist; it would check for keymapp, fboundp, etc. and act appropriately. The global map would be implied, unless the local map were explicitly specified in the list. ++Brandon