Skip to content

Commit c218aa5

Browse files
committed
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.
1 parent dd34bef commit c218aa5

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

lisp/apropos.el

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -724,22 +724,27 @@ the output includes key-bindings of commands."
724724
;; (autoload (push (cdr x) autoloads))
725725
('require (push (cdr x) requires))
726726
('provide (push (cdr x) provides))
727-
('t nil) ; Skip "was an autoload" entries.
727+
('t nil) ; Skip "was an autoload" entries.
728728
;; FIXME: Print information about each individual method: both
729729
;; its docstring and specializers (bug#21422).
730730
('cl-defmethod (push (cadr x) provides))
731731
(_ (push (or (cdr-safe x) x) symbols))))
732-
(let ((apropos-pattern "")) ;Dummy binding for apropos-symbols-internal.
733-
(apropos-symbols-internal
734-
symbols apropos-do-all
735-
(concat
736-
(format-message
737-
"Library `%s' provides: %s\nand requires: %s"
738-
file
739-
(mapconcat #'apropos-library-button
740-
(or provides '(nil)) " and ")
741-
(mapconcat #'apropos-library-button
742-
(or requires '(nil)) " and ")))))))
732+
(let ((apropos-pattern "") ;Dummy binding for apropos-symbols-internal.
733+
(text
734+
(concat
735+
(format-message
736+
"Library `%s' provides: %s\nand requires: %s"
737+
file
738+
(mapconcat #'apropos-library-button
739+
(or provides '(nil)) " and ")
740+
(mapconcat #'apropos-library-button
741+
(or requires '(nil)) " and ")))))
742+
(if (null symbols)
743+
(with-output-to-temp-buffer "*Apropos*"
744+
(with-current-buffer standard-output
745+
(apropos-mode)
746+
(apropos--preamble text)))
747+
(apropos-symbols-internal symbols apropos-do-all text)))))
743748

744749
(defun apropos-symbols-internal (symbols keys &optional text)
745750
;; Filter out entries that are marked as apropos-inhibit.
@@ -1154,10 +1159,7 @@ as a heading."
11541159
symbol item)
11551160
(set-buffer standard-output)
11561161
(apropos-mode)
1157-
(insert (substitute-command-keys "Type \\[apropos-follow] on ")
1158-
(if apropos-multi-type "a type label" "an entry")
1159-
" to view its full documentation.\n\n")
1160-
(if text (insert text "\n\n"))
1162+
(apropos--preamble text)
11611163
(dolist (apropos-item p)
11621164
(when (and spacing (not (bobp)))
11631165
(princ spacing))
@@ -1287,6 +1289,14 @@ as a heading."
12871289
(fill-region opoint (point) nil t)))
12881290
(or (bolp) (terpri)))))
12891291

1292+
(defun apropos--preamble (text)
1293+
(let ((inhibit-read-only t))
1294+
(insert (substitute-command-keys "Type \\[apropos-follow] on ")
1295+
(if apropos-multi-type "a type label" "an entry")
1296+
" to view its full documentation.\n\n")
1297+
(when text
1298+
(insert text "\n\n"))))
1299+
12901300
(defun apropos-follow ()
12911301
"Invokes any button at point, otherwise invokes the nearest label button."
12921302
(interactive)

0 commit comments

Comments
 (0)