comparison lisp/help.el @ 60779:456199ab7d27

(where-is): Don't mention aliases with no key bindings.
author Richard M. Stallman <rms@gnu.org>
date Mon, 21 Mar 2005 17:41:41 +0000
parents 9b106d739bf9
children f2d616f518a5 13796b0653c7
comparison
equal deleted inserted replaced
60778:f3fe2785106e 60779:456199ab7d27
484 obarray 'commandp t)) 484 obarray 'commandp t))
485 (list (if (equal val "") fn (intern val)) current-prefix-arg))) 485 (list (if (equal val "") fn (intern val)) current-prefix-arg)))
486 (let ((func (indirect-function definition)) 486 (let ((func (indirect-function definition))
487 (defs nil) 487 (defs nil)
488 (standard-output (if insert (current-buffer) t))) 488 (standard-output (if insert (current-buffer) t)))
489 ;; In DEFS, find all symbols that are aliases for DEFINITION.
489 (mapatoms (lambda (symbol) 490 (mapatoms (lambda (symbol)
490 (and (fboundp symbol) 491 (and (fboundp symbol)
491 (not (eq symbol definition)) 492 (not (eq symbol definition))
492 (eq func (condition-case () 493 (eq func (condition-case ()
493 (indirect-function symbol) 494 (indirect-function symbol)
494 (error symbol))) 495 (error symbol)))
495 (push symbol defs)))) 496 (push symbol defs))))
496 (princ (mapconcat 497 ;; Look at all the symbols--first DEFINITION,
497 #'(lambda (symbol) 498 ;; then its aliases.
498 (let* ((remapped (command-remapping symbol)) 499 (dolist (symbol (cons definition defs))
499 (keys (where-is-internal 500 (let* ((remapped (command-remapping symbol))
500 symbol overriding-local-map nil nil remapped)) 501 (keys (where-is-internal
501 (keys (mapconcat 'key-description keys ", "))) 502 symbol overriding-local-map nil nil remapped))
502 (if insert 503 (keys (mapconcat 'key-description keys ", "))
503 (if (> (length keys) 0) 504 string)
504 (if remapped 505 (setq string
505 (format "%s (%s) (remapped from %s)" 506 (if insert
506 keys remapped symbol) 507 (if (> (length keys) 0)
507 (format "%s (%s)" keys symbol)) 508 (if remapped
508 (format "M-x %s RET" symbol)) 509 (format "%s (%s) (remapped from %s)"
509 (if (> (length keys) 0) 510 keys remapped symbol)
510 (if remapped 511 (format "%s (%s)" keys symbol))
511 (format "%s is remapped to %s which is on %s" 512 (format "M-x %s RET" symbol))
512 definition symbol keys) 513 (if (> (length keys) 0)
513 (format "%s is on %s" symbol keys)) 514 (if remapped
514 (format "%s is not on any key" symbol))))) 515 (format "%s is remapped to %s which is on %s"
515 (cons definition defs) 516 definition symbol keys)
516 ";\nand "))) 517 (format "%s is on %s" symbol keys))
518 ;; If this is the command the user asked about,
519 ;; and it is not on any key, say so.
520 ;; For other symbols, its aliases, say nothing
521 ;; about them unless they are on keys.
522 (if (eq symbol definition)
523 (format "%s is not on any key" symbol)))))
524 (when string
525 (unless (eq symbol definition)
526 (princ ";\n its alias "))
527 (princ string)))))
517 nil) 528 nil)
518 529
519 (defun string-key-binding (key) 530 (defun string-key-binding (key)
520 "Value is the binding of KEY in a string. 531 "Value is the binding of KEY in a string.
521 If KEY is an event on a string, and that string has a `local-map' 532 If KEY is an event on a string, and that string has a `local-map'