Function: org-agenda-filter-make-matcher

org-agenda-filter-make-matcher is a byte-compiled function defined in org-agenda.el.gz.

Signature

(org-agenda-filter-make-matcher FILTER TYPE &optional EXPAND)

Documentation

Create the form that tests a line for agenda filter.

Optional argument EXPAND can be used for the TYPE tag and will expand the tags in the FILTER if any of the tags in FILTER are grouptags.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-filter-make-matcher (filter type &optional expand)
  "Create the form that tests a line for agenda filter.
Optional argument EXPAND can be used for the TYPE tag and will
expand the tags in the FILTER if any of the tags in FILTER are
grouptags."
  (let ((multi-pos-cats
	 (and (eq type 'category)
	      (string-match-p "\\+.*\\+"
			      (mapconcat (lambda (cat) (substring cat 0 1))
					 filter ""))))
	f f1)
    (cond
     ;; Tag filter
     ((eq type 'tag)
      (setq filter
	    (delete-dups
	     (append (assoc-default 'tag org-agenda-filters-preset)
		     filter)))
      (dolist (x filter)
	(let ((op (string-to-char x)))
	  (if expand (setq x (org-agenda-filter-expand-tags (list x) t))
	    (setq x (list x)))
	  (setq f1 (org-agenda-filter-make-matcher-tag-exp x op))
	  (push f1 f))))
     ;; Category filter
     ((eq type 'category)
      (setq filter
	    (delete-dups
	     (append (assoc-default 'category org-agenda-filters-preset)
		     filter)))
      (dolist (x filter)
	(if (equal "-" (substring x 0 1))
	    (setq f1 (list 'not (list 'equal (substring x 1) 'cat)))
	  (setq f1 (list 'equal (substring x 1) 'cat)))
	(push f1 f)))
     ;; Regexp filter
     ((eq type 'regexp)
      (setq filter
	    (delete-dups
	     (append (assoc-default 'regexp org-agenda-filters-preset)
		     filter)))
      (dolist (x filter)
	(if (equal "-" (substring x 0 1))
	    (setq f1 (list 'not (list 'string-match (substring x 1) 'txt)))
	  (setq f1 (list 'string-match (substring x 1) 'txt)))
	(push f1 f)))
     ;; Effort filter
     ((eq type 'effort)
      (setq filter
	    (delete-dups
	     (append (assoc-default 'effort org-agenda-filters-preset)
		     filter)))
      (dolist (x filter)
	(push (org-agenda-filter-effort-form x) f))))
    (cons (if multi-pos-cats 'or 'and) (nreverse f))))