Dear all,
here is a patch implementing category filtering in the agenda.
The patch is not 100% clean wrt documentation, but I throw it
now to get some feedback and some testing done.
Press in the agenda to filter by category.
Press to filter by the category of the entry point.
Another / / removes the filter. / + filters by the
default category (General) since everything is in a category.
I find this last function quick and useful, so I also implemented
it for tag filtering: pressing / / filters by tags from the entry
on the current line. A second / / removes the filter.
Let me know if the category filtering works ok with you, and
if you find the new / / behavior useful.
There is one limitation for now: it does not combine with Effort
filtering.
Thanks,
From 948a38b403125359b59c5f5d520be6d053599b0d Mon Sep 17 00:00:00 2001
From: Bastien Guerry b...@altern.org
Date: Sun, 6 Nov 2011 19:26:28 +0100
Subject: [PATCH] Implement agenda filtering by category.
---
doc/org.texi |6 +-
lisp/org-agenda.el | 234
lisp/org-faces.el |6 ++
3 files changed, 189 insertions(+), 57 deletions(-)
diff --git a/doc/org.texi b/doc/org.texi
index 4a547d0..af189f0 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7954,10 +7954,10 @@ the entire agenda view---in a block agenda, you should only set this in the
global options section, not in the section of an individual block.}
You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
-all. Pressing @key{TAB} at that prompt will offer use completion to select a
-tag (including any tags that do not have a selection character). The command
+all. Pressing @key{TAB} at that prompt will use completion to select a
+tag (also including tags that do not have a selection character). The command
then hides all entries that do not contain or inherit this tag. When called
-with prefix arg, remove the entries that @emph{do} have the tag. A second
+with a prefix arguement, remove the entries that @emph{do} have the tag. A second
@kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
will be narrowed by requiring or forbidding the selected additional tag.
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index bcc2de4..83c42f0 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -286,8 +286,14 @@ you can \misuse\ it to also add other text to the header. However,
(list :tag Deadline Warning days
(const org-deadline-warning-days)
(integer :value 1))
+ (list :tag Category filter preset
+ (const org-agenda-category-filter-preset)
+ (list
+ (const :format quote)
+ (repeat
+ (string :tag +category or -category
(list :tag Tags filter preset
- (const org-agenda-filter-preset)
+ (const org-agenda-tag-filter-preset)
(list
(const :format quote)
(repeat
@@ -1949,6 +1955,7 @@ The following commands are available:
(org-defkey org-agenda-mode-map } 'org-agenda-manipulate-query-subtract-re)
(org-defkey org-agenda-mode-map / 'org-agenda-filter-by-tag)
(org-defkey org-agenda-mode-map \\ 'org-agenda-filter-by-tag-refine)
+(org-defkey org-agenda-mode-map 'org-agenda-filter-by-category)
(org-defkey org-agenda-mode-map ; 'org-timer-set-timer)
(define-key org-agenda-mode-map ? 'org-agenda-show-the-flagging-note)
(org-defkey org-agenda-mode-map \C-c\C-x\C-mg'org-mobile-pull)
@@ -3043,9 +3050,9 @@ removed from the entry content. Currently only `planning' is allowed here.
(defvar org-pre-agenda-window-conf nil)
(defvar org-agenda-columns-active nil)
(defvar org-agenda-name nil)
-(defvar org-agenda-filter nil)
-(defvar org-agenda-filter-while-redo nil)
-(defvar org-agenda-filter-preset nil
+(defvar org-agenda-tag-filter nil)
+(defvar org-agenda-tag-filter-while-redo nil)
+(defvar org-agenda-tag-filter-preset nil
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
by \+\ or \-\.
@@ -3055,13 +3062,21 @@ the entire agenda view. In a block agenda, it will not work reliably to
define a filter for one of the individual blocks. You need to set it in
the global options and expect it to be applied to the entire view.)
+(defvar org-agenda-category-filter-preset nil
+ A preset of the categeory filter used for secondary agenda filtering.
+This must be a list of strings, each string must be a single category
+preceded by \+\ or \-\. See `org-agenda-tag-filter-preset' for
+details.)
+
(defun org-prepare-agenda (optional name)
(setq org-todo-keywords-for-agenda nil)
(setq org-done-keywords-for-agenda nil)
(setq org-drawers-for-agenda nil)
(unless org-agenda-persistent-filter
-(setq org-agenda-filter nil))
- (put 'org-agenda-filter :preset-filter org-agenda-filter-preset)
+(setq