From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id +LXqJSAgFmAZYgAA0tVLHw (envelope-from ) for ; Sun, 31 Jan 2021 03:12:32 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id iBuGISAgFmCzLQAAbx9fmQ (envelope-from ) for ; Sun, 31 Jan 2021 03:12:32 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8C04D9403D6 for ; Sun, 31 Jan 2021 03:12:30 +0000 (UTC) Received: from localhost ([::1]:44858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l63A5-0007Tq-Hn for larch@yhetil.org; Sat, 30 Jan 2021 22:12:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5cL0-0002iJ-46 for emacs-orgmode@gnu.org; Fri, 29 Jan 2021 17:33:58 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:34065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5cKw-0003Cu-F4 for emacs-orgmode@gnu.org; Fri, 29 Jan 2021 17:33:57 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id AFDB8BC0 for ; Fri, 29 Jan 2021 17:33:50 -0500 (EST) Received: from imap34 ([10.202.2.84]) by compute7.internal (MEProxy); Fri, 29 Jan 2021 17:33:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h= mime-version:message-id:date:from:to:subject:content-type; s= fm2; bh=7uckQ7QySmGv2rY5Q1D+szFO8RGtNLHaBJuU9sSzPBs=; b=t2VxxDB0 fqsQSQEvNIpjxxqgJAV+431cAVSCgJYur466Lca/mBqFg+IuO7SQVA24lD4M3pKV JHT0ngkArfQaoMMbK6+2TbzpFvbDErfpq84y/xRRVra1d7Wr3YJs/2A7x+3xFFFJ pLHkxmsco0YSAIbQvea8QZWo++2XFQEB9IT5Qbl7CvQNm/VKTvIIrpi9OlmSdj8/ hZyu6ZGRPqfufeBVw/DnXHiEN0109kX178L3dvk+D/cCjTkmwKkzI5wscWydCqK6 fLp2ObXZ7+CwSqniJsXRjS7/oKLQ9EIyDGaO5+Q4vtO6FGGXfR+iMtBu00DR+xeU WClVgTtmNhlZ1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=7uckQ7QySmGv2rY5Q1D+szFO8RGtN LHaBJuU9sSzPBs=; b=l6TiDelRr4avIbB2hwH7/ZG7zW+GQ66lTNXufAzm1112u /U+52IsKUGC1MCI4sx5iCNS57RZUrQrYjB/TX6chlmrNJtf1QBbH5hyHszs7yr+x B2cdjqg4aSToOc/rRPEj5e3g6yzXv1O3ebzXjw/sZDlRAhxuwOwG+nPCFNy2uY17 lPs3zogW/SSuisqFc7we54vuaj7EgzXA/oS9aNiPXYXoSGyfY/OJtUK1G+69AGU2 n2TxTAi8Px5d5VVPuCzw1f1Fj6EBIL8QWxnMHakykR+bg4NIKRVoDjKLVqW2QHAJ 1mBmS909+0Exr/dDJZJpmcUGydBRcvPmr6E+7SRcw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedvgdduieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsehttdertd erredtnecuhfhrohhmpedfvehhrhhishhtohhphhgvrhcuvegruhhsvghrfdcuoehmlhdq vghmrggtshdqohhrghhmohguvggthhihtgdrtghordhukhestghhhigtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeffgeffiedvtefgveduudejgfetfffgvdefkeeifeehudeu hfegtdekfeekffeiffenucffohhmrghinhepughirghrhidrohhrghdpohhrghhmohguvg drohhrghdpmhgrnhejrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepmhhlqdgvmhgrtghsqdhorhhgmhhouggvtghhhigtrdgtohdruh hksegthhihtgdrtghordhukh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 42F96280066; Fri, 29 Jan 2021 17:33:48 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-84-gfc141fe8b8-fm-20210125.001-gfc141fe8 Mime-Version: 1.0 Message-Id: <79daebf0-5bda-473a-b289-392fd0c8df18@www.fastmail.com> Date: Fri, 29 Jan 2021 22:32:33 +0000 From: "Christopher Causer" To: orgmode Subject: clock-table and hooking that into org-capture file+olp+datetree Content-Type: text/plain Received-SPF: pass client-ip=64.147.123.19; envelope-from=ml-emacs-orgmodechyc.co.uk@chyc.co.uk; helo=wout3-smtp.messagingengine.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 30 Jan 2021 22:11:09 -0500 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=fm2 header.b=t2VxxDB0; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=l6TiDelR; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=chyc.co.uk (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 8C04D9403D6 X-Spam-Score: -0.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: pu2J934Ku0af Hello everyone! Here's a reasonably easy (I think) question because I'm quite new to Emacs and org-mode. I have an org-capture template using file+olp+datetree[1], which works great at filing my thoughts for the day. Separately I know I can generate clock tables[2] based on dynamic blocks to show me what I've been doing with my time for any given period. What I'm struggling with is to glue parts of these together to achieve the following: 1. I org-capture to the datetree. When it does so it either creates or updates an org-clock-report at the top of the datetree header (the bit that says "2020-11-12 Thursday", for example.) I guess this would be the parent of what I'm capturing. 2. For all my historical journal entries, if I could move point to a headline with a date such as the example below and it would pull the date out and add a clocktable below via an interactive function that would be my ideal. This is less of a problem for me as I don't have much in the way of history in my diary yet or my other org files. An example tree would be #+BEGIN_QUOTE * Work ** 2021 *** 2021-01 January **** 2021-01-07 Thursday ***** Ate some chips ***** Drank some soda #+END_QUOTE I tried looking at the org-mode source, and it is too advanced for me to follow. The closest I can get (or at least here's a scrap of code to prove I did actually try) is as follows: #+BEGIN_SRC emacs-lisp (defun cc/create-or-update-effort-table () (save-excursion (find-file (concat org-directory "/diary.org")) (goto-char (org-find-olp (list (concat org-directory "/diary.org" ) "Work" "2021" "2021-01 January" "2021-01-07 Thursday"))) (beginning-of-line) (next-line) (if (looking-at-p "[[:space:]]*#\\+BEGIN: clocktable") (forward-word 3) (progn (insert "\n")(previous-line))) (org-clock-report))) #+END_SRC A lot of beginner missteps there that I'm sure people can correct, but hopefully you can see the intent. If you see anything amiss please let me know, but my main problems are: 1. I hardcoded the datetree part whereas I'd like this to be today's date or even the date picker built into org-mode. I am very far off using the datepicker to generate ("%Y" "%Y-%m %B" "%Y-%m-%d %A") [3] or even from today's date. 2. I obviously don't understand how markers work well enough because I had to add the ~find-file~ whereas I would imagine you could just do it all in the goto-char line, if I knew how to use markers better . 3. The function would fail if the tree doesn't exist. I'd like it created like org-capture would. Not all clocked items are in my diary, so I may want to run the function before any diary items exist for today. 4. I would like to customize the variables org-clock-report uses to generate the report. It looks to be assigned by the defaults ~org-clocktable-defaults~. The ~:block~ option is the obvious option I'd like to change to a set date. In other words, I want to change the options in the function above but not use org-clocktable-defaults unless it reverts after the function is finished. 5. Even if the function above worked, I have no idea how to hook that into file+olp+datetree. Would I need to switch to file+function and add the clock table as a side-effect? The function cc/create-or-update-effort-table has to use olp, not headline, as the headline "2021-01-07 Thursday" is not unique in the file. Thank you for taking the time to read this far, and thank you to all the people who've contributed to Emacs and Org-Mode. I wish I'd discovered them sooner. Christopher. [1] https://orgmode.org/manual/Template-elements.html [2] https://orgmode.org/manual/The-clock-table.html [3] https://man7.org/linux/man-pages/man1/date.1.html The links are for my benefit when I come back to this email, rather than anyone else's, but I guess it doesn't hurt to include them for other people new to org-mode like myself.