(ctree-find-calist): Add optional argument 'all.
authormorioka <morioka>
Mon, 27 Apr 1998 12:55:07 +0000 (12:55 +0000)
committermorioka <morioka>
Mon, 27 Apr 1998 12:55:07 +0000 (12:55 +0000)
calist.el

index 38f4889..ee643b6 100644 (file)
--- a/calist.el
+++ b/calist.el
@@ -84,7 +84,7 @@
                    ret-alist))))
        ))))
 
-(defun ctree-find-calist (rule-tree alist)
+(defun ctree-find-calist (rule-tree alist &optional all)
   "Return list of condition-alist which matches ALIST in RULE-TREE."
   (if (null rule-tree)
       (list alist)
              (if ret-alist
                  (if (cdr choice)
                      (setq dest
-                           (append
-                            (ctree-find-calist (cdr choice) ret-alist)
-                            dest))
+                           (append (ctree-find-calist
+                                    (cdr choice) ret-alist all)
+                                   dest))
                    (setq dest (cons ret-alist dest))
                    )))))
        (setq choices (cdr choices)))
-      (or dest
+      (or (and (not all) dest)
          (if default
              (let ((ret-alist (calist-field-match alist type t)))
                (if ret-alist
                    (if (cdr default)
-                       (ctree-find-calist (cdr default) ret-alist)
-                     (list ret-alist)
-                     ))))))))
+                       (setq dest
+                             (append (ctree-find-calist
+                                      (cdr default) ret-alist all)
+                                     dest))
+                     (setq dest (cons ret-alist dest))
+                     ))))
+         )
+      dest)))
 
 (defun calist-to-ctree (calist)
   "Convert condition-alist CALIST to condition-tree."