Browse Source

org-agenda.el: Update the logic of regexp filters

* lisp/org-agenda.el (org-agenda-filter-by-regexp): Remove
existing regexp filter.  Only cumulate filters when called
with two prefix arguments.

It seems more common and reasonable to hit "=" to filter
then hit "=" again to remove the filter.  Cumulative filters
are still accessible through hitting `C-u C-u ='.
Bastien 6 years ago
parent
commit
2b6004f57e
2 changed files with 13 additions and 11 deletions
  1. 3 2
      doc/org-manual.org
  2. 10 9
      lisp/org-agenda.el

+ 3 - 2
doc/org-manual.org

@@ -9222,8 +9222,9 @@ custom agenda commands.
      Filter the agenda view by a regular expression: only show agenda
      entries matching the regular expression the user entered.  When
      called with a prefix argument, it filters /out/ entries matching
-     the regexp.  With two universal prefix arguments, it removes all
-     the regexp filters, which can be accumulated.
+     the regexp.  Called in a regexp-filtered agenda view, remove the
+     filter, unless there are two universal prefix arguments, in which
+     case filters are cumulated.
 
      #+vindex: org-agenda-regexp-filter-preset
      You can add a filter preset in custom agenda commands through the

+ 10 - 9
lisp/org-agenda.el

@@ -7433,22 +7433,23 @@ The top headline is that of the current line."
 
 (defvar org-agenda-regexp-filter nil)
 (defun org-agenda-filter-by-regexp (strip)
-  "Filter agenda entries by a regular expression.
-Regexp filters are cumulative.
-With no prefix argument, keep entries matching the regexp.
+  "Filter agenda entries by regular expressions.
+
 With one prefix argument, filter out entries matching the regexp.
-With two prefix arguments, remove the regexp filters."
+If there is already a regexp filter, remove it unless called with
+two prefix arguments."
   (interactive "P")
-  (if (not (equal strip '(16)))
-      (let ((flt (concat (if (equal strip '(4)) "-" "+")
+  (cond
+   ((and org-agenda-regexp-filter (not (equal strip '(16))))
+    (org-agenda-filter-show-all-re)
+    (message "Regexp filter removed"))
+   (t (let ((flt (concat (if (equal strip '(4)) "-" "+")
 			 (read-from-minibuffer
 			  (if (equal strip '(4))
 			      "Filter out entries matching regexp: "
 			    "Narrow to entries matching regexp: ")))))
 	(push flt org-agenda-regexp-filter)
-	(org-agenda-filter-apply org-agenda-regexp-filter 'regexp))
-    (org-agenda-filter-show-all-re)
-    (message "Regexp filter removed")))
+	(org-agenda-filter-apply org-agenda-regexp-filter 'regexp)))))
 
 (defvar org-agenda-effort-filter nil)
 (defun org-agenda-filter-by-effort (strip)