From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wD4IA0esxF5hIAAA0tVLHw (envelope-from ) for ; Wed, 20 May 2020 04:04:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id CFmCOkasxF5FAQAAB5/wlQ (envelope-from ) for ; Wed, 20 May 2020 04:04:22 +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 24E3B940418 for ; Wed, 20 May 2020 04:04:22 +0000 (UTC) Received: from localhost ([::1]:51894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbFxt-0004Sw-0C for larch@yhetil.org; Wed, 20 May 2020 00:04:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbFwX-0002va-5H for emacs-orgmode@gnu.org; Wed, 20 May 2020 00:02:57 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:52674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbFwU-00052g-Sq for emacs-orgmode@gnu.org; Wed, 20 May 2020 00:02:56 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 58D90D58E3; Wed, 20 May 2020 00:02:51 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=wcPXB6blbbbYIbkRr9uJYGbxoC8=; b=vIsh+u eNQBaC0Fi+zBsSWc8Tojq0GwVs8CLn77Xcy9spaEEKetWm992Xf+CFzQvVaBuguY 1fe5id503GeeVEZzHWjqhXaMA9srV6xaPDHEam7W7t3BMF62xVkPPj8UQPzCBQ/S qDyLk8vlfWDlRcAkImqOKZjQ774WLVWZdkmOY= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 50E14D58E2; Wed, 20 May 2020 00:02:51 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=o3TihiEFhyfUtvlPy5efq3k0x4VkpDkrKXelAoH/Nu0=; b=sbctsWDjAu57JXfuw2Ydu8Y4wyw6TniiR+RxE12MnhU3oa6ljeArj/6IJXePQW6Qg7aCKT8flw4udhRHCMQSyONeXsmrZSyHIn3UrqKw0g5M8/TnnQGIecX+TIyU+n21RrqPQgiiSCj2Wv3K9FgjCF+piJvZF3nY/pGj3cih22E= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 9861DD58DF; Wed, 20 May 2020 00:02:48 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Nils Schween Subject: Re: Capture Template Diary Entry: file+datetree+prompt use the prompted timestamp including the time when time is specified In-Reply-To: References: Date: Wed, 20 May 2020 04:02:46 +0000 Message-ID: <87lflns17d.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: C4B2C2AA-9A4E-11EA-95C0-8D86F504CC47-24757444!pb-smtp21.pobox.com Received-SPF: pass client-ip=173.228.157.53; envelope-from=kyle@kyleam.com; helo=pb-smtp21.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/20 00:02:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=vIsh+u e; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=sbctsWDj; 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-Spam-Score: -1.21 X-TUID: byjSyOl6U08d Nils Schween writes: > ("d" "Diary entry" entry (file+datetree+prompt "~/MPIK-Nextcloud/emacs/.org/kalender.org") > "* %i%?\n %T") > > And it works as expected: When calling the capture template, I am prompted for a > date and I can also type a time, and on saving everything is stored at the > correct location in the datetree. Perfect. But in case I do not enter a time, > 00:00 is inserted. This is unfortunate. Okay, I can replace "%T" in the template > with "%t", but then any specification of time is ignored. > > Instead, I would love to mimic the behaviour of the function "org-time-stamp". Calling it > prompts for a date, and if I do not specify a time, only the date is inserted. > In case I specify a time or a range (i.e. 10:00-12:00) the timestamp is > supplemented with this additional information. > > I tried a lot to get the desired behaviour by testing variants of the following > combination of org-mode functions and variables. > %(org-insert-time-stamp (org-read-date nil t org-read-date-final-answer) t) > > I was not able to produce what I wanted. > > Does anyone have a workaround or an idea how I could implement the described and > wished behaviour? Thanks. I'm not aware of any built-in way to do what you want. For either implementing or working around, org-capture-set-target-location and org-capture-fill-template are the two places you'd probably want to look. As a start of a hacky workaround, with an entry like ("d" "Diary entry" entry (file+datetree "/tmp/scratch.org") "* %i%?\n %T" :time-prompt t) you should be able to get the time/no time behavior you're after with (advice-add 'org-capture-fill-template :around (lambda (fn &optional template &rest args) (let ((template (and (not org-time-was-given) (replace-regexp-in-string "%T" "%t" (org-capture-get :template) t)))) (apply fn template args))) '((name . "org-capture-hack")))