diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2019-09-06 15:41:39 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2019-09-06 15:48:44 +0200 |
commit | c580a290acb0525f172c9c5d1c4d0e5b18e59baf (patch) | |
tree | 99e7e4db0f636acc51001d1a6a25b64f76b70a4d | |
parent | 124017b6d3c35d8197d10d7b4521368c4c2b17e7 (diff) | |
download | org-mode-c580a290acb0525f172c9c5d1c4d0e5b18e59baf.tar.gz |
Normalize the use of `C-u' for `org-agenda-filter-by-effort'
-rw-r--r-- | lisp/org-agenda.el | 88 |
1 files changed, 46 insertions, 42 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 0ba42d4..2aa3345 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7533,49 +7533,53 @@ two prefix arguments." (defvar org-agenda-effort-filter nil) (defun org-agenda-filter-by-effort (strip) "Filter agenda entries by effort. -With no prefix argument, keep entries matching the effort condition. -With one prefix argument, filter out entries matching the condition. -With two prefix arguments, remove the effort filters." +With no `\\[universal-argument]' prefix argument, keep entries matching the effort condition. +With one `\\[universal-argument]' prefix argument, filter out entries matching the condition. +With two `\\[universal-argument]' prefix arguments, add a second condition to the existing filter. +This last option is in practice not very useful, but it is available for +consistency with the other filter commands." (interactive "P") - (cond - ((member strip '(nil 4)) - (let* ((efforts (split-string - (or (cdr (assoc (concat org-effort-property "_ALL") - org-global-properties)) - "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00"))) - ;; XXX: the following handles only up to 10 different - ;; effort values. - (allowed-keys (if (null efforts) nil - (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 <) or press `_' again to remove filter"))) - ;; Select appropriate duration. Ignore non-digit characters. - (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")))) + (let* ((efforts (split-string + (or (cdr (assoc (concat org-effort-property "_ALL") + org-global-properties)) + "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00"))) + ;; XXX: the following handles only up to 10 different + ;; effort values. + (allowed-keys (if (null efforts) nil + (mapcar (lambda (n) (mod n 10)) ;turn 10 into 0 + (number-sequence 1 (length efforts))))) + (keep (equal strip '(16))) + (current org-agenda-effort-filter) + (op nil)) + (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. + (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))) + (org-agenda-filter-show-all-effort) + (setq org-agenda-effort-filter + (append + (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))) + (if keep current nil))) + (org-agenda-filter-apply org-agenda-effort-filter 'effort))))) (defun org-agenda-filter (&optional strip) |