소스 검색

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.
Carsten Dominik 6 년 전
부모
커밋
713a414713
2개의 변경된 파일15개의 추가작업 그리고 7개의 파일을 삭제
  1. 3 2
      doc/org-manual.org
  2. 12 5
      lisp/org-agenda.el

+ 3 - 2
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~) ::
 

+ 12 - 5
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