comparison lisp/subr.el @ 3901:c78753b7eea8

(define-key-in-sequence): New function.
author Richard M. Stallman <rms@gnu.org>
date Sat, 26 Jun 1993 04:18:37 +0000
parents 70bdc91ef161
children 717f2e24975e
comparison
equal deleted inserted replaced
3900:c6f3d2af0df7 3901:c78753b7eea8
179 inner-def 179 inner-def
180 prefix1))))) 180 prefix1)))))
181 (setq i (1+ i)))))) 181 (setq i (1+ i))))))
182 (setq scan (cdr scan))))) 182 (setq scan (cdr scan)))))
183 183
184 (defun define-key-in-sequence (keymap key definition after)
185 "Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding.
186 This is like `define-key' except that the binding for KEY is placed
187 just after the binding for the event AFTER, instead of at the beginning
188 of the map.
189 The order matters when the keymap is used as a menu."
190 (or (keymapp keymap)
191 (signal 'wrong-type-argument (list 'keymapp keymap)))
192 (let ((tail keymap) done
193 (first (aref key 0)))
194 (while (and (not done) tail)
195 ;; Delete any earlier bindings for the same key.
196 (if (eq (car-safe (car (cdr tail))) first)
197 (setcdr tail (cdr (cdr tail))))
198 ;; When we reach AFTER's binding, insert the new binding after.
199 ;; If we reach an inherited keymap, insert just before that.
200 (if (or (eq (car-safe (car tail)) after)
201 (eq (car tail) 'keymap))
202 (progn
203 (setcdr tail (cons (cons (aref key 0) definition) (cdr tail)))
204 (setq done t)))
205 (setq tail (cdr tail)))))
206
184 (defun keyboard-translate (from to) 207 (defun keyboard-translate (from to)
185 "Translate character FROM to TO at a low level. 208 "Translate character FROM to TO at a low level.
186 This function creates a `keyboard-translate-table' if necessary 209 This function creates a `keyboard-translate-table' if necessary
187 and then modifies one entry in it." 210 and then modifies one entry in it."
188 (or (arrayp keyboard-translate-table) 211 (or (arrayp keyboard-translate-table)