Normalize the use of `C-u' for `org-agenda-filter-by-effort'
This commit is contained in:
parent
124017b6d3
commit
c580a290ac
|
@ -7533,49 +7533,53 @@ two prefix arguments."
|
||||||
(defvar org-agenda-effort-filter nil)
|
(defvar org-agenda-effort-filter nil)
|
||||||
(defun org-agenda-filter-by-effort (strip)
|
(defun org-agenda-filter-by-effort (strip)
|
||||||
"Filter agenda entries by effort.
|
"Filter agenda entries by effort.
|
||||||
With no prefix argument, keep entries matching the effort condition.
|
With no `\\[universal-argument]' prefix argument, keep entries matching the effort condition.
|
||||||
With one prefix argument, filter out entries matching the condition.
|
With one `\\[universal-argument]' prefix argument, filter out entries matching the condition.
|
||||||
With two prefix arguments, remove the effort filters."
|
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")
|
(interactive "P")
|
||||||
(cond
|
(let* ((efforts (split-string
|
||||||
((member strip '(nil 4))
|
(or (cdr (assoc (concat org-effort-property "_ALL")
|
||||||
(let* ((efforts (split-string
|
org-global-properties))
|
||||||
(or (cdr (assoc (concat org-effort-property "_ALL")
|
"0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")))
|
||||||
org-global-properties))
|
;; XXX: the following handles only up to 10 different
|
||||||
"0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")))
|
;; effort values.
|
||||||
;; XXX: the following handles only up to 10 different
|
(allowed-keys (if (null efforts) nil
|
||||||
;; effort values.
|
(mapcar (lambda (n) (mod n 10)) ;turn 10 into 0
|
||||||
(allowed-keys (if (null efforts) nil
|
(number-sequence 1 (length efforts)))))
|
||||||
(mapcar (lambda (n) (mod n 10)) ;turn 10 into 0
|
(keep (equal strip '(16)))
|
||||||
(number-sequence 1 (length efforts)))))
|
(current org-agenda-effort-filter)
|
||||||
(op nil))
|
(op nil))
|
||||||
(while (not (memq op '(?< ?> ?= ?_)))
|
(while (not (memq op '(?< ?> ?= ?_)))
|
||||||
(setq op (read-char-exclusive "Effort operator? (> = or <) or press `_' again to remove filter")))
|
(setq op (read-char-exclusive
|
||||||
;; Select appropriate duration. Ignore non-digit characters.
|
"Effort operator? (> = or <) or press `_' again to remove filter")))
|
||||||
(if (eq op ?_)
|
;; Select appropriate duration. Ignore non-digit characters.
|
||||||
(progn
|
(if (eq op ?_)
|
||||||
(org-agenda-filter-show-all-effort)
|
(progn
|
||||||
(message "Effort filter removed"))
|
(org-agenda-filter-show-all-effort)
|
||||||
(let ((prompt
|
(message "Effort filter removed"))
|
||||||
(apply #'format
|
(let ((prompt
|
||||||
(concat "Effort %c "
|
(apply #'format
|
||||||
(mapconcat (lambda (s) (concat "[%d]" s))
|
(concat "Effort %c "
|
||||||
efforts
|
(mapconcat (lambda (s) (concat "[%d]" s))
|
||||||
" "))
|
efforts
|
||||||
op allowed-keys))
|
" "))
|
||||||
(eff -1))
|
op allowed-keys))
|
||||||
(while (not (memq eff allowed-keys))
|
(eff -1))
|
||||||
(message prompt)
|
(while (not (memq eff allowed-keys))
|
||||||
(setq eff (- (read-char-exclusive) 48)))
|
(message prompt)
|
||||||
(setq org-agenda-effort-filter
|
(setq eff (- (read-char-exclusive) 48)))
|
||||||
(list (concat (if strip "-" "+")
|
(org-agenda-filter-show-all-effort)
|
||||||
(char-to-string op)
|
(setq org-agenda-effort-filter
|
||||||
;; Numbering is 1 2 3 ... 9 0, but we want
|
(append
|
||||||
;; 0 1 2 ... 8 9.
|
(list (concat (if strip "-" "+")
|
||||||
(nth (mod (1- eff) 10) efforts)))))
|
(char-to-string op)
|
||||||
(org-agenda-filter-apply org-agenda-effort-filter 'effort))))
|
;; Numbering is 1 2 3 ... 9 0, but we want
|
||||||
(t (org-agenda-filter-show-all-effort)
|
;; 0 1 2 ... 8 9.
|
||||||
(message "Effort filter removed"))))
|
(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)
|
(defun org-agenda-filter (&optional strip)
|
||||||
|
|
Loading…
Reference in New Issue