diff options
| author | Karl Heuer | 1994-03-03 16:27:06 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-03-03 16:27:06 +0000 |
| commit | f14dbba77153ebcd65ae0e7023f678031887e92e (patch) | |
| tree | 1fa1b3d9db5e62352c2a12396ad13a43b7c89074 | |
| parent | bbf2192538a002d9c2f51df1d72733e7e197b4d9 (diff) | |
| download | emacs-f14dbba77153ebcd65ae0e7023f678031887e92e.tar.gz emacs-f14dbba77153ebcd65ae0e7023f678031887e92e.zip | |
(substitute-key-definition): Avoid infinite recursion.
| -rw-r--r-- | lisp/subr.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 119e7c2159f..44a7e298e3c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -133,6 +133,9 @@ but optional second arg NODIGITS non-nil treats them like other chars." | |||
| 133 | ; (copy-sequence keymap) | 133 | ; (copy-sequence keymap) |
| 134 | ; (copy-alist keymap))) | 134 | ; (copy-alist keymap))) |
| 135 | 135 | ||
| 136 | (defvar key-substitution-in-progress nil | ||
| 137 | "Used internally by substitute-key-definition.") | ||
| 138 | |||
| 136 | (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) | 139 | (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) |
| 137 | "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. | 140 | "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. |
| 138 | In other words, OLDDEF is replaced with NEWDEF where ever it appears. | 141 | In other words, OLDDEF is replaced with NEWDEF where ever it appears. |
| @@ -141,7 +144,9 @@ in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP." | |||
| 141 | (or prefix (setq prefix "")) | 144 | (or prefix (setq prefix "")) |
| 142 | (let* ((scan (or oldmap keymap)) | 145 | (let* ((scan (or oldmap keymap)) |
| 143 | (vec1 (vector nil)) | 146 | (vec1 (vector nil)) |
| 144 | (prefix1 (vconcat prefix vec1))) | 147 | (prefix1 (vconcat prefix vec1)) |
| 148 | (key-substitution-in-progress | ||
| 149 | (cons scan key-substitution-in-progress))) | ||
| 145 | ;; Scan OLDMAP, finding each char or event-symbol that | 150 | ;; Scan OLDMAP, finding each char or event-symbol that |
| 146 | ;; has any definition, and act on it with hack-key. | 151 | ;; has any definition, and act on it with hack-key. |
| 147 | (while (consp scan) | 152 | (while (consp scan) |
| @@ -163,7 +168,9 @@ in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP." | |||
| 163 | (setq inner-def (symbol-function inner-def))) | 168 | (setq inner-def (symbol-function inner-def))) |
| 164 | (if (eq defn olddef) | 169 | (if (eq defn olddef) |
| 165 | (define-key keymap prefix1 (nconc (nreverse skipped) newdef)) | 170 | (define-key keymap prefix1 (nconc (nreverse skipped) newdef)) |
| 166 | (if (keymapp defn) | 171 | (if (and (keymapp defn) |
| 172 | (not (memq inner-def | ||
| 173 | key-substitution-in-progress))) | ||
| 167 | (substitute-key-definition olddef newdef keymap | 174 | (substitute-key-definition olddef newdef keymap |
| 168 | inner-def | 175 | inner-def |
| 169 | prefix1))))) | 176 | prefix1))))) |
| @@ -189,7 +196,9 @@ in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP." | |||
| 189 | (if (eq defn olddef) | 196 | (if (eq defn olddef) |
| 190 | (define-key keymap prefix1 | 197 | (define-key keymap prefix1 |
| 191 | (nconc (nreverse skipped) newdef)) | 198 | (nconc (nreverse skipped) newdef)) |
| 192 | (if (keymapp defn) | 199 | (if (and (keymapp defn) |
| 200 | (not (memq inner-def | ||
| 201 | key-substitution-in-progress))) | ||
| 193 | (substitute-key-definition olddef newdef keymap | 202 | (substitute-key-definition olddef newdef keymap |
| 194 | inner-def | 203 | inner-def |
| 195 | prefix1))))) | 204 | prefix1))))) |