Function: org-agenda-filter-completion-function

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

Signature

(org-agenda-filter-completion-function STRING PREDICATE &optional FLAG)

Documentation

Complete a complex filter string.

FLAG specifies the type of completion operation to perform. This function is passed as a collection function to completing-read, which see.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-filter-completion-function (string _predicate &optional flag)
  "Complete a complex filter string.
FLAG specifies the type of completion operation to perform.  This
function is passed as a collection function to `completing-read',
which see."
  (let ((completion-ignore-case t)	;tags are case-sensitive
        (confirm #'stringp)
	(prefix "")
	(operator "")
	table
        begin)
    (when (string-match "^\\(.*\\([-+<>=]\\)\\)\\([^-+<>=]*\\)$" string)
      (setq prefix (match-string 1 string)
	    operator (match-string 2 string)
            begin (match-beginning 3)
	    string (match-string 3 string)))
    (cond
     ((member operator '("+" "-" "" nil))
      (setq table (append (org-agenda-get-represented-categories)
			  (org-agenda-get-represented-tags))))
     ((member operator '("<" ">" "="))
      (setq table (split-string
		   (or (cdr (assoc-string (concat org-effort-property "_ALL")
					  org-global-properties
					  t))
		       "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")
		   " +")))
     (t (setq table nil)))
    (pcase flag
      (`t (all-completions string table confirm))
      (`lambda (assoc string table)) ;exact match?
      (`(boundaries . ,suffix)
       (let ((end (if (string-match "[-+<>=]" suffix)
                      (match-string 0 suffix)
                    (length suffix))))
         `(boundaries ,(or begin 0) . ,end)))
      (`nil
       (pcase (try-completion string table confirm)
	 ((and completion (pred stringp))
	  (concat prefix completion))
	 (completion completion)))
      (_ nil))))