Show sum of daily efforts directly in the agenda

Now that column view does not show effort sums any longer, we need another means
to show daily efforts.  It turns out that this can be accomplished easily using
two simple functions and `org-agenda-finalize-hook`.

This is taken from
https://emacs.stackexchange.com/questions/21380/show-sum-of-efforts-for-a-day-in-org-agenda-day-title#21902.
This commit is contained in:
Daniel - 2021-01-29 17:11:55 +01:00
parent ac31d0eb89
commit 9cf17c973f
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
2 changed files with 38 additions and 0 deletions

View File

@ -720,6 +720,7 @@
db/org-agenda-list-deadlines
db/org-agenda-skip-tag
hydra-org-agenda-view/body
db/org-agenda-insert-efforts
org-babel-execute:hy
db/org-timestamp-difference
db/org-capture-code-snippet
@ -1013,6 +1014,9 @@
org-agenda-search-headline-for-time nil
org-agenda-search-view-always-boolean t
;; Show daily efforts directly in the agenda
org-agenda-finalize-hook '(db/org-agenda-insert-efforts)
org-agenda-clock-consistency-checks
'(:max-duration 9999999
:min-duration 0

View File

@ -181,6 +181,40 @@ _y_: ?y? year _q_: quit _L__l__c_: ?l?
(org-agenda-redo)))
("q" (message "Abort") :exit t))
;; Show sum of daily efforts in agenda, the following two functions are from
;; anpandey,
;; cf. https://emacs.stackexchange.com/questions/21380/show-sum-of-efforts-for-a-day-in-org-agenda-day-title#21902
(defun db/org-agenda-calculate-efforts (limit)
"Sum efforts of scheduled entries up to LIMIT in the agenda buffer."
(let (total)
(save-excursion
(while (< (point) limit)
(when (member (org-get-at-bol 'type) '("scheduled" "past-scheduled"))
(push (org-entry-get (org-get-at-bol 'org-hd-marker) "Effort") total))
(forward-line)))
(org-duration-from-minutes
(cl-reduce #'+
(mapcar #'org-duration-to-minutes
(cl-remove-if-not 'identity total))))))
(defun db/org-agenda-insert-efforts ()
"Insert efforts for each day into the agenda buffer.
Add this function to `org-agenda-finalize-hook'."
(save-excursion
(let (pos)
(while (setq pos (text-property-any
(point) (point-max) 'org-agenda-date-header t))
(goto-char pos)
(end-of-line)
(insert-and-inherit
(concat " ("
(db/org-agenda-calculate-efforts
(next-single-property-change (point) 'day))
")"))
(forward-line)))))
;;; Capturing