changeset 22218:eb4deede0c5a

(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.
author Richard M. Stallman <rms@gnu.org>
date Sun, 24 May 1998 23:11:14 +0000
parents e83578642825
children 0d635ed37f07
files lisp/apropos.el
diffstat 1 files changed, 30 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/apropos.el	Sun May 24 19:40:12 1998 +0000
+++ b/lisp/apropos.el	Sun May 24 23:11:14 1998 +0000
@@ -140,18 +140,35 @@
 	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 @@
 			    (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 @@
 	     (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 @@
 (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)