diff options
| author | Richard M. Stallman | 1993-06-26 04:18:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-06-26 04:18:37 +0000 |
| commit | 4434d61b29d47440b6985e3ffa9ff037489ce71d (patch) | |
| tree | 045d43dfbee5d7a6e25f9b80eea2f5add7b0b0e5 | |
| parent | 198d5c0098044d63124902ad8b1b617b5af59e04 (diff) | |
| download | emacs-4434d61b29d47440b6985e3ffa9ff037489ce71d.tar.gz emacs-4434d61b29d47440b6985e3ffa9ff037489ce71d.zip | |
(define-key-in-sequence): New function.
| -rw-r--r-- | lisp/subr.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 9759799fb3a..f866228ccc0 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -181,6 +181,29 @@ in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP." | |||
| 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 |