# HG changeset patch # User Richard M. Stallman # Date 797838991 0 # Node ID 84e419a90298ef4df93196e5d7870ef521dee956 # Parent 9829d3c035f29af3dc0541828b593df628c4dcc0 (derived-mode-merge-keymaps): Recursively merge prefix key submaps also. diff -r 9829d3c035f2 -r 84e419a90298 lisp/derived.el --- a/lisp/derived.el Fri Apr 14 03:58:51 1995 +0000 +++ b/lisp/derived.el Fri Apr 14 05:56:31 1995 +0000 @@ -297,8 +297,30 @@ (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)