Fix stacking of summed effort estimations upon agenda refresh

When refreshing the Org agenda without completing redrawing it (i.e, by calling
`org-agenda-filter-by-tag`), effort estimates where added for every refreshing,
causing them to stack up.  We now check whether a summed effort estimate is
already present and remove it before adding it again.

(Maybe one could also just skip the effort recalculation if the a summed effort
estimate is already present, but I am not sure whether this will cause display
inconsistencies when new events are added or old ones are deleted.)
This commit is contained in:
Daniel - 2023-01-11 20:44:19 +01:00
parent 6ed088d2da
commit 28b2047ad6
No known key found for this signature in database
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 11 additions and 0 deletions

View File

@ -218,6 +218,17 @@ Add this function to `org-agenda-finalize-hook' to enable this."
(point) (point-max) 'org-agenda-date-header t))
(goto-char pos)
(end-of-line)
;; When there is already an effort sum shown, delete it first
(when (re-search-backward " ([0-9]+:[0-9]\\{2\\})"
(save-mark-and-excursion
;; Only search until start of line
(beginning-of-line)
(point))
t)
(kill-line))
;; Insert effort sum
(insert-and-inherit
(concat " ("
(db/org-agenda-calculate-efforts