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 QP+RLi+TFWCfawAA0tVLHw (envelope-from ) for ; Sat, 30 Jan 2021 17:11:11 +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 AKJgKi+TFWCyfQAAbx9fmQ (envelope-from ) for ; Sat, 30 Jan 2021 17:11:11 +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 2FD7394029C for ; Sat, 30 Jan 2021 17:11:11 +0000 (UTC) Received: from localhost ([::1]:35738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5tmA-0001Qs-2e for larch@yhetil.org; Sat, 30 Jan 2021 12:11:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5tko-0001L7-7T for emacs-orgmode@gnu.org; Sat, 30 Jan 2021 12:09:46 -0500 Received: from forward4-smtp.messagingengine.com ([66.111.4.238]:35359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5tkh-00072f-LS for emacs-orgmode@gnu.org; Sat, 30 Jan 2021 12:09:41 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailforward.nyi.internal (Postfix) with ESMTP id D83111953B5F; Sat, 30 Jan 2021 12:09:38 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 30 Jan 2021 12:09:38 -0500 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=rWzviU lwiCUWAoOoWxYOGW6qd1HZoMk9dLgOvtaJoNI=; b=CJ31TlLz+tTT4FgPo5Uaol /XGYnwrOf98rscbcAZSGasxWmaWcS+jOBXFlVAn5HSVeCPguVs2J9j3tIjL3FlN7 F7lNxOmvIrzH7QCgsPbruwY0OrI0yj/UKuE9jAS0D1bZnbl2ydMCu7pdey0tz259 jebizrqsKo7GeG4uP5696xYYWms8Va1clP163Y3W1Phd+H/p/Va2t2bPfMMxQNta eybzrgK3XtcIPya1IpR3UHlHz6dJRRKKMWlrYXmPq1xvQYHXFDI8bPrB9m9GdwS2 UKRXb1h0Gn+kdtAsMqZdUyCCJF95wMzGGXRlZmYgB2rqj8eMUuco+JoXlzd8+pZA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeggdelkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufgjfhffkfggtgesthdtredttd dttdenucfhrhhomheptfhitghhrghrugcunfgrfihrvghntggvuceorhhitghhrghrugdr lhgrfihrvghntggvsehunhhiqdhtuhgvsghinhhgvghnrdguvgeqnecuggftrfgrthhtvg hrnhephfejheeujeelgfdvieekkeegtefhgeekkedvgeeljedvteejhefhffefteeggfel necukfhppeegiedruddugedrudehuddrudeggeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehrfihlsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Received: from aquinas (dynamic-046-114-151-144.46.114.pool.telefonica.de [46.114.151.144]) by mail.messagingengine.com (Postfix) with ESMTPA id 51D9D108005F; Sat, 30 Jan 2021 12:09:38 -0500 (EST) Received: from rwl by aquinas with local (Exim 4.92) (envelope-from ) id 1l5tke-0005JG-9W; Sat, 30 Jan 2021 18:09:36 +0100 From: Richard Lawrence To: Christopher Causer , orgmode Subject: Re: clock-table and hooking that into org-capture file+olp+datetree In-Reply-To: <44e81542-882d-4c36-adcd-69ca90b23f48@www.fastmail.com> References: <79daebf0-5bda-473a-b289-392fd0c8df18@www.fastmail.com> <85e0ac65-f4b6-4212-95bf-2bc24671de06@www.fastmail.com> <87mtwqziuj.fsf@aquinas> <44e81542-882d-4c36-adcd-69ca90b23f48@www.fastmail.com> Date: Sat, 30 Jan 2021 18:09:36 +0100 Message-ID: <87im7ez6zz.fsf@aquinas> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: neutral client-ip=66.111.4.238; envelope-from=rwl@fastmail.com; helo=forward4-smtp.messagingengine.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_NEUTRAL=0.779 autolearn=no 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: -2.05 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=CJ31TlLz; dmarc=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: 2FD7394029C X-Spam-Score: -2.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: 5qGqJ+cHUuPM Hi Christopher and all, "Christopher Causer" writes: >> 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? As sensible as anything :) I recently added my version, using decode-time and nth, as a helper function to my .emacs. I feel sure that it must already exist *somewhere* in Emacs but I searched quite a while for it and didn't find it. I will use this again below: #+begin_src emacs-lisp (defun time-as-calendar-date (time) "Convert time in Emacs' time format to a calendar date list (MONTH DAY YEAR)" (let ((parsed-time (decode-time time))) (list (nth 4 parsed-time) (nth 3 parsed-time) (nth 5 parsed-time)))) #+end_src > My two next things to tackle are > > 1. A hook to run the function when I run org-capture. Here you might find it useful to grab the value of the :default-time key from org-capture-plist (which should contain either the time you entered at the date prompt during capture, or the current time, in Emacs' time format). Then, using the functions above, you can say something like this in your hook: #+being_src emacs-lisp (let* ((default-time (plist-get org-capture-plist :default-time)) (date (time-as-calendar-date default-time))) (org-update-clocktable-on-date date)) #+end_src > 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. Emacs Lisp has dynamic scope by default, which makes this is pretty easy in general: just set the value you want to use in a let form around the code that uses this variable, like: (let ((org-clocktable-defaults your-custom-value-here)) ...) > Thank you so much Richard. You've probably saved me days of going through the org-mode documentation and source. No problem! That's what this list is for. I recently spent a fair amount of time digging through the datetree stuff myself, so I was glad to have a chance to share what I learned. -- Best, Richard