diff options
| author | Richard M. Stallman | 1993-05-21 21:29:27 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-05-21 21:29:27 +0000 |
| commit | 4fa884066fbd16e66832396b5cefe38dc3942597 (patch) | |
| tree | 80a2dd1f471eed62ba0dde7a26ddd1d76c3b3061 | |
| parent | af01ef26430d69c04421aac4d862df4f5898a838 (diff) | |
| download | emacs-4fa884066fbd16e66832396b5cefe38dc3942597.tar.gz emacs-4fa884066fbd16e66832396b5cefe38dc3942597.zip | |
(apropos-match-keys): Handle modern keymap structure.
| -rw-r--r-- | lisp/apropos.el | 91 |
1 files changed, 56 insertions, 35 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el index a6639f5ff62..161934fee81 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el | |||
| @@ -252,43 +252,64 @@ Returns list of symbols and documentation found." | |||
| 252 | (setq map (cdr (car maps)) | 252 | (setq map (cdr (car maps)) |
| 253 | sequence (car (car maps)) ;keys to reach this map | 253 | sequence (car (car maps)) ;keys to reach this map |
| 254 | maps (cdr maps)) | 254 | maps (cdr maps)) |
| 255 | (setq i 0) | 255 | ;; Skip the leading `keymap', doc string, etc. |
| 256 | ;; In an alist keymap, skip the leading `keymap', doc string, etc. | 256 | (if (eq (car map) 'keymap) |
| 257 | (while (and (consp map) (not (consp (car map)))) | 257 | (setq map (cdr map))) |
| 258 | (while (stringp (car-safe map)) | ||
| 258 | (setq map (cdr map))) | 259 | (setq map (cdr map))) |
| 259 | (while (and map (< i 128)) ;vector keymaps have 128 entries | 260 | (while (consp map) |
| 260 | (cond ((consp map) | 261 | (cond ((consp (car map)) |
| 261 | (setq command (cdr (car map)) | 262 | (setq command (cdr (car map)) |
| 262 | key (car (car map)) | 263 | key (car (car map))) |
| 263 | map (cdr map)) | 264 | ;; Skip any menu prompt in this key binding. |
| 264 | ;; Skip any atoms in the keymap. | 265 | (and (consp command) (symbolp (cdr command)) |
| 265 | (while (and (consp map) (not (consp (car map)))) | 266 | (setq command (cdr command))) |
| 266 | (setq map (cdr map)))) | 267 | ;; if is a symbol, and matches optional regexp, and is a car |
| 267 | ((vectorp map) | 268 | ;; in alist, and is not shadowed by a different local binding, |
| 268 | (setq command (aref map i) | 269 | ;; record it |
| 269 | key i | 270 | (and (symbolp command) |
| 270 | i (1+ i)))) | 271 | (if regexp (string-match regexp (symbol-name command))) |
| 271 | ;; Skip any menu prompt in this key binding. | 272 | (setq item (assq command alist)) |
| 272 | (and (consp command) (symbolp (cdr command)) | 273 | (if (or (vectorp sequence) (not (integerp key))) |
| 273 | (setq command (cdr command))) | 274 | (setq key (vconcat sequence (vector key))) |
| 274 | ;; if is a symbol, and matches optional regexp, and is a car | 275 | (setq key (concat sequence (char-to-string key)))) |
| 275 | ;; in alist, and is not shadowed by a different local binding, | 276 | ;; checking if shadowed by local binding. |
| 276 | ;; record it | 277 | ;; either no local map, no local binding, or runs off the |
| 277 | (and (symbolp command) | 278 | ;; binding tree (number), or is the same binding |
| 278 | (if regexp (string-match regexp (symbol-name command))) | 279 | (or (not current-local-map) |
| 279 | (setq item (assq command alist)) | 280 | (not (setq local (lookup-key current-local-map key))) |
| 280 | (if (or (vectorp sequence) (not (integerp key))) | 281 | (numberp local) |
| 281 | (setq key (vconcat sequence (vector key))) | 282 | (eq command local)) |
| 282 | (setq key (concat sequence (char-to-string key)))) | 283 | ;; add this key binding to the item in alist |
| 283 | ;; checking if shadowed by local binding. | 284 | (nconc item (cons key nil)))) |
| 284 | ;; either no local map, no local binding, or runs off the | 285 | ((vectorp (car map)) |
| 285 | ;; binding tree (number), or is the same binding | 286 | (let ((i 0) |
| 286 | (or (not current-local-map) | 287 | (vec (car map)) |
| 287 | (not (setq local (lookup-key current-local-map key))) | 288 | (len (length (car map)))) |
| 288 | (numberp local) | 289 | (while (< i len) |
| 289 | (eq command local)) | 290 | (setq command (aref vec i)) |
| 290 | ;; add this key binding to the item in alist | 291 | (setq key i) |
| 291 | (nconc item (cons key nil)))))) | 292 | ;; Skip any menu prompt in this key binding. |
| 293 | (and (consp command) (symbolp (cdr command)) | ||
| 294 | (setq command (cdr command))) | ||
| 295 | ;; This is the same as the code in the previous case. | ||
| 296 | (and (symbolp command) | ||
| 297 | (if regexp (string-match regexp (symbol-name command))) | ||
| 298 | (setq item (assq command alist)) | ||
| 299 | (if (or (vectorp sequence) (not (integerp key))) | ||
| 300 | (setq key (vconcat sequence (vector key))) | ||
| 301 | (setq key (concat sequence (char-to-string key)))) | ||
| 302 | ;; checking if shadowed by local binding. | ||
| 303 | ;; either no local map, no local binding, or runs off the | ||
| 304 | ;; binding tree (number), or is the same binding | ||
| 305 | (or (not current-local-map) | ||
| 306 | (not (setq local (lookup-key current-local-map key))) | ||
| 307 | (numberp local) | ||
| 308 | (eq command local)) | ||
| 309 | ;; add this key binding to the item in alist | ||
| 310 | (nconc item (cons key nil))) | ||
| 311 | (setq i (1+ i)))))) | ||
| 312 | (setq map (cdr map))))) | ||
| 292 | alist) | 313 | alist) |
| 293 | 314 | ||
| 294 | ;; Get an alist item in alist apropos-accumulate whose car is SYMBOL. Creates | 315 | ;; Get an alist item in alist apropos-accumulate whose car is SYMBOL. Creates |