diff options
| author | Richard M. Stallman | 1994-10-01 21:10:38 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-10-01 21:10:38 +0000 |
| commit | 75a768810df9fb9492ae42cf5274670c2d7d5763 (patch) | |
| tree | 06ddea2f0d9c2c4ee78d16468a5645c5f53a7c25 | |
| parent | 7a410cb5fbddfad125c57cae94e63470635617dc (diff) | |
| download | emacs-75a768810df9fb9492ae42cf5274670c2d7d5763.tar.gz emacs-75a768810df9fb9492ae42cf5274670c2d7d5763.zip | |
(apropos-print-matches): Add newline after
Function: or Variable: if line doesn't fit with it.
New arg no-header inhibits them entirely.
(apropos): New arg no-header. Pass it to apropos-print-matches.
| -rw-r--r-- | lisp/apropos.el | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el index 5d9ddc17d74..2681a8b88b9 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el | |||
| @@ -51,13 +51,16 @@ Makes them run 2 or 3 times slower. Set this non-nil if you have a fast | |||
| 51 | machine.") | 51 | machine.") |
| 52 | 52 | ||
| 53 | ;;;###autoload | 53 | ;;;###autoload |
| 54 | (defun apropos (regexp &optional do-all pred) | 54 | (defun apropos (regexp &optional do-all pred no-header) |
| 55 | "Show all symbols whose names contain matches for REGEXP. | 55 | "Show all symbols whose names contain matches for REGEXP. |
| 56 | If optional argument DO-ALL is non-nil (prefix argument if interactive), | 56 | If optional argument DO-ALL is non-nil (prefix argument if interactive), |
| 57 | or if `apropos-do-all' is non-nil, does more (time-consuming) work such as | 57 | or if `apropos-do-all' is non-nil, does more (time-consuming) work such as |
| 58 | showing key bindings. Optional argument PRED is called with each symbol, and | 58 | showing key bindings. Optional argument PRED is called with each symbol, and |
| 59 | if it returns nil, the symbol is not shown. | 59 | if it returns nil, the symbol is not shown. |
| 60 | 60 | ||
| 61 | Optional argument NO-HEADER means don't print `Function:' or `Variable:' | ||
| 62 | in the output. | ||
| 63 | |||
| 61 | Returns list of symbols and documentation found." | 64 | Returns list of symbols and documentation found." |
| 62 | (interactive "sApropos (regexp): \nP") | 65 | (interactive "sApropos (regexp): \nP") |
| 63 | (setq do-all (or apropos-do-all do-all)) | 66 | (setq do-all (or apropos-do-all do-all)) |
| @@ -66,15 +69,10 @@ Returns list of symbols and documentation found." | |||
| 66 | (message "No apropos matches for `%s'" regexp) | 69 | (message "No apropos matches for `%s'" regexp) |
| 67 | (apropos-get-doc apropos-accumulate) | 70 | (apropos-get-doc apropos-accumulate) |
| 68 | (with-output-to-temp-buffer "*Help*" | 71 | (with-output-to-temp-buffer "*Help*" |
| 69 | (apropos-print-matches apropos-accumulate regexp nil do-all))) | 72 | (apropos-print-matches apropos-accumulate regexp nil |
| 73 | do-all no-header))) | ||
| 70 | apropos-accumulate)) | 74 | apropos-accumulate)) |
| 71 | 75 | ||
| 72 | ;; If "C-h a" still has its original binding of command-apropos, change it to | ||
| 73 | ;; use fast-command-apropos. I don't use substitute-key-definition because | ||
| 74 | ;; it's slow. | ||
| 75 | ;(if (eq 'command-apropos (lookup-key help-map "a")) | ||
| 76 | ; (define-key help-map "a" 'fast-command-apropos)) | ||
| 77 | |||
| 78 | ;; Takes LIST of symbols and adds documentation. Modifies LIST in place. | 76 | ;; Takes LIST of symbols and adds documentation. Modifies LIST in place. |
| 79 | ;; Resulting alist is of form ((symbol fn-doc var-doc) ...). Should only be | 77 | ;; Resulting alist is of form ((symbol fn-doc var-doc) ...). Should only be |
| 80 | ;; called by apropos. Returns LIST. | 78 | ;; called by apropos. Returns LIST. |
| @@ -186,7 +184,8 @@ Returns list of symbols and documentation found." | |||
| 186 | ;; consulting key bindings. Should only be called within a | 184 | ;; consulting key bindings. Should only be called within a |
| 187 | ;; with-output-to-temp-buffer. | 185 | ;; with-output-to-temp-buffer. |
| 188 | 186 | ||
| 189 | (defun apropos-print-matches (matches &optional regexp spacing do-all) | 187 | (defun apropos-print-matches (matches &optional regexp |
| 188 | spacing do-all no-header) | ||
| 190 | (setq matches (sort matches (function | 189 | (setq matches (sort matches (function |
| 191 | (lambda (a b) | 190 | (lambda (a b) |
| 192 | (string-lessp (car a) (car b)))))) | 191 | (string-lessp (car a) (car b)))))) |
| @@ -217,12 +216,22 @@ Returns list of symbols and documentation found." | |||
| 217 | (princ "(not bound to any keys)")))) | 216 | (princ "(not bound to any keys)")))) |
| 218 | (terpri) | 217 | (terpri) |
| 219 | (cond ((setq tem (nth 1 item)) | 218 | (cond ((setq tem (nth 1 item)) |
| 220 | (princ " Function: ") | 219 | (let ((substed (if do-all (substitute-command-keys tem) tem))) |
| 221 | (princ (if do-all (substitute-command-keys tem) tem)))) | 220 | (if no-header |
| 221 | (princ " ") | ||
| 222 | (princ " Function: ") | ||
| 223 | (if (> (length substed) 67) | ||
| 224 | (princ "\n "))) | ||
| 225 | (princ substed)))) | ||
| 222 | (or (bolp) (terpri)) | 226 | (or (bolp) (terpri)) |
| 223 | (cond ((setq tem (nth 2 item)) | 227 | (cond ((setq tem (nth 2 item)) |
| 224 | (princ " Variable: ") | 228 | (let ((substed (if do-all (substitute-command-keys tem) tem))) |
| 225 | (princ (if do-all (substitute-command-keys tem) tem)))) | 229 | (if no-header |
| 230 | (princ " ") | ||
| 231 | (princ " Variable: ") | ||
| 232 | (if (> (length substed) 67) | ||
| 233 | (princ "\n "))) | ||
| 234 | (princ substed)))) | ||
| 226 | (or (bolp) (terpri))))) | 235 | (or (bolp) (terpri))))) |
| 227 | t) | 236 | t) |
| 228 | 237 | ||