aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-06-08 04:32:43 +0000
committerStefan Monnier2008-06-08 04:32:43 +0000
commit2e3d43acd9c6e5b06f8bd1d4a0c8abc66dbc0e1f (patch)
treeeba5c2d6266389ed04e017281b673cb3e385fd8f
parent671c04d971c57f224d4048e786dc877c9b2ee7fb (diff)
downloademacs-2e3d43acd9c6e5b06f8bd1d4a0c8abc66dbc0e1f.tar.gz
emacs-2e3d43acd9c6e5b06f8bd1d4a0c8abc66dbc0e1f.zip
(apropos-library): New command and new button.
(apropos-library-button): New function.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/apropos.el66
3 files changed, 71 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 4be44175e73..73c6dacecf3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -63,6 +63,8 @@ default toolkit, but you can use --with-x-toolkit=gtk if necessary.
63 63
64* Changes in Emacs 23.1 64* Changes in Emacs 23.1
65 65
66** `apropos-library' describes the elements defined in a given library.
67
66** scroll-preserve-screen-position also preserves the column position. 68** scroll-preserve-screen-position also preserves the column position.
67** Completion. 69** Completion.
68*** `completion-styles' can be customized to choose your favorite completion. 70*** `completion-styles' can be customized to choose your favorite completion.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 91c276b2ba7..f7bb9fc3205 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12008-06-08 Stefan Monnier <monnier@iro.umontreal.ca> 12008-06-08 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * apropos.el (apropos-library): New command and new button.
4 (apropos-library-button): New function.
5
3 * apropos.el: Remove spurious * in docstrings. 6 * apropos.el: Remove spurious * in docstrings.
4 (apropos-label-face): Use variable pitch. 7 (apropos-label-face): Use variable pitch.
5 (apropos-print): Use dolist and with-current-buffer. 8 (apropos-print): Use dolist and with-current-buffer.
diff --git a/lisp/apropos.el b/lisp/apropos.el
index a073d293524..d453cb89de8 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -250,6 +250,12 @@ term, and the rest of the words are alternative terms.")
250 'action (lambda (button) 250 'action (lambda (button)
251 (apropos-describe-plist (button-get button 'apropos-symbol)))) 251 (apropos-describe-plist (button-get button 'apropos-symbol))))
252 252
253(define-button-type 'apropos-library
254 'help-echo "mouse-2, RET: Display more help on this library"
255 'follow-link t
256 'action (lambda (button)
257 (apropos-library (button-get button 'apropos-symbol))))
258
253(defun apropos-next-label-button (pos) 259(defun apropos-next-label-button (pos)
254 "Return the next apropos label button after POS, or nil if there's none. 260 "Return the next apropos label button after POS, or nil if there's none.
255Will also return nil if more than one `apropos-symbol' button is encountered 261Will also return nil if more than one `apropos-symbol' button is encountered
@@ -531,6 +537,66 @@ Returns list of symbols and documentation found."
531 (symbol-plist symbol))))) 537 (symbol-plist symbol)))))
532 (or do-all apropos-do-all))) 538 (or do-all apropos-do-all)))
533 539
540(defun apropos-library-button (sym)
541 (if (null sym)
542 "<nothing>"
543 (let ((name (copy-sequence (symbol-name sym))))
544 (make-text-button name nil
545 'type 'apropos-library
546 'face apropos-symbol-face
547 'apropos-symbol name)
548 name)))
549
550;;;###autoload
551(defun apropos-library (file)
552 "List the variables and functions defined by library FILE.
553FILE should be one of the libraries currently loaded and should
554thus be found in `load-history'."
555 (interactive
556 (let ((libs
557 (nconc (delq nil
558 (mapcar
559 (lambda (l)
560 (setq l (file-name-nondirectory l))
561 (while
562 (not (equal (setq l (file-name-sans-extension l))
563 l)))
564 l)
565 (mapcar 'car load-history)))
566 (mapcar 'car load-history))))
567 (list (completing-read "Describe library: " libs nil t))))
568 (let ((symbols nil)
569 ;; (autoloads nil)
570 (provides nil)
571 (requires nil)
572 (lh-entry (assoc file load-history)))
573 (unless lh-entry
574 ;; `file' may be the "shortname".
575 (let ((lh load-history)
576 (re (concat "\\(?:\\`\\|[\\/]\\)" (regexp-quote file)
577 "\\(\\.\\|\\'\\)")))
578 (while (and lh (null lh-entry))
579 (if (string-match re (caar lh))
580 (setq lh-entry (car lh))
581 (setq lh (cdr lh)))))
582 (unless lh-entry (error "Unknown library `%s'" file)))
583 (dolist (x (cdr lh-entry))
584 (case (car-safe x)
585 ;; (autoload (push (cdr x) autoloads))
586 (require (push (cdr x) requires))
587 (provide (push (cdr x) provides))
588 (t (push (or (cdr-safe x) x) symbols))))
589 (let ((apropos-pattern "")) ;Dummy binding for apropos-symbols-internal.
590 (apropos-symbols-internal
591 symbols apropos-do-all
592 (concat
593 (format "Library `%s' provides: %s\nand requires: %s"
594 file
595 (mapconcat 'apropos-library-button
596 (or provides '(nil)) " and ")
597 (mapconcat 'apropos-library-button
598 (or requires '(nil)) " and ")))))))
599
534(defun apropos-symbols-internal (symbols keys &optional text) 600(defun apropos-symbols-internal (symbols keys &optional text)
535 ;; Filter out entries that are marked as apropos-inhibit. 601 ;; Filter out entries that are marked as apropos-inhibit.
536 (let ((all nil)) 602 (let ((all nil))