2

I would like to show sum of efforts for all tasks for a day in Org-Agenda day title. E.g. for a week agenda there would be 7 sums for each of the day, in their respective titles.

I think this could be done somehow by manipulating the org-agenda-format-date variable.

By default, this variable points to a builtin function org-agenda-format-date-aligned, but I suppose it can be reset to point to a custom function to include the sum of efforts in the date line.

Could you please help me define such a function?

Also, I would like to use a predefined Effort value for all tasks lacking the Effort property.

  • Not a direct answer to the question so I'll post as a comment, but a similar effect can be gained from a clocktable, e.g. put a #+BEGIN: clocktable :maxlevel 7 :scope agenda :block thisweek :step day :fileskip0 :formatter :link 2 :indent t :narrow 79 :formula % #+END: then C-c C-x C-u inside that clocktable. You can change "thisweek" to "lastweek", tune the level of detail shown with :maxlevel etc. That has the advantage that it's only updated when you explicitly ask, as pulling out that effort information can be a little slow. – Stuart Hickinbottom Aug 28 at 6:54
2

So far as I know, this is not possible. You can get an effort sum using column view, though only for one day at a time. Set column format as follows:

(setq org-columns-default-format "%60ITEM(Task) %6Effort(Estim){:}")

Then, when in agenda view, restrict your view to a single day using 'd' and then turn on column view (C-c C-x C-c).

That will get you what you want. Though there seems to be a bug such that this will not work properly if you use more than one agenda file.

0

You can accomplish this by defining a function such as my/org-agenda-insert-efforts that inserts the sum of the efforts next to the heading for a particular day after the agenda has been generated. The function only considers scheduled items for a particular day:

(require 'cl-lib)

(defun my/org-agenda-calculate-efforts (limit)
  "Sum the 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 my/org-agenda-insert-efforts ()
  "Insert the efforts for each day inside the agenda buffer."
  (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 " ("
                                   (my/org-agenda-calculate-efforts
                                    (next-single-property-change (point) 'day))
                                   ")"))
       (forward-line)))))

The function can then be added to org-agenda-finalize-hook so that the text is automatically inserted after the agenda has been generated:

(add-hook 'org-agenda-finalize-hook 'my/org-agenda-insert-efforts)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.