diff options
author | Bastien <bzg@gnu.org> | 2018-04-28 14:12:37 +0200 |
---|---|---|
committer | Bastien <bzg@gnu.org> | 2018-04-28 14:12:37 +0200 |
commit | 2b6004f57ed98cef76ffba133575763f2da93bc9 (patch) | |
tree | 1967c59b50a7b90f257dca0c8583e3046a98599b | |
parent | 2debcd5b2287063ee3fb5d4d7ccf96d1f85465db (diff) | |
download | org-mode-2b6004f57ed98cef76ffba133575763f2da93bc9.tar.gz |
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 ='.
-rw-r--r-- | doc/org-manual.org | 5 | ||||
-rw-r--r-- | lisp/org-agenda.el | 19 |
2 files changed, 13 insertions, 11 deletions
diff --git a/doc/org-manual.org b/doc/org-manual.org index 4095ff9..5354208 100644 --- a/doc/org-manual.org +++ b/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 diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f48d6de..342ea06 100644 --- a/lisp/org-agenda.el +++ b/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) |