Mercurial > emacs
comparison lisp/apropos.el @ 10282:84c786359b07
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 29 Dec 1994 01:46:34 +0000 |
parents | 58037e770f67 |
children | 1d1c5ea9eb86 |
comparison
equal
deleted
inserted
replaced
10281:44d98e169823 | 10282:84c786359b07 |
---|---|
91 (substring var-doc 0 (string-match "\n" var-doc)))) | 91 (substring var-doc 0 (string-match "\n" var-doc)))) |
92 (setcar p (list symbol fn-doc var-doc)) | 92 (setcar p (list symbol fn-doc var-doc)) |
93 (setq p (cdr p))) | 93 (setq p (cdr p))) |
94 list)) | 94 list)) |
95 | 95 |
96 ;; Variables bound by super-apropos and used by its subroutines. | |
97 ;; It would be good to say what each one is for, but I don't know -- rms. | |
98 (defvar apropos-item) | |
99 (defvar apropos-var-doc) | |
100 (defvar apropos-fn-doc) | |
101 (defvar apropos-accumulate) | |
102 (defvar apropos-regexp | |
103 "Within `super-apropos', this holds the REGEXP argument.") | |
104 | |
96 ;;;###autoload | 105 ;;;###autoload |
97 (defun super-apropos (regexp &optional do-all) | 106 (defun super-apropos (regexp &optional do-all) |
98 "Show symbols whose names/documentation contain matches for REGEXP. | 107 "Show symbols whose names/documentation contain matches for REGEXP. |
99 If optional argument DO-ALL is non-nil (prefix argument if interactive), | 108 If optional argument DO-ALL is non-nil (prefix argument if interactive), |
100 or if `apropos-do-all' is non-nil, does more (time-consuming) work such as | 109 or if `apropos-do-all' is non-nil, does more (time-consuming) work such as |
102 file. | 111 file. |
103 | 112 |
104 Returns list of symbols and documentation found." | 113 Returns list of symbols and documentation found." |
105 (interactive "sSuper Apropos: \nP") | 114 (interactive "sSuper Apropos: \nP") |
106 (setq do-all (or apropos-do-all do-all)) | 115 (setq do-all (or apropos-do-all do-all)) |
107 (let (apropos-accumulate fn-doc var-doc item) | 116 (let ((apropos-regexp regexp) |
108 (setq apropos-accumulate (super-apropos-check-doc-file regexp)) | 117 apropos-accumulate apropos-fn-doc apropos-var-doc apropos-item) |
118 (setq apropos-accumulate (super-apropos-check-doc-file apropos-regexp)) | |
109 (if (null apropos-accumulate) | 119 (if (null apropos-accumulate) |
110 (message "No apropos matches for `%s'" regexp) | 120 (message "No apropos matches for `%s'" apropos-regexp) |
111 (if do-all (mapatoms 'super-apropos-accumulate)) | 121 (if do-all (mapatoms 'super-apropos-accumulate)) |
112 (with-output-to-temp-buffer "*Help*" | 122 (with-output-to-temp-buffer "*Help*" |
113 (apropos-print-matches apropos-accumulate nil t do-all))) | 123 (apropos-print-matches apropos-accumulate nil t do-all))) |
114 apropos-accumulate)) | 124 apropos-accumulate)) |
115 | 125 |
141 (point) | 151 (point) |
142 (progn | 152 (progn |
143 (if (search-forward "\C-_" nil 'move) | 153 (if (search-forward "\C-_" nil 'move) |
144 (1- (point)) | 154 (1- (point)) |
145 (point)))) | 155 (point)))) |
146 item (assq symbol sym-list)) | 156 apropos-item (assq symbol sym-list)) |
147 (and (if (= type 1) | 157 (and (if (= type 1) |
148 (and (fboundp symbol) (documentation symbol)) | 158 (and (fboundp symbol) (documentation symbol)) |
149 (documentation-property symbol 'variable-documentation)) | 159 (documentation-property symbol 'variable-documentation)) |
150 (or item | 160 (or apropos-item |
151 (setq item (list symbol nil nil) | 161 (setq apropos-item (list symbol nil nil) |
152 sym-list (cons item sym-list))) | 162 sym-list (cons apropos-item sym-list))) |
153 (setcar (nthcdr type item) doc)))) | 163 (setcar (nthcdr type apropos-item) doc)))) |
154 sym-list)) | 164 sym-list)) |
155 | 165 |
156 ;; This is passed as the argument to map-atoms, so it is called once for every | 166 ;; This is passed as the argument to map-atoms, so it is called once for every |
157 ;; symbol in obarray. Takes one argument SYMBOL, and finds any memory-resident | 167 ;; symbol in obarray. Takes one argument SYMBOL, and finds any memory-resident |
158 ;; documentation on that symbol if it matches a variable regexp. WARNING: this | 168 ;; documentation on that symbol if it matches a variable regexp. |
159 ;; function depends on the symbols fn-doc var-doc regexp and item being bound | |
160 ;; correctly when it is called!" | |
161 | 169 |
162 (defun super-apropos-accumulate (symbol) | 170 (defun super-apropos-accumulate (symbol) |
163 (cond ((string-match regexp (symbol-name symbol)) | 171 (cond ((string-match apropos-regexp (symbol-name symbol)) |
164 (setq item (apropos-get-accum-item symbol)) | 172 (setq apropos-item (apropos-get-accum-item symbol)) |
165 (setcar (cdr item) (or (safe-documentation symbol) | 173 (setcar (cdr apropos-item) (or (safe-documentation symbol) |
166 (nth 1 item))) | 174 (nth 1 apropos-item))) |
167 (setcar (nthcdr 2 item) (or (safe-documentation-property symbol) | 175 (setcar (nthcdr 2 apropos-item) (or (safe-documentation-property symbol) |
168 (nth 2 item)))) | 176 (nth 2 apropos-item)))) |
169 (t | 177 (t |
170 (and (setq fn-doc (safe-documentation symbol)) | 178 (and (setq apropos-fn-doc (safe-documentation symbol)) |
171 (string-match regexp fn-doc) | 179 (string-match apropos-regexp apropos-fn-doc) |
172 (setcar (cdr (apropos-get-accum-item symbol)) fn-doc)) | 180 (setcar (cdr (apropos-get-accum-item symbol)) apropos-fn-doc)) |
173 (and (setq var-doc (safe-documentation-property symbol)) | 181 (and (setq apropos-var-doc (safe-documentation-property symbol)) |
174 (string-match regexp var-doc) | 182 (string-match apropos-regexp apropos-var-doc) |
175 (setcar (nthcdr 2 (apropos-get-accum-item symbol)) var-doc)))) | 183 (setcar (nthcdr 2 (apropos-get-accum-item symbol)) |
184 apropos-var-doc)))) | |
176 nil) | 185 nil) |
177 | 186 |
178 ;; Prints the symbols and documentation in alist MATCHES of form ((symbol | 187 ;; Prints the symbols and documentation in alist MATCHES of form ((symbol |
179 ;; fn-doc var-doc) ...). Uses optional argument REGEXP to speed up searching | 188 ;; fn-doc var-doc) ...). Uses optional argument REGEXP to speed up searching |
180 ;; for keybindings. The names of all symbols in MATCHES must match REGEXP. | 189 ;; for keybindings. The names of all symbols in MATCHES must match REGEXP. |