Commit 75a76881 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(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.
parent 7a410cb5
...@@ -51,13 +51,16 @@ Makes them run 2 or 3 times slower. Set this non-nil if you have a fast ...@@ -51,13 +51,16 @@ Makes them run 2 or 3 times slower. Set this non-nil if you have a fast
machine.") machine.")
;;;###autoload ;;;###autoload
(defun apropos (regexp &optional do-all pred) (defun apropos (regexp &optional do-all pred no-header)
"Show all symbols whose names contain matches for REGEXP. "Show all symbols whose names contain matches for REGEXP.
If optional argument DO-ALL is non-nil (prefix argument if interactive), If optional argument DO-ALL is non-nil (prefix argument if interactive),
or if `apropos-do-all' is non-nil, does more (time-consuming) work such as or if `apropos-do-all' is non-nil, does more (time-consuming) work such as
showing key bindings. Optional argument PRED is called with each symbol, and showing key bindings. Optional argument PRED is called with each symbol, and
if it returns nil, the symbol is not shown. if it returns nil, the symbol is not shown.
Optional argument NO-HEADER means don't print `Function:' or `Variable:'
in the output.
Returns list of symbols and documentation found." Returns list of symbols and documentation found."
(interactive "sApropos (regexp): \nP") (interactive "sApropos (regexp): \nP")
(setq do-all (or apropos-do-all do-all)) (setq do-all (or apropos-do-all do-all))
...@@ -66,15 +69,10 @@ Returns list of symbols and documentation found." ...@@ -66,15 +69,10 @@ Returns list of symbols and documentation found."
(message "No apropos matches for `%s'" regexp) (message "No apropos matches for `%s'" regexp)
(apropos-get-doc apropos-accumulate) (apropos-get-doc apropos-accumulate)
(with-output-to-temp-buffer "*Help*" (with-output-to-temp-buffer "*Help*"
(apropos-print-matches apropos-accumulate regexp nil do-all))) (apropos-print-matches apropos-accumulate regexp nil
do-all no-header)))
apropos-accumulate)) apropos-accumulate))
;; If "C-h a" still has its original binding of command-apropos, change it to
;; use fast-command-apropos. I don't use substitute-key-definition because
;; it's slow.
;(if (eq 'command-apropos (lookup-key help-map "a"))
; (define-key help-map "a" 'fast-command-apropos))
;; Takes LIST of symbols and adds documentation. Modifies LIST in place. ;; Takes LIST of symbols and adds documentation. Modifies LIST in place.
;; Resulting alist is of form ((symbol fn-doc var-doc) ...). Should only be ;; Resulting alist is of form ((symbol fn-doc var-doc) ...). Should only be
;; called by apropos. Returns LIST. ;; called by apropos. Returns LIST.
...@@ -186,7 +184,8 @@ Returns list of symbols and documentation found." ...@@ -186,7 +184,8 @@ Returns list of symbols and documentation found."
;; consulting key bindings. Should only be called within a ;; consulting key bindings. Should only be called within a
;; with-output-to-temp-buffer. ;; with-output-to-temp-buffer.
(defun apropos-print-matches (matches &optional regexp spacing do-all) (defun apropos-print-matches (matches &optional regexp
spacing do-all no-header)
(setq matches (sort matches (function (setq matches (sort matches (function
(lambda (a b) (lambda (a b)
(string-lessp (car a) (car b)))))) (string-lessp (car a) (car b))))))
...@@ -217,12 +216,22 @@ Returns list of symbols and documentation found." ...@@ -217,12 +216,22 @@ Returns list of symbols and documentation found."
(princ "(not bound to any keys)")))) (princ "(not bound to any keys)"))))
(terpri) (terpri)
(cond ((setq tem (nth 1 item)) (cond ((setq tem (nth 1 item))
(princ " Function: ") (let ((substed (if do-all (substitute-command-keys tem) tem)))
(princ (if do-all (substitute-command-keys tem) tem)))) (if no-header
(princ " ")
(princ " Function: ")
(if (> (length substed) 67)
(princ "\n ")))
(princ substed))))
(or (bolp) (terpri)) (or (bolp) (terpri))
(cond ((setq tem (nth 2 item)) (cond ((setq tem (nth 2 item))
(princ " Variable: ") (let ((substed (if do-all (substitute-command-keys tem) tem)))
(princ (if do-all (substitute-command-keys tem) tem)))) (if no-header
(princ " ")
(princ " Variable: ")
(if (> (length substed) 67)
(princ "\n ")))
(princ substed))))
(or (bolp) (terpri))))) (or (bolp) (terpri)))))
t) t)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment