+(defun apropos-library-button (sym)
+ (if (null sym)
+ "<nothing>"
+ (let ((name (copy-sequence (symbol-name sym))))
+ (make-text-button name nil
+ 'type 'apropos-library
+ 'face 'apropos-symbol
+ 'apropos-symbol name)
+ name)))
+
+;;;###autoload
+(defun apropos-library (file)
+ "List the variables and functions defined by library FILE.
+FILE should be one of the libraries currently loaded and should
+thus be found in `load-history'. If `apropos-do-all' is non-nil,
+the output includes key-bindings of commands."
+ (interactive
+ (let* ((libs (delq nil (mapcar 'car load-history)))
+ (libs
+ (nconc (delq nil
+ (mapcar
+ (lambda (l)
+ (setq l (file-name-nondirectory l))
+ (while
+ (not (equal (setq l (file-name-sans-extension l))
+ l)))
+ l)
+ libs))
+ libs)))
+ (list (completing-read "Describe library: " libs nil t))))
+ (let ((symbols nil)
+ ;; (autoloads nil)
+ (provides nil)
+ (requires nil)
+ (lh-entry (assoc file load-history)))
+ (unless lh-entry
+ ;; `file' may be the "shortname".
+ (let ((lh load-history)
+ (re (concat "\\(?:\\`\\|[\\/]\\)" (regexp-quote file)
+ "\\(\\.\\|\\'\\)")))
+ (while (and lh (null lh-entry))
+ (if (and (caar lh) (string-match re (caar lh)))
+ (setq lh-entry (car lh))
+ (setq lh (cdr lh)))))
+ (unless lh-entry (error "Unknown library `%s'" file)))
+ (dolist (x (cdr lh-entry))
+ (pcase (car-safe x)
+ ;; (autoload (push (cdr x) autoloads))
+ (`require (push (cdr x) requires))
+ (`provide (push (cdr x) provides))
+ (_ (push (or (cdr-safe x) x) symbols))))
+ (let ((apropos-pattern "")) ;Dummy binding for apropos-symbols-internal.
+ (apropos-symbols-internal
+ symbols apropos-do-all
+ (concat
+ (format "Library `%s' provides: %s\nand requires: %s"
+ file
+ (mapconcat 'apropos-library-button
+ (or provides '(nil)) " and ")
+ (mapconcat 'apropos-library-button
+ (or requires '(nil)) " and ")))))))
+