diff options
| -rw-r--r-- | lisp/apropos.el | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el index 9750683fd85..e5904e73b71 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; apropos.el --- apropos commands for users and programmers | 1 | ;;; apropos.el --- apropos commands for users and programmers |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1989, 1994, 1995, 2001, 2002, 2003 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1989,94,1995,2001,02,03,2004 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Joe Wells <jbw@bigbird.bu.edu> | 5 | ;; Author: Joe Wells <jbw@bigbird.bu.edu> |
| 6 | ;; Rewritten: Daniel Pfeiffer <occitan@esperanto.org> | 6 | ;; Rewritten: Daniel Pfeiffer <occitan@esperanto.org> |
| @@ -58,6 +58,7 @@ | |||
| 58 | ;;; Code: | 58 | ;;; Code: |
| 59 | 59 | ||
| 60 | (require 'button) | 60 | (require 'button) |
| 61 | (eval-when-compile (require 'cl)) | ||
| 61 | 62 | ||
| 62 | (defgroup apropos nil | 63 | (defgroup apropos nil |
| 63 | "Apropos commands for users and programmers" | 64 | "Apropos commands for users and programmers" |
| @@ -348,7 +349,6 @@ This requires that at least 2 keywords (unless only one was given)." | |||
| 348 | "Return t if DOC is really matched by the current keywords." | 349 | "Return t if DOC is really matched by the current keywords." |
| 349 | (apropos-true-hit doc apropos-all-words)) | 350 | (apropos-true-hit doc apropos-all-words)) |
| 350 | 351 | ||
| 351 | ;;;###autoload | ||
| 352 | (define-derived-mode apropos-mode fundamental-mode "Apropos" | 352 | (define-derived-mode apropos-mode fundamental-mode "Apropos" |
| 353 | "Major mode for following hyperlinks in output of apropos commands. | 353 | "Major mode for following hyperlinks in output of apropos commands. |
| 354 | 354 | ||
| @@ -452,37 +452,42 @@ show unbound symbols and key bindings, which is a little more | |||
| 452 | time-consuming. Returns list of symbols and documentation found." | 452 | time-consuming. Returns list of symbols and documentation found." |
| 453 | (interactive "sApropos symbol (regexp or words): \nP") | 453 | (interactive "sApropos symbol (regexp or words): \nP") |
| 454 | (setq apropos-regexp (apropos-rewrite-regexp apropos-regexp)) | 454 | (setq apropos-regexp (apropos-rewrite-regexp apropos-regexp)) |
| 455 | (setq apropos-accumulator | 455 | (apropos-symbols-internal |
| 456 | (apropos-internal apropos-regexp | 456 | (apropos-internal apropos-regexp |
| 457 | (and (not do-all) | 457 | (and (not do-all) |
| 458 | (not apropos-do-all) | 458 | (not apropos-do-all) |
| 459 | (lambda (symbol) | 459 | (lambda (symbol) |
| 460 | (or (fboundp symbol) | 460 | (or (fboundp symbol) |
| 461 | (boundp symbol) | 461 | (boundp symbol) |
| 462 | (facep symbol) | 462 | (facep symbol) |
| 463 | (symbol-plist symbol)))))) | 463 | (symbol-plist symbol))))) |
| 464 | (let ((tem apropos-accumulator)) | 464 | (or do-all apropos-do-all))) |
| 465 | (while tem | 465 | |
| 466 | (if (get (car tem) 'apropos-inhibit) | 466 | (defun apropos-symbols-internal (symbols keys &optional text) |
| 467 | (setq apropos-accumulator (delq (car tem) apropos-accumulator))) | 467 | ;; Filter out entries that are marked as apropos-inhibit. |
| 468 | (setq tem (cdr tem)))) | 468 | (let ((all nil)) |
| 469 | (let ((p apropos-accumulator) | 469 | (dolist (symbol symbols) |
| 470 | symbol doc properties) | 470 | (unless (get symbol 'apropos-inhibit) |
| 471 | (while p | 471 | (push symbol all))) |
| 472 | (setcar p (list | 472 | (setq symbols all)) |
| 473 | (setq symbol (car p)) | 473 | (let ((apropos-accumulator |
| 474 | (apropos-score-symbol symbol) | 474 | (mapcar |
| 475 | (when (fboundp symbol) | 475 | (lambda (symbol) |
| 476 | (if (setq doc (condition-case nil | 476 | (let (doc properties) |
| 477 | (documentation symbol t) | 477 | (list |
| 478 | (void-function | 478 | symbol |
| 479 | "(alias for undefined function)") | 479 | (apropos-score-symbol symbol) |
| 480 | (error | 480 | (when (fboundp symbol) |
| 481 | "(error retrieving function documentation)"))) | 481 | (if (setq doc (condition-case nil |
| 482 | (substring doc 0 (string-match "\n" doc)) | 482 | (documentation symbol t) |
| 483 | "(not documented)")) | 483 | (void-function |
| 484 | (when (boundp symbol) | 484 | "(alias for undefined function)") |
| 485 | (apropos-documentation-property | 485 | (error |
| 486 | "(can't retrieve function documentation)"))) | ||
| 487 | (substring doc 0 (string-match "\n" doc)) | ||
| 488 | "(not documented)")) | ||
| 489 | (when (boundp symbol) | ||
| 490 | (apropos-documentation-property | ||
| 486 | symbol 'variable-documentation t)) | 491 | symbol 'variable-documentation t)) |
| 487 | (when (setq properties (symbol-plist symbol)) | 492 | (when (setq properties (symbol-plist symbol)) |
| 488 | (setq doc (list (car properties))) | 493 | (setq doc (list (car properties))) |
| @@ -492,16 +497,14 @@ time-consuming. Returns list of symbols and documentation found." | |||
| 492 | (when (get symbol 'widget-type) | 497 | (when (get symbol 'widget-type) |
| 493 | (apropos-documentation-property | 498 | (apropos-documentation-property |
| 494 | symbol 'widget-documentation t)) | 499 | symbol 'widget-documentation t)) |
| 495 | (when (facep symbol) | 500 | (when (facep symbol) |
| 496 | (apropos-documentation-property | 501 | (apropos-documentation-property |
| 497 | symbol 'face-documentation t)) | 502 | symbol 'face-documentation t)) |
| 498 | (when (get symbol 'custom-group) | 503 | (when (get symbol 'custom-group) |
| 499 | (apropos-documentation-property | 504 | (apropos-documentation-property |
| 500 | symbol 'group-documentation t)))) | 505 | symbol 'group-documentation t))))) |
| 501 | (setq p (cdr p)))) | 506 | symbols))) |
| 502 | (apropos-print | 507 | (apropos-print keys nil text))) |
| 503 | (or do-all apropos-do-all) | ||
| 504 | nil)) | ||
| 505 | 508 | ||
| 506 | 509 | ||
| 507 | ;;;###autoload | 510 | ;;;###autoload |
| @@ -755,7 +758,7 @@ Will return nil instead." | |||
| 755 | function)) | 758 | function)) |
| 756 | 759 | ||
| 757 | 760 | ||
| 758 | (defun apropos-print (do-keys spacing) | 761 | (defun apropos-print (do-keys spacing &optional text) |
| 759 | "Output result of apropos searching into buffer `*Apropos*'. | 762 | "Output result of apropos searching into buffer `*Apropos*'. |
| 760 | The value of `apropos-accumulator' is the list of items to output. | 763 | The value of `apropos-accumulator' is the list of items to output. |
| 761 | Each element should have the format | 764 | Each element should have the format |
| @@ -764,8 +767,8 @@ The return value is the list that was in `apropos-accumulator', sorted | |||
| 764 | alphabetically by symbol name; but this function also sets | 767 | alphabetically by symbol name; but this function also sets |
| 765 | `apropos-accumulator' to nil before returning. | 768 | `apropos-accumulator' to nil before returning. |
| 766 | 769 | ||
| 767 | If SPACING is non-nil, it should be a string; | 770 | If SPACING is non-nil, it should be a string; separate items with that string. |
| 768 | separate items with that string." | 771 | If non-nil TEXT is a string that will be printed as a heading." |
| 769 | (if (null apropos-accumulator) | 772 | (if (null apropos-accumulator) |
| 770 | (message "No apropos matches for `%s'" apropos-orig-regexp) | 773 | (message "No apropos matches for `%s'" apropos-orig-regexp) |
| 771 | (setq apropos-accumulator | 774 | (setq apropos-accumulator |
| @@ -794,6 +797,7 @@ separate items with that string." | |||
| 794 | " or variable,\n" | 797 | " or variable,\n" |
| 795 | (substitute-command-keys | 798 | (substitute-command-keys |
| 796 | "and type \\[apropos-follow] to get full documentation.\n\n")) | 799 | "and type \\[apropos-follow] to get full documentation.\n\n")) |
| 800 | (if text (insert text "\n\n")) | ||
| 797 | (while (consp p) | 801 | (while (consp p) |
| 798 | (when (and spacing (not (bobp))) | 802 | (when (and spacing (not (bobp))) |
| 799 | (princ spacing)) | 803 | (princ spacing)) |
| @@ -907,13 +911,15 @@ separate items with that string." | |||
| 907 | 911 | ||
| 908 | (defun apropos-describe-plist (symbol) | 912 | (defun apropos-describe-plist (symbol) |
| 909 | "Display a pretty listing of SYMBOL's plist." | 913 | "Display a pretty listing of SYMBOL's plist." |
| 910 | (with-output-to-temp-buffer "*Help*" | 914 | (help-setup-xref (list 'apropos-describe-plist symbol) (interactive-p)) |
| 915 | (with-output-to-temp-buffer (help-buffer) | ||
| 911 | (set-buffer standard-output) | 916 | (set-buffer standard-output) |
| 912 | (princ "Symbol ") | 917 | (princ "Symbol ") |
| 913 | (prin1 symbol) | 918 | (prin1 symbol) |
| 914 | (princ "'s plist is\n (") | 919 | (princ "'s plist is\n (") |
| 915 | (if apropos-symbol-face | 920 | (if apropos-symbol-face |
| 916 | (put-text-property 8 (- (point) 14) 'face apropos-symbol-face)) | 921 | (put-text-property (+ (point-min) 7) (- (point) 14) |
| 922 | 'face apropos-symbol-face)) | ||
| 917 | (insert (apropos-format-plist symbol "\n ")) | 923 | (insert (apropos-format-plist symbol "\n ")) |
| 918 | (princ ")") | 924 | (princ ")") |
| 919 | (print-help-return-message))) | 925 | (print-help-return-message))) |