diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-14 12:11:52 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-14 12:11:52 +0200 |
commit | c218aa5b533be22f3a97a2d2a330de0907c7c34e (patch) | |
tree | 41b209b242f465bb510a0c7bb9a54150d45c9ebb | |
parent | dd34bef7d3769a8574bcee2c1e91e8445129af75 (diff) | |
download | emacs-c218aa5b533be22f3a97a2d2a330de0907c7c34e.tar.gz emacs-c218aa5b533be22f3a97a2d2a330de0907c7c34e.tar.bz2 emacs-c218aa5b533be22f3a97a2d2a330de0907c7c34e.zip |
Make `apropos-library' also work for libraries without symbols
* lisp/apropos.el (apropos--preamble): Factor out (bug#17832)...
(apropos-print-doc): ... from here.
(apropos-library): Use it to display the apropos buffer even if it
has no symbols of its own.
-rw-r--r-- | lisp/apropos.el | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el index f2460643ab3..376c1b2cbc5 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -724,22 +724,27 @@ the output includes key-bindings of commands." ;; (autoload (push (cdr x) autoloads)) ('require (push (cdr x) requires)) ('provide (push (cdr x) provides)) - ('t nil) ; Skip "was an autoload" entries. + ('t nil) ; Skip "was an autoload" entries. ;; FIXME: Print information about each individual method: both ;; its docstring and specializers (bug#21422). ('cl-defmethod (push (cadr 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-message - "Library `%s' provides: %s\nand requires: %s" - file - (mapconcat #'apropos-library-button - (or provides '(nil)) " and ") - (mapconcat #'apropos-library-button - (or requires '(nil)) " and "))))))) + (let ((apropos-pattern "") ;Dummy binding for apropos-symbols-internal. + (text + (concat + (format-message + "Library `%s' provides: %s\nand requires: %s" + file + (mapconcat #'apropos-library-button + (or provides '(nil)) " and ") + (mapconcat #'apropos-library-button + (or requires '(nil)) " and "))))) + (if (null symbols) + (with-output-to-temp-buffer "*Apropos*" + (with-current-buffer standard-output + (apropos-mode) + (apropos--preamble text))) + (apropos-symbols-internal symbols apropos-do-all text))))) (defun apropos-symbols-internal (symbols keys &optional text) ;; Filter out entries that are marked as apropos-inhibit. @@ -1154,10 +1159,7 @@ as a heading." symbol item) (set-buffer standard-output) (apropos-mode) - (insert (substitute-command-keys "Type \\[apropos-follow] on ") - (if apropos-multi-type "a type label" "an entry") - " to view its full documentation.\n\n") - (if text (insert text "\n\n")) + (apropos--preamble text) (dolist (apropos-item p) (when (and spacing (not (bobp))) (princ spacing)) @@ -1287,6 +1289,14 @@ as a heading." (fill-region opoint (point) nil t))) (or (bolp) (terpri))))) +(defun apropos--preamble (text) + (let ((inhibit-read-only t)) + (insert (substitute-command-keys "Type \\[apropos-follow] on ") + (if apropos-multi-type "a type label" "an entry") + " to view its full documentation.\n\n") + (when text + (insert text "\n\n")))) + (defun apropos-follow () "Invokes any button at point, otherwise invokes the nearest label button." (interactive) |