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

(super-apropos, super-apropos-check-doc-file)

(super-apropos-accumulate): Vars item, fn-doc and var-doc renamed
to apropos-item, apropos-fn-doc and apropos-var-doc.
(apropos-item, apropos-var-doc, apropos-fn-doc)
(apropos-accumulate, apropos-regexp): New defvars.
(super-apropos): Bind apropos-regexp to regexp.
(super-apropos-accumulate): Use apropos-regexp.
parent 68469f74
...@@ -93,6 +93,15 @@ Returns list of symbols and documentation found." ...@@ -93,6 +93,15 @@ Returns list of symbols and documentation found."
(setq p (cdr p))) (setq p (cdr p)))
list)) list))
;; Variables bound by super-apropos and used by its subroutines.
;; It would be good to say what each one is for, but I don't know -- rms.
(defvar apropos-item)
(defvar apropos-var-doc)
(defvar apropos-fn-doc)
(defvar apropos-accumulate)
(defvar apropos-regexp
"Within `super-apropos', this holds the REGEXP argument.")
;;;###autoload ;;;###autoload
(defun super-apropos (regexp &optional do-all) (defun super-apropos (regexp &optional do-all)
"Show symbols whose names/documentation contain matches for REGEXP. "Show symbols whose names/documentation contain matches for REGEXP.
...@@ -104,10 +113,11 @@ file. ...@@ -104,10 +113,11 @@ file.
Returns list of symbols and documentation found." Returns list of symbols and documentation found."
(interactive "sSuper Apropos: \nP") (interactive "sSuper Apropos: \nP")
(setq do-all (or apropos-do-all do-all)) (setq do-all (or apropos-do-all do-all))
(let (apropos-accumulate fn-doc var-doc item) (let ((apropos-regexp regexp)
(setq apropos-accumulate (super-apropos-check-doc-file regexp)) apropos-accumulate apropos-fn-doc apropos-var-doc apropos-item)
(setq apropos-accumulate (super-apropos-check-doc-file apropos-regexp))
(if (null apropos-accumulate) (if (null apropos-accumulate)
(message "No apropos matches for `%s'" regexp) (message "No apropos matches for `%s'" apropos-regexp)
(if do-all (mapatoms 'super-apropos-accumulate)) (if do-all (mapatoms 'super-apropos-accumulate))
(with-output-to-temp-buffer "*Help*" (with-output-to-temp-buffer "*Help*"
(apropos-print-matches apropos-accumulate nil t do-all))) (apropos-print-matches apropos-accumulate nil t do-all)))
...@@ -143,36 +153,35 @@ Returns list of symbols and documentation found." ...@@ -143,36 +153,35 @@ Returns list of symbols and documentation found."
(if (search-forward "\C-_" nil 'move) (if (search-forward "\C-_" nil 'move)
(1- (point)) (1- (point))
(point)))) (point))))
item (assq symbol sym-list)) apropos-item (assq symbol sym-list))
(and (if (= type 1) (and (if (= type 1)
(and (fboundp symbol) (documentation symbol)) (and (fboundp symbol) (documentation symbol))
(documentation-property symbol 'variable-documentation)) (documentation-property symbol 'variable-documentation))
(or item (or apropos-item
(setq item (list symbol nil nil) (setq apropos-item (list symbol nil nil)
sym-list (cons item sym-list))) sym-list (cons apropos-item sym-list)))
(setcar (nthcdr type item) doc)))) (setcar (nthcdr type apropos-item) doc))))
sym-list)) sym-list))
;; This is passed as the argument to map-atoms, so it is called once for every ;; This is passed as the argument to map-atoms, so it is called once for every
;; symbol in obarray. Takes one argument SYMBOL, and finds any memory-resident ;; symbol in obarray. Takes one argument SYMBOL, and finds any memory-resident
;; documentation on that symbol if it matches a variable regexp. WARNING: this ;; documentation on that symbol if it matches a variable regexp.
;; function depends on the symbols fn-doc var-doc regexp and item being bound
;; correctly when it is called!"
(defun super-apropos-accumulate (symbol) (defun super-apropos-accumulate (symbol)
(cond ((string-match regexp (symbol-name symbol)) (cond ((string-match apropos-regexp (symbol-name symbol))
(setq item (apropos-get-accum-item symbol)) (setq apropos-item (apropos-get-accum-item symbol))
(setcar (cdr item) (or (safe-documentation symbol) (setcar (cdr apropos-item) (or (safe-documentation symbol)
(nth 1 item))) (nth 1 apropos-item)))
(setcar (nthcdr 2 item) (or (safe-documentation-property symbol) (setcar (nthcdr 2 apropos-item) (or (safe-documentation-property symbol)
(nth 2 item)))) (nth 2 apropos-item))))
(t (t
(and (setq fn-doc (safe-documentation symbol)) (and (setq apropos-fn-doc (safe-documentation symbol))
(string-match regexp fn-doc) (string-match apropos-regexp apropos-fn-doc)
(setcar (cdr (apropos-get-accum-item symbol)) fn-doc)) (setcar (cdr (apropos-get-accum-item symbol)) apropos-fn-doc))
(and (setq var-doc (safe-documentation-property symbol)) (and (setq apropos-var-doc (safe-documentation-property symbol))
(string-match regexp var-doc) (string-match apropos-regexp apropos-var-doc)
(setcar (nthcdr 2 (apropos-get-accum-item symbol)) var-doc)))) (setcar (nthcdr 2 (apropos-get-accum-item symbol))
apropos-var-doc))))
nil) nil)
;; Prints the symbols and documentation in alist MATCHES of form ((symbol ;; Prints the symbols and documentation in alist MATCHES of form ((symbol
......
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