From: Lars Ingebrigtsen Date: Wed, 14 Jul 2021 10:11:52 +0000 (+0200) Subject: Make `apropos-library' also work for libraries without symbols X-Git-Tag: emacs-28.0.90~1875 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c218aa5b533be22f3a97a2d2a330de0907c7c34e;p=emacs.git 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. --- 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)