Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!think!nike!ucbcad!moore From: moore@ucbcad.BERKELEY.EDU (Peter X Moore) Newsgroups: net.emacs Subject: Re: Creating new keymaps in GNU Message-ID: <979@ucbcad.BERKELEY.EDU> Date: Thu, 21-Aug-86 17:29:51 EDT Article-I.D.: ucbcad.979 Posted: Thu Aug 21 17:29:51 1986 Date-Received: Thu, 21-Aug-86 22:41:48 EDT References: <312@briar.UUCP> Reply-To: moore@cad.Berkeley.EDU.UUCP (Peter X Moore) Organization: UC Berkeley, CAD group Lines: 30 I found the process of making new keymaps unfriendly enough, I automated it. Here is a set of macros that bind commands to an arbitrary key sequence, creating new keymaps as necessary. Peter Moore moore@ic.Berkeley.EDU (defun make-global-binding (key function) "Bind globally to the arbitrary string KEY, FUNCTION" (interactive "skey:\nafunction:") (make-binding global-map key function)) (defun make-local-binding (key function) "Bind locally to the arbitrary string KEY, FUNCTION" (interactive "skey:\nafunction:") (make-binding (current-local-map) key function)) (defun make-binding (top-map key function) (let ((num (lookup-key top-map key))) (if (numberp num) (let ((prefix (substring key 0 (1- num))) (path (substring key (1- num))) cur-char symb) (while (> (length path) 1) (setq prefix (concat prefix (substring path 0 1))) (setq path (substring path 1)) (setq symb (intern (concat prefix "-prefix"))) (fset symb (make-sparse-keymap)) (define-key top-map prefix symb)))) (define-key top-map key function)))