X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=calist.el;fp=calist.el;h=0d47b82a478a63a9835f75e84256e0213d4991c3;hb=e9a9f01552a1f8513594ab418bb65967371c2c10;hp=154e10571896e1fc22830c343ed21f987fe446fa;hpb=1af6e74fe363b80443ad0cad9238c71dd5f0e4cb;p=elisp%2Fapel.git diff --git a/calist.el b/calist.el index 154e105..0d47b82 100644 --- a/calist.el +++ b/calist.el @@ -84,6 +84,37 @@ ret-alist)))) )))) +(defun ctree-match-calist-all (rule-tree alist) + "Return matched condition-alist if ALIST matches RULE-TREE." + (if (null rule-tree) + (list alist) + (let ((type (car rule-tree)) + (choices (cdr rule-tree)) + default dest) + (while choices + (let* ((choice (car choices)) + (choice-value (car choice))) + (if (eq choice-value t) + (setq default choice) + (let ((ret-alist (calist-field-match alist type (car choice)))) + (if ret-alist + (if (cdr choice) + (setq dest + (append + (ctree-match-calist-all (cdr choice) ret-alist) + dest)) + (setq dest (cons ret-alist dest)) + ))))) + (setq choices (cdr choices))) + (or dest + (if default + (let ((ret-alist (calist-field-match alist type t))) + (if ret-alist + (if (cdr default) + (ctree-match-calist-all (cdr default) ret-alist) + (list ret-alist) + )))))))) + (defun calist-to-ctree (calist) "Convert condition-alist CALIST to condition-tree." (if calist