From 05942d060ed2ef46e3358ad5ec22ed7fb90f0578 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sun, 24 May 1998 23:11:14 +0000 Subject: [PATCH] (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. --- lisp/apropos.el | 42 ++++++++++++++++++++++++++++++------------ 1 file 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." mode-name "Apropos")) ;;;###autoload -(defun apropos-variable (regexp) - (interactive (list (read-string "Apropos variable (regexp): "))) - (apropos-command regexp nil t)) +(defun apropos-variable (regexp &optional do-all) + "Show user variables that match REGEXP. +With optional prefix ARG or if `apropos-do-all' is non-nil, also show +normal variables." + (interactive (list (read-string + (concat "Apropos " + (if (or current-prefix-arg apropos-do-all) + "variable" + "user option") + " (regexp): ")) + current-prefix-arg)) + (apropos-command regexp nil + (if arg + #'(lambda (symbol) + (and (boundp symbol) + (get symbol 'variable-documentation))) + 'user-variable-p))) ;; For auld lang syne: ;;;###autoload (fset 'command-apropos 'apropos-command) ;;;###autoload -(defun apropos-command (apropos-regexp &optional do-all just-vars) +(defun apropos-command (apropos-regexp &optional do-all var-predicate) "Show commands (interactively callable functions) that match REGEXP. With optional prefix ARG, or if `apropos-do-all' is non-nil, also show -variables. If JUST-VARS is non-nil, show only variables." +user option variables. + +If VAR-PREDICATE is non-nil, show only variables that +satisfy the predicate VAR-PREDICATE." (interactive (list (read-string (concat "Apropos command " (if (or current-prefix-arg @@ -168,8 +185,9 @@ variables. If JUST-VARS is non-nil, show only variables." (if do-all (lambda (symbol) (or (commandp symbol) (user-variable-p symbol))) - (if just-vars 'user-variable-p - 'commandp)))) + (or var-predicate 'commandp)))) + (if do-all + (setq var-predicate 'user-variable-p)) (let ((tem apropos-accumulator)) (while tem (if (get (car tem) 'apropos-inhibit) @@ -182,13 +200,13 @@ variables. If JUST-VARS is non-nil, show only variables." (while p (setcar p (list (setq symbol (car p)) - (if (or do-all (not just-vars)) + (if (or do-all (not var-predicate)) (if (commandp symbol) (if (setq doc (documentation symbol t)) (substring doc 0 (string-match "\n" doc)) "(not documented)"))) - (and do-all - (user-variable-p symbol) + (and var-predicate + (funcall var-predicate symbol) (if (setq doc (documentation-property symbol 'variable-documentation t)) (substring doc 0 @@ -484,8 +502,8 @@ Will return nil instead." (defun apropos-print (do-keys doc-fn spacing) "Output result of various apropos commands with `apropos-regexp'. APROPOS-ACCUMULATOR is a list. Optional DOC-FN is called for each element -of apropos-accumulator and may modify it resulting in (symbol fn-doc -var-doc [plist-doc]). Returns sorted list of symbols and documentation +of apropos-accumulator and may modify it resulting in (SYMBOL FN-DOC +VAR-DOC [PLIST-DOC]). Returns sorted list of symbols and documentation found." (if (null apropos-accumulator) (message "No apropos matches for `%s'" apropos-regexp) -- 2.39.2