diff options
| author | Richard M. Stallman | 1998-05-24 23:11:14 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-24 23:11:14 +0000 |
| commit | 05942d060ed2ef46e3358ad5ec22ed7fb90f0578 (patch) | |
| tree | a03a7c66cb49d091c9d69981d54eacfcf4d74ba4 | |
| parent | cd3b7f95a1af31964d353fcc0299dc7c719ad750 (diff) | |
| download | emacs-05942d060ed2ef46e3358ad5ec22ed7fb90f0578.tar.gz emacs-05942d060ed2ef46e3358ad5ec22ed7fb90f0578.zip | |
(apropos-command): Change 3rd arg to VAR-PREDICATE
and use it as a predicate for which variables to match.
(apropos-variable): Use that feature to match all documented vars,
if have prefix arg.
| -rw-r--r-- | lisp/apropos.el | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el index f726029c7ea..94701b8f27a 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el | |||
| @@ -140,18 +140,35 @@ This looks good, but slows down the commands several times." | |||
| 140 | mode-name "Apropos")) | 140 | mode-name "Apropos")) |
| 141 | 141 | ||
| 142 | ;;;###autoload | 142 | ;;;###autoload |
| 143 | (defun apropos-variable (regexp) | 143 | (defun apropos-variable (regexp &optional do-all) |
| 144 | (interactive (list (read-string "Apropos variable (regexp): "))) | 144 | "Show user variables that match REGEXP. |
| 145 | (apropos-command regexp nil t)) | 145 | With optional prefix ARG or if `apropos-do-all' is non-nil, also show |
| 146 | normal variables." | ||
| 147 | (interactive (list (read-string | ||
| 148 | (concat "Apropos " | ||
| 149 | (if (or current-prefix-arg apropos-do-all) | ||
| 150 | "variable" | ||
| 151 | "user option") | ||
| 152 | " (regexp): ")) | ||
| 153 | current-prefix-arg)) | ||
| 154 | (apropos-command regexp nil | ||
| 155 | (if arg | ||
| 156 | #'(lambda (symbol) | ||
| 157 | (and (boundp symbol) | ||
| 158 | (get symbol 'variable-documentation))) | ||
| 159 | 'user-variable-p))) | ||
| 146 | 160 | ||
| 147 | ;; For auld lang syne: | 161 | ;; For auld lang syne: |
| 148 | ;;;###autoload | 162 | ;;;###autoload |
| 149 | (fset 'command-apropos 'apropos-command) | 163 | (fset 'command-apropos 'apropos-command) |
| 150 | ;;;###autoload | 164 | ;;;###autoload |
| 151 | (defun apropos-command (apropos-regexp &optional do-all just-vars) | 165 | (defun apropos-command (apropos-regexp &optional do-all var-predicate) |
| 152 | "Show commands (interactively callable functions) that match REGEXP. | 166 | "Show commands (interactively callable functions) that match REGEXP. |
| 153 | With optional prefix ARG, or if `apropos-do-all' is non-nil, also show | 167 | With optional prefix ARG, or if `apropos-do-all' is non-nil, also show |
| 154 | variables. If JUST-VARS is non-nil, show only variables." | 168 | user option variables. |
| 169 | |||
| 170 | If VAR-PREDICATE is non-nil, show only variables that | ||
| 171 | satisfy the predicate VAR-PREDICATE." | ||
| 155 | (interactive (list (read-string (concat | 172 | (interactive (list (read-string (concat |
| 156 | "Apropos command " | 173 | "Apropos command " |
| 157 | (if (or current-prefix-arg | 174 | (if (or current-prefix-arg |
| @@ -168,8 +185,9 @@ variables. If JUST-VARS is non-nil, show only variables." | |||
| 168 | (if do-all | 185 | (if do-all |
| 169 | (lambda (symbol) (or (commandp symbol) | 186 | (lambda (symbol) (or (commandp symbol) |
| 170 | (user-variable-p symbol))) | 187 | (user-variable-p symbol))) |
| 171 | (if just-vars 'user-variable-p | 188 | (or var-predicate 'commandp)))) |
| 172 | 'commandp)))) | 189 | (if do-all |
| 190 | (setq var-predicate 'user-variable-p)) | ||
| 173 | (let ((tem apropos-accumulator)) | 191 | (let ((tem apropos-accumulator)) |
| 174 | (while tem | 192 | (while tem |
| 175 | (if (get (car tem) 'apropos-inhibit) | 193 | (if (get (car tem) 'apropos-inhibit) |
| @@ -182,13 +200,13 @@ variables. If JUST-VARS is non-nil, show only variables." | |||
| 182 | (while p | 200 | (while p |
| 183 | (setcar p (list | 201 | (setcar p (list |
| 184 | (setq symbol (car p)) | 202 | (setq symbol (car p)) |
| 185 | (if (or do-all (not just-vars)) | 203 | (if (or do-all (not var-predicate)) |
| 186 | (if (commandp symbol) | 204 | (if (commandp symbol) |
| 187 | (if (setq doc (documentation symbol t)) | 205 | (if (setq doc (documentation symbol t)) |
| 188 | (substring doc 0 (string-match "\n" doc)) | 206 | (substring doc 0 (string-match "\n" doc)) |
| 189 | "(not documented)"))) | 207 | "(not documented)"))) |
| 190 | (and do-all | 208 | (and var-predicate |
| 191 | (user-variable-p symbol) | 209 | (funcall var-predicate symbol) |
| 192 | (if (setq doc (documentation-property | 210 | (if (setq doc (documentation-property |
| 193 | symbol 'variable-documentation t)) | 211 | symbol 'variable-documentation t)) |
| 194 | (substring doc 0 | 212 | (substring doc 0 |
| @@ -484,8 +502,8 @@ Will return nil instead." | |||
| 484 | (defun apropos-print (do-keys doc-fn spacing) | 502 | (defun apropos-print (do-keys doc-fn spacing) |
| 485 | "Output result of various apropos commands with `apropos-regexp'. | 503 | "Output result of various apropos commands with `apropos-regexp'. |
| 486 | APROPOS-ACCUMULATOR is a list. Optional DOC-FN is called for each element | 504 | APROPOS-ACCUMULATOR is a list. Optional DOC-FN is called for each element |
| 487 | of apropos-accumulator and may modify it resulting in (symbol fn-doc | 505 | of apropos-accumulator and may modify it resulting in (SYMBOL FN-DOC |
| 488 | var-doc [plist-doc]). Returns sorted list of symbols and documentation | 506 | VAR-DOC [PLIST-DOC]). Returns sorted list of symbols and documentation |
| 489 | found." | 507 | found." |
| 490 | (if (null apropos-accumulator) | 508 | (if (null apropos-accumulator) |
| 491 | (message "No apropos matches for `%s'" apropos-regexp) | 509 | (message "No apropos matches for `%s'" apropos-regexp) |