diff options
| author | Lars Ingebrigtsen | 2021-07-14 12:11:52 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-07-14 12:11:52 +0200 |
| commit | c218aa5b533be22f3a97a2d2a330de0907c7c34e (patch) | |
| tree | 41b209b242f465bb510a0c7bb9a54150d45c9ebb | |
| parent | dd34bef7d3769a8574bcee2c1e91e8445129af75 (diff) | |
| download | emacs-c218aa5b533be22f3a97a2d2a330de0907c7c34e.tar.gz 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." | |||
| 724 | ;; (autoload (push (cdr x) autoloads)) | 724 | ;; (autoload (push (cdr x) autoloads)) |
| 725 | ('require (push (cdr x) requires)) | 725 | ('require (push (cdr x) requires)) |
| 726 | ('provide (push (cdr x) provides)) | 726 | ('provide (push (cdr x) provides)) |
| 727 | ('t nil) ; Skip "was an autoload" entries. | 727 | ('t nil) ; Skip "was an autoload" entries. |
| 728 | ;; FIXME: Print information about each individual method: both | 728 | ;; FIXME: Print information about each individual method: both |
| 729 | ;; its docstring and specializers (bug#21422). | 729 | ;; its docstring and specializers (bug#21422). |
| 730 | ('cl-defmethod (push (cadr x) provides)) | 730 | ('cl-defmethod (push (cadr x) provides)) |
| 731 | (_ (push (or (cdr-safe x) x) symbols)))) | 731 | (_ (push (or (cdr-safe x) x) symbols)))) |
| 732 | (let ((apropos-pattern "")) ;Dummy binding for apropos-symbols-internal. | 732 | (let ((apropos-pattern "") ;Dummy binding for apropos-symbols-internal. |
| 733 | (apropos-symbols-internal | 733 | (text |
| 734 | symbols apropos-do-all | 734 | (concat |
| 735 | (concat | 735 | (format-message |
| 736 | (format-message | 736 | "Library `%s' provides: %s\nand requires: %s" |
| 737 | "Library `%s' provides: %s\nand requires: %s" | 737 | file |
| 738 | file | 738 | (mapconcat #'apropos-library-button |
| 739 | (mapconcat #'apropos-library-button | 739 | (or provides '(nil)) " and ") |
| 740 | (or provides '(nil)) " and ") | 740 | (mapconcat #'apropos-library-button |
| 741 | (mapconcat #'apropos-library-button | 741 | (or requires '(nil)) " and "))))) |
| 742 | (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))))) | ||
| 743 | 748 | ||
| 744 | (defun apropos-symbols-internal (symbols keys &optional text) | 749 | (defun apropos-symbols-internal (symbols keys &optional text) |
| 745 | ;; Filter out entries that are marked as apropos-inhibit. | 750 | ;; Filter out entries that are marked as apropos-inhibit. |
| @@ -1154,10 +1159,7 @@ as a heading." | |||
| 1154 | symbol item) | 1159 | symbol item) |
| 1155 | (set-buffer standard-output) | 1160 | (set-buffer standard-output) |
| 1156 | (apropos-mode) | 1161 | (apropos-mode) |
| 1157 | (insert (substitute-command-keys "Type \\[apropos-follow] on ") | 1162 | (apropos--preamble text) |
| 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")) | ||
| 1161 | (dolist (apropos-item p) | 1163 | (dolist (apropos-item p) |
| 1162 | (when (and spacing (not (bobp))) | 1164 | (when (and spacing (not (bobp))) |
| 1163 | (princ spacing)) | 1165 | (princ spacing)) |
| @@ -1287,6 +1289,14 @@ as a heading." | |||
| 1287 | (fill-region opoint (point) nil t))) | 1289 | (fill-region opoint (point) nil t))) |
| 1288 | (or (bolp) (terpri))))) | 1290 | (or (bolp) (terpri))))) |
| 1289 | 1291 | ||
| 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 | |||
| 1290 | (defun apropos-follow () | 1300 | (defun apropos-follow () |
| 1291 | "Invokes any button at point, otherwise invokes the nearest label button." | 1301 | "Invokes any button at point, otherwise invokes the nearest label button." |
| 1292 | (interactive) | 1302 | (interactive) |