diff options
author | Richard M. Stallman <rms@gnu.org> | 1995-04-14 05:56:31 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1995-04-14 05:56:31 +0000 |
commit | 37a4f4b6b6669ddcd8723cc668984b3b6d91a7be (patch) | |
tree | c3d809faa30cb1e0bf9916ba6a45a43336cc53ba /lisp/derived.el | |
parent | 2d7fc7e8f9f019d01a4f02ad28fb6b9abc8404dc (diff) | |
download | emacs-37a4f4b6b6669ddcd8723cc668984b3b6d91a7be.tar.gz |
(derived-mode-merge-keymaps): Recursively merge prefix key submaps also.
Diffstat (limited to 'lisp/derived.el')
-rw-r--r-- | lisp/derived.el | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lisp/derived.el b/lisp/derived.el index f48156a1010..a1cfe8485f8 100644 --- a/lisp/derived.el +++ b/lisp/derived.el @@ -297,8 +297,30 @@ Always merge its parent into it, since the merge is non-destructive." (defun derived-mode-merge-keymaps (old new) "Merge an old keymap into a new one. -The old keymap is set to be the cdr of the new one, so that there will +The old keymap is set to be the last cdr of the new one, so that there will be automatic inheritance." + (let ((tail new)) + ;; Scan the NEW map for prefix keys. + (while (consp tail) + (and (consp (car tail)) + (let* ((key (vector (car (car tail)))) + (subnew (lookup-key new key)) + (subold (lookup-key old key))) + ;; If KEY is a prefix key in both OLD and NEW, merge them. + (and (keymapp subnew) (keymapp subold) + (derived-mode-merge-keymaps subold subnew)))) + (and (vectorp (car tail)) + ;; Search a vector of ASCII char bindings for prefix keys. + (let ((i (1- (length (car tail))))) + (while (>= i 0) + (let* ((key (vector i)) + (subnew (lookup-key new key)) + (subold (lookup-key old key))) + ;; If KEY is a prefix key in both OLD and NEW, merge them. + (and (keymapp subnew) (keymapp subold) + (derived-mode-merge-keymaps subold subnew))) + (setq i (1- i))))) + (setq tail (cdr tail)))) (setcdr (nthcdr (1- (length new)) new) old)) (defun derived-mode-merge-syntax-tables (old new) |