mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-30 02:10:03 +00:00
Lay the groundwork for new filter interface
* lisp/org-agenda.el (org-agenda-get-represented-categories): New function. (org-agenda-get-represented-tags): Added a caching mechanism. * (org-agenda-all-categories): Removed again, deferring to `org-agenda-get-represented-categories'. * lisp/org-agenda.el (org-agenda-represented-categories) (org-agenda-represented-tags): New variables. (org-agenda-finalize): Remove the caches for represented tags and categories.
This commit is contained in:
parent
fa792e9231
commit
36dc6ae644
|
@ -3636,6 +3636,10 @@ removed from the entry content. Currently only `planning' is allowed here."
|
||||||
(defvar org-agenda-regexp-filter nil)
|
(defvar org-agenda-regexp-filter nil)
|
||||||
(defvar org-agenda-effort-filter nil)
|
(defvar org-agenda-effort-filter nil)
|
||||||
(defvar org-agenda-top-headline-filter nil)
|
(defvar org-agenda-top-headline-filter nil)
|
||||||
|
(defvar org-agenda-represented-categories nil
|
||||||
|
"Cache for the list of all categories in the agenda.")
|
||||||
|
(defvar org-agenda-represented-tags nil
|
||||||
|
"Cache for the list of all categories in the agenda.")
|
||||||
(defvar org-agenda-tag-filter-preset nil
|
(defvar org-agenda-tag-filter-preset nil
|
||||||
"A preset of the tags filter used for secondary agenda filtering.
|
"A preset of the tags filter used for secondary agenda filtering.
|
||||||
This must be a list of strings, each string must be a single tag preceded
|
This must be a list of strings, each string must be a single tag preceded
|
||||||
|
@ -3844,6 +3848,8 @@ FILTER-ALIST is an alist of filters we need to apply when
|
||||||
(org-with-point-at mrk
|
(org-with-point-at mrk
|
||||||
(mapcar #'downcase (org-get-tags)))))))))
|
(mapcar #'downcase (org-get-tags)))))))))
|
||||||
(run-hooks 'org-agenda-finalize-hook)
|
(run-hooks 'org-agenda-finalize-hook)
|
||||||
|
(setq org-agenda-represented-tags nil
|
||||||
|
org-agenda-represented-categories nil)
|
||||||
(when org-agenda-top-headline-filter
|
(when org-agenda-top-headline-filter
|
||||||
(org-agenda-filter-top-headline-apply
|
(org-agenda-filter-top-headline-apply
|
||||||
org-agenda-top-headline-filter))
|
org-agenda-top-headline-filter))
|
||||||
|
@ -7439,14 +7445,6 @@ With a prefix argument, do so in all agenda buffers."
|
||||||
"Return the category of the agenda line."
|
"Return the category of the agenda line."
|
||||||
(org-get-at-bol 'org-category))
|
(org-get-at-bol 'org-category))
|
||||||
|
|
||||||
(defun org-agenda-all-categories ()
|
|
||||||
"Return a list of all categories used in this agenda buffer."
|
|
||||||
(let ((pos (point-min)) categories)
|
|
||||||
(while (and (< pos (point-max))
|
|
||||||
(setq pos (next-single-property-change
|
|
||||||
pos 'org-category nil (point-max))))
|
|
||||||
(push (get-text-property pos 'org-category) categories))
|
|
||||||
(nreverse (org-uniquify (delq nil categories)))))
|
|
||||||
|
|
||||||
(defun org-agenda-filter-by-category (strip)
|
(defun org-agenda-filter-by-category (strip)
|
||||||
"Filter lines in the agenda buffer that have a specific category.
|
"Filter lines in the agenda buffer that have a specific category.
|
||||||
|
@ -7666,17 +7664,32 @@ also press `-' or `+' to switch between filtering and excluding."
|
||||||
(org-agenda-filter-apply org-agenda-tag-filter 'tag expand))
|
(org-agenda-filter-apply org-agenda-tag-filter 'tag expand))
|
||||||
(t (error "Invalid tag selection character %c" char)))))
|
(t (error "Invalid tag selection character %c" char)))))
|
||||||
|
|
||||||
(defun org-agenda-get-represented-tags ()
|
(defun org-agenda-get-represented-categories ()
|
||||||
"Get a list of all tags currently represented in the agenda."
|
"Return a list of all categories used in this agenda buffer."
|
||||||
(let (p tags)
|
(or org-agenda-represented-categories
|
||||||
(save-excursion
|
(when (derived-mode-p 'org-agenda-mode)
|
||||||
(goto-char (point-min))
|
(let ((pos (point-min)) categories)
|
||||||
(while (setq p (next-single-property-change (point) 'tags))
|
(while (and (< pos (point-max))
|
||||||
(goto-char p)
|
(setq pos (next-single-property-change
|
||||||
(mapc (lambda (x) (add-to-list 'tags x))
|
pos 'org-category nil (point-max))))
|
||||||
(get-text-property (point) 'tags))))
|
(push (get-text-property pos 'org-category) categories))
|
||||||
tags))
|
(setq org-agenda-represented-categories
|
||||||
|
(nreverse (org-uniquify (delq nil categories))))))))
|
||||||
|
|
||||||
|
(defun org-agenda-get-represented-tags ()
|
||||||
|
"Return a list of all tags used in this agenda buffer.
|
||||||
|
These will be lower-case, for filtering."
|
||||||
|
(or org-agenda-represented-tags
|
||||||
|
(when (derived-mode-p 'org-agenda-mode)
|
||||||
|
(let ((pos (point-min)) tags-lists tt)
|
||||||
|
(while (and (< pos (point-max))
|
||||||
|
(setq pos (next-single-property-change
|
||||||
|
pos 'tags nil (point-max))))
|
||||||
|
(setq tt (get-text-property pos 'tags))
|
||||||
|
(if tt (push tt tags-lists)))
|
||||||
|
(setq org-agenda-represented-tags
|
||||||
|
(nreverse (org-uniquify
|
||||||
|
(delq nil (apply 'append tags-lists)))))))))
|
||||||
|
|
||||||
(defun org-agenda-filter-make-matcher (filter type &optional expand)
|
(defun org-agenda-filter-make-matcher (filter type &optional expand)
|
||||||
"Create the form that tests a line for agenda filter. Optional
|
"Create the form that tests a line for agenda filter. Optional
|
||||||
|
|
Loading…
Reference in a new issue