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 oKQkIyEcFWDBEgAA0tVLHw (envelope-from ) for ; Sat, 30 Jan 2021 08:43:13 +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 OCvdHiEcFWALKQAAbx9fmQ (envelope-from ) for ; Sat, 30 Jan 2021 08:43:13 +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 2B4EC94030E for ; Sat, 30 Jan 2021 08:43:11 +0000 (UTC) Received: from localhost ([::1]:42738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5lqY-0003cG-3e for larch@yhetil.org; Sat, 30 Jan 2021 03:43:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5lpW-0003c6-Q4 for emacs-orgmode@gnu.org; Sat, 30 Jan 2021 03:42:06 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:50515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5lpT-000221-T8 for emacs-orgmode@gnu.org; Sat, 30 Jan 2021 03:42:06 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 76F315C00B2 for ; Sat, 30 Jan 2021 03:41:59 -0500 (EST) Received: from imap34 ([10.202.2.84]) by compute1.internal (MEProxy); Sat, 30 Jan 2021 03:41:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type; s=fm2; bh=sy7Pu3CxEINeLv8irQs85YO1e2cL5qh kKMrEx0QeGvc=; b=ZRVVdCseYDqf7bYpXT1gdwnNokfpQX9aLRhj86zkWc7EkH+ 2thc+YsnpkXYCfKZYG6Shcvnz4Y+ykhgLXzUPDakjBRAaMKz/5qVetcjZnqbwiuw FIqoCEEpbITWKFJSzQ1NltdNKhsfwiFE12DLh9xSpVfSk89OwEAeharY+6diYwob 0QR4EoHHS0Zt5Nj8qy6uil3x8Ow00uajGvBK1K6peIzNegDIKyR0iXiTeJhTTo52 +QeVBQ93NQK6AcBNJZKeLHQft2pEocDVwEYIz7tVt06UPyxh/XY0AVmjTvnrxHBb SqmKyrQgBsP8cvYCH98KBwOduFxzjasjEaNdl0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=sy7Pu3 CxEINeLv8irQs85YO1e2cL5qhkKMrEx0QeGvc=; b=bPfYLkrW5LEpDLI/2QygUI 4xBUBVdxNBxfI+/5Hp8OCTEJYq93ctQt4V1e95KRVm8bGu8E4t4mipvwuF/eT97M ell5hF+IJI5TTnrtLPWV97FxDiXjwaTfJ4AStOsLEk9rp3F/s+hgUu1XMavzYbaK jSZj1qNxN/dRrW/VifFN/VkI+Gd1oVBXZdeRR5idlP1qox0kHIlLft6o6Df7jUAc IccDTCrk74BDJlsIkpLvgR0tu4r4iSKNPA34thdWzdAo1omWrdFccuIJ+Jx2IC9M 56jbgMhp1k9KOYvLlvmNokIhMc1eiqlusKjX4/T86Q5mKErH/eraylhgl0nyv/Yg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeefgdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd ertderredtnecuhfhrohhmpedfvehhrhhishhtohhphhgvrhcuvegruhhsvghrfdcuoehm lhdqvghmrggtshdqohhrghhmohguvgestghhhigtrdgtohdruhhkqeenucggtffrrghtth gvrhhnpeduhefgudetlefgvddtffefgffgvddujeeuveetleegueefheehteehieehueek hfenucffohhmrghinhepughirghrhidrohhrghdpohhrghhmohguvgdrohhrghdpmhgrnh ejrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepmhhlqdgvmhgrtghsqdhorhhgmhhouggvsegthhihtgdrtghordhukh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 64445280066; Sat, 30 Jan 2021 03:41:58 -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: <85e0ac65-f4b6-4212-95bf-2bc24671de06@www.fastmail.com> In-Reply-To: <79daebf0-5bda-473a-b289-392fd0c8df18@www.fastmail.com> References: <79daebf0-5bda-473a-b289-392fd0c8df18@www.fastmail.com> Date: Sat, 30 Jan 2021 08:40:12 +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=66.111.4.27; envelope-from=ml-emacs-orgmode@chyc.co.uk; helo=out3-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-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: -1.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=fm2 header.b=ZRVVdCse; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=bPfYLkrW; 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: 2B4EC94030E X-Spam-Score: -1.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: bdpIKkChs1X3 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 a subheading of datetree. When it does so it either creates or updates an org-clock-report just below 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]. This would also be needed for point 4. 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.