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 16:32:42 +0000 [thread overview]
Message-ID: <44e81542-882d-4c36-adcd-69ca90b23f48@www.fastmail.com> (raw)
In-Reply-To: <87mtwqziuj.fsf@aquinas>
On Sat, 30 Jan 2021, at 12:53, Richard Lawrence wrote:
> #+begin_src emacs-lisp
> (defun org-update-clocktable-on-date (date)
> (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)))
> #+end_src
This is wonderful Richard, and a great help to me. I had no idea of the org-datree-find-date-create, and the argument to org-clock-report cuts out a lot of my code.
> Note that org-datetree-find-date has a slightly annoying interface, in
> that you need to provide a list of three integers representing a
> calendar date.
Yes, that is a little awkward. What I did think of using was substrings to extract the date from the picker interface.
#+BEGIN_SRC emacs-lisp
(defun org-date-picker-to-list ()
(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))))
#+END_SRC
Does that look sensible?
My two next things to tackle are
1. A hook to run the function when I run org-capture.
2. Changing the org-clock-report options in your function above, but not the defaults.
For the second point, is there some trick to swap a global variable for the run of a function? The variable in this case would be org-clocktable-defaults.
Thank you so much Richard. You've probably saved me days of going through the org-mode documentation and source.
next prev parent reply other threads:[~2021-01-30 16:34 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 [this message]
2021-01-30 17:09 ` Richard Lawrence
2021-01-30 22:40 ` Christopher Causer
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=44e81542-882d-4c36-adcd-69ca90b23f48@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).