Is there any way to enable clockreport-mode in a TODO-agenda view? I mainly use this view because I don't really set dates for my tasks so the agenda-view is not really helpful for me (I'm using spacemacs by the way).
Anyway the clockreport-mode only works in 'agenda' - Agenda-Buffers. Otherwise it will throw an error Not allowed in todo-type agenda buffers
.
The function in org-agenda.el
is defined like this:
(defun org-agenda-clockreport-mode ()
"Toggle clocktable mode in an agenda buffer."
(interactive)
(org-agenda-check-type t 'agenda)
(setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode))
(org-agenda-set-mode-name)
(org-agenda-redo)
(message "Clocktable mode is %s"
(if org-agenda-clockreport-mode "on" "off")))
And I think this is where the clocktable gets inserted in defun-org-agenda-list
(when (and org-agenda-clockreport-mode clocktable-start)
(let ((org-agenda-files (org-agenda-files nil 'ifmode))
;; the above line is to ensure the restricted range!
(p (copy-sequence org-agenda-clockreport-parameter-plist))
tbl)
(setq p (org-plist-delete p :block))
(setq p (plist-put p :tstart clocktable-start))
(setq p (plist-put p :tend clocktable-end))
(setq p (plist-put p :scope 'agenda))
(setq tbl (apply 'org-clock-get-clocktable p))
(insert tbl)))
But as im still an Elisp novice I don't really know what I can do to enable and display a clocktable in a todo-agenda Buffer.
Edit:
Thanks to Tobias answer I found a way to work around the problem so that it fits my use case. This avoids using org-agenda-clockreport-mode
, so I guess it doesn't really answer the question but it's good enough for me right now.
I took the clocktable code from org-agenda.el
and modified it slightly to turn it into my own function that can insert a clocktable.
(defun own-clock-report ()
"function to insert clocktable"
(goto-char (point-max))
(let ((org-agenda-files (org-agenda-files nil 'ifmode))
;; the above line is to ensure the restricted range!
(p (copy-sequence org-agenda-clockreport-parameter-plist))
tbl)
(setq p (org-plist-delete p :block))
(setq p (plist-put p :tstart "<today>"))
(setq p (plist-put p :tend "<now>"))
(setq p (plist-put p :scope 'agenda))
(setq tbl (apply 'org-clock-get-clocktable p))
(open-line 1)
(insert tbl)))
Then I used a hook to add it to my agenda view:
(add-hook 'org-agenda-finalize-hook #'own-clock-report)
Using org-agenda-mode-hook
seems to work as well, if you like the clockreport on top of the agenda.
The only drawback this method has is, that every time I change the Todo-state of an item or clock in/out of it, a clocktable appears below the item and I have to rebuild the agenda buffer to make it disappear.
org-agenda
.org-agenda-clockreport-mode
in todo-agenda buffers though.org-agenda-finalize-hook
?