From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: Bug: org-capture-templates with %^t Date: Fri, 06 Oct 2017 10:20:41 -0500 Message-ID: <87h8vce20m.fsf@fastmail.fm> References: <87h8vfj0bo.fsf@fastmail.fm> <87bmlllkpz.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0UQi-0006VC-KC for emacs-orgmode@gnu.org; Fri, 06 Oct 2017 11:20:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0UQe-0007wO-0l for emacs-orgmode@gnu.org; Fri, 06 Oct 2017 11:20:47 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:34985) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0UQd-0007tE-LM for emacs-orgmode@gnu.org; Fri, 06 Oct 2017 11:20:43 -0400 Received: from archdesk (wcnat-96-20.wheaton.edu [209.147.96.20]) by mail.messagingengine.com (Postfix) with ESMTPA id A82857FA80 for ; Fri, 6 Oct 2017 11:20:41 -0400 (EDT) In-Reply-To: <87bmlllkpz.fsf@fastmail.fm> (Matt Lundin's message of "Thu, 05 Oct 2017 09:43:08 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode --=-=-= Content-Type: text/plain Matt Lundin writes: > Matt Lundin writes: > >> After commit 51b431d01365211d4c40b07729d5d11d82b9dfe2, >> org-capture-templates containing %^t do not work as expected. >> >> With this capture template, I am prompted to enter a time via >> org-read-date. The expected behavior is as follows: >> >> - if I enter a date and time of day, the resulting timestamp should >> contain the time of day: >> - i.e., entering "Thu 8am" should yield "<2017-10-05 Thu 08:00>" >> >> What happens now: >> >> - when I enter a date with a time of day, the timestamp is truncated >> and contains only a date >> - I.e., entering "Thu 8am" now yields "<2017-10-05 Thu>" >> > > There is a further bug here. With the capture template above, if I enter > a time range - i.e., an end time - the timestamp in the capture buffer > is incorrect. > > Entering... "Thu 8am-10am" yields... > > <2017-10-05 Thu-10:00> > Attached please find a patch that fixes these issues. It is a simple change, but it brings the behavior of %^t and %^u vs. %^T and %^U into line with the behavior of the interactive function org-time-stamp without and with a prefix argument. The escapes %^t and %^u now default to no time of day if the user enters nothing but allow the optional entry of a time of day via user interaction. The escapes %^T and %^U always include a time of day, with or without user interaction. Best, Matt --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-interactive-timestamp-entry-in-capture-templates.patch >From b3e9fc879c8cadd8b634d7f4f3512ba1eaf1b8bf Mon Sep 17 00:00:00 2001 From: Matt Lundin Date: Fri, 6 Oct 2017 09:50:05 -0500 Subject: [PATCH] Fix interactive timestamp entry in capture templates * lisp/org-capture.el: (org-capture-fill-template) Fix interactive timestamp entry to match the behavior of org-time-stamp. This fixes a bug related to the %^t and %^u template escapes which resulted in incorrect timestamps (<2017-10-06 Fri-12:00>). The difference between %^t and %^T now corresponds to the difference between org-time-stamp called without and with a prefix argument. --- lisp/org-capture.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 862cdb276..25af674b8 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1792,11 +1792,10 @@ The template may still contain \"%?\" for cursor positioning." (let* ((upcase? (equal (upcase key) key)) (org-end-time-was-given nil) (time (org-read-date upcase? t nil prompt))) - (let ((org-time-was-given upcase?)) - (org-insert-time-stamp - time org-time-was-given - (member key '("u" "U")) - nil nil (list org-end-time-was-given))))) + (org-insert-time-stamp + time (or org-time-was-given upcase?) + (member key '("u" "U")) + nil nil (list org-end-time-was-given)))) (`nil (push (org-completing-read (concat (or prompt "Enter string") -- 2.14.2 --=-=-=--