From: "Christopher Causer" <ml-emacs-orgmode@chyc.co.uk>
To: orgmode <emacs-orgmode@gnu.org>
Subject: Re: clock-table and hooking that into org-capture file+olp+datetree
Date: Sat, 30 Jan 2021 22:40:22 +0000 [thread overview]
Message-ID: <1a9a61b4-a5f9-471b-80e5-1c52902b392d@www.fastmail.com> (raw)
In-Reply-To: <87im7ez6zz.fsf@aquinas>
Thanks again Richard. I now have a working solution which I share below, warts and all.
One snag I hit that I feel I should mention is what I believe to be a mistake in the documentation[1]. I was scratching my head as why org-clocktable-defaults wasn't working, but it was only when I brought up the inline documentation that I see that this probably is some vestigial variableand it has since moved to org-clock-clocktable-default-properties. Is mentioning this here on the list enough or should I report it somewhere else?
Christopher
#+BEGIN_SRC emacs-lisp
(defun org-date-to-list ()
"Run `org-read-date' and return it in the form '(mm dd YYYY).
This form is more useful for functions that require it in
this format, such as `org-datetree-find-date-create'."
(let* ((date-string (org-read-date))
(year (substring date-string 0 4))
(month (substring date-string 5 7))
(day (substring date-string 8 10)))
(mapcar 'string-to-number (list month day year))))
(defun org-update-clocktable-on-date (date)
(let* ((year (number-to-string (nth 2 date)))
(month (number-to-string (nth 0 date)))
(day (number-to-string (nth 1 date)))
(org-clock-clocktable-default-properties
(list :scope 'agenda :maxlevel 6 :block (concat year "-" month "-" day))))
(save-excursion
;; open the file containing the datetree:
(find-file (concat org-directory "/diary.org"))
;; jump to the subtree for the given date:
;; note: date must look like (m d y) where all three values are integers
(org-datetree-find-date-create date)
;; narrow to the subtree for this date, so we don't update
;; any other clocktables
(org-narrow-to-subtree)
;; update the clock report, or create it if it doesn't exist
;; note: we pass a prefix argument to tell org-clock-report to
;; update the first clocktable it finds in the (narrowed) buffer
(org-clock-report t)
;; widen to the whole buffer again
(widen))))
;; Usage
; (org-update-clocktable-on-date (org-date-to-list))
#+END_SRC
[1] Variable org-clocktable-defaults is mentioned here https://orgmode.org/manual/The-clock-table.html
next prev parent reply other threads:[~2021-01-30 22:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 22:32 clock-table and hooking that into org-capture file+olp+datetree Christopher Causer
2021-01-30 8:40 ` Christopher Causer
2021-01-30 12:53 ` Richard Lawrence
2021-01-30 16:32 ` Christopher Causer
2021-01-30 17:09 ` Richard Lawrence
2021-01-30 22:40 ` Christopher Causer [this message]
2021-02-02 5:15 ` Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a9a61b4-a5f9-471b-80e5-1c52902b392d@www.fastmail.com \
--to=ml-emacs-orgmode@chyc.co.uk \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).