I grabbed code from org effectiveness as shown below:
(defun org-effectiveness-count-todo() ;;org-effectiveness-count-todo
"Print a message with the number of todo tasks in the current buffer"
(interactive)
(save-excursion
(goto-char (point-min))
(message "Number of TODO: %d" (count-matches "TODO"))))
When I put org-effectiveness-count-todo in any buffer, it shows TODO count correctly. When I put this code in agenda header, it shows only zero.
(org-agenda-overriding-header (org-effectiveness-count-todo) ...
]2
(defun my-function () "Doc-string." (interactive) (let (result) (save-excursion (goto-char (point-min)) (setq result (count-matches "TODO"))) (message "Number of TODO: %d" result) result))
As mentioned above, I do not know if that was your own problem, but it was definitely one of them. – lawlist May 10 '18 at 22:25org-agenda-overriding-header
value and do your calculations before that point in time. It may be helpful to also look for when the functionorg-agenda-format-item
is called because that is one of the last places data is modified before the buffer is populated; e.g., map through data near it. – lawlist May 10 '18 at 22:42