summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2019-08-30 08:35:27 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2019-08-30 08:35:27 +0200
commit713a4147139a5cf7fd543e099c59b0b75f90711f (patch)
tree1ff43e966357a5c914f2b5971655fd352e8ea368
parent3ac2fb6c5fcb14b27119380784ebe4dba074da50 (diff)
downloadorg-mode-713a4147139a5cf7fd543e099c59b0b75f90711f.tar.gz
Small improvements to filtering
* lisp/org-agenda.el (org-agenda-filter): Append new filter elements instead of prepending them. And allow an additional leading `+' to signal that the new elements should be added to the current filter instad of replacing them.
-rw-r--r--doc/org-manual.org5
-rw-r--r--lisp/org-agenda.el17
2 files changed, 15 insertions, 7 deletions
diff --git a/doc/org-manual.org b/doc/org-manual.org
index c64773e..9317844 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -9174,8 +9174,9 @@ custom agenda commands.
(tags will take priority). If you reply to the prompt with the
empty string, all filtering is removed. If a filter is specified,
it replaces all current filters. But if you call the command with a
- prefix argument, the new filter elements are added to the active
- ones.
+ prefix argument, or if you add an additional `+' (e.g. `+-John') to
+ the front of the string, the new filter elements are added to the
+ active ones.
- {{{kbd(^)}}} (~org-agenda-filter-by-top-headline~) ::
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 617c6df..09efef5 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7609,11 +7609,18 @@ and deselects entries with tag `John' or matching the regexp `plot'.
During entry of the filter, completion for tags, categories and effort
values is offered. Since the syntax for categories and tags is identical
there should be no overlap between categoroes and tags. If there is, tags
-get priority."
+get priority.
+
+Instead of using the prefix argument to add to the current filter
+set, you can also add an additional leading `+' to filter string,
+like `+-John'."
(interactive "P")
(let* ((tag-list (org-agenda-get-represented-tags))
(category-list (org-agenda-get-represented-categories))
(f-string (completing-read "Filter [+cat-tag<0:10-/regexp/]: " 'org-agenda-filter-completion-function))
+ (keep (or (if (string-match "^+[-+]" f-string)
+ (progn (setq f-string (substring f-string 1)) t))
+ keep))
(fc (if keep org-agenda-category-filter))
(ft (if keep org-agenda-tag-filter))
(fe (if keep org-agenda-effort-filter))
@@ -7627,16 +7634,16 @@ get priority."
;; category or tag
(setq s (match-string 3 f-string))
(cond ((member s tag-list)
- (push (concat log s) ft))
+ (add-to-list 'ft (concat log s) 'append 'equal))
((member s category-list)
- (push (concat log s) fc))
+ (add-to-list 'fc (concat log s) 'append 'equal))
(t (message "`%s%s' filter ignored because it is not represented as tag or category" log s))))
((match-beginning 4)
;; effort
- (push (concat log (match-string 4 f-string)) fe))
+ (add-to-list 'fe (concat log (match-string 4 f-string)) 'append 'equal))
((match-beginning 5)
;; regexp
- (push (concat log (match-string 6 f-string)) fr)))
+ (add-to-list 'fr (concat log (match-string 6 f-string)) 'append 'equal)))
(setq f-string (substring f-string (match-end 0))))
(org-agenda-filter-remove-all)
(and fc (org-agenda-filter-apply