From 8c011126b5d79c554f3f42de104e2f46af36b697 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 27 Aug 2019 09:01:58 +0200 Subject: [PATCH] Make pressing `_' twice in agenda remove the effort filter * lisp/org-agenda.el (org-agenda-filter-by-effort): Pressing `_' again will remove the effort filter. This aligns the command with the tags filter. --- lisp/org-agenda.el | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 0b7958116..977260d44 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7537,27 +7537,31 @@ With two prefix arguments, remove the effort filters." (mapcar (lambda (n) (mod n 10)) ;turn 10 into 0 (number-sequence 1 (length efforts))))) (op nil)) - (while (not (memq op '(?< ?> ?=))) - (setq op (read-char-exclusive "Effort operator? (> = or <)"))) + (while (not (memq op '(?< ?> ?= ?_))) + (setq op (read-char-exclusive "Effort operator? (> = or <) or press `_' again to remove filter"))) ;; Select appropriate duration. Ignore non-digit characters. - (let ((prompt - (apply #'format - (concat "Effort %c " - (mapconcat (lambda (s) (concat "[%d]" s)) - efforts - " ")) - op allowed-keys)) - (eff -1)) - (while (not (memq eff allowed-keys)) - (message prompt) - (setq eff (- (read-char-exclusive) 48))) - (setq org-agenda-effort-filter - (list (concat (if strip "-" "+") - (char-to-string op) - ;; Numbering is 1 2 3 ... 9 0, but we want - ;; 0 1 2 ... 8 9. - (nth (mod (1- eff) 10) efforts))))) - (org-agenda-filter-apply org-agenda-effort-filter 'effort))) + (if (eq op ?_) + (progn + (org-agenda-filter-show-all-effort) + (message "Effort filter removed")) + (let ((prompt + (apply #'format + (concat "Effort %c " + (mapconcat (lambda (s) (concat "[%d]" s)) + efforts + " ")) + op allowed-keys)) + (eff -1)) + (while (not (memq eff allowed-keys)) + (message prompt) + (setq eff (- (read-char-exclusive) 48))) + (setq org-agenda-effort-filter + (list (concat (if strip "-" "+") + (char-to-string op) + ;; Numbering is 1 2 3 ... 9 0, but we want + ;; 0 1 2 ... 8 9. + (nth (mod (1- eff) 10) efforts))))) + (org-agenda-filter-apply org-agenda-effort-filter 'effort)))) (t (org-agenda-filter-show-all-effort) (message "Effort filter removed"))))