emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c218aa5: Make `apropos-library' also work for libraries without s


From: Lars Ingebrigtsen
Subject: master c218aa5: Make `apropos-library' also work for libraries without symbols
Date: Wed, 14 Jul 2021 06:12:01 -0400 (EDT)

branch: master
commit c218aa5b533be22f3a97a2d2a330de0907c7c34e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 lisp/apropos.el | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/lisp/apropos.el b/lisp/apropos.el
index f246064..376c1b2 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]