emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-capture -- optionally add time-of-day as with C-c . ?
@ 2016-02-10  9:22 John Magolske
  2016-02-10 18:47 ` Charles Millar
  2016-02-10 19:19 ` Aaron Ecay
  0 siblings, 2 replies; 4+ messages in thread
From: John Magolske @ 2016-02-10  9:22 UTC (permalink / raw)
  To: emacs-orgmode

In setting up org-capture, I'd like to have behaviour similar to what
`org-time-stamp` provides, which by default is bound to:

    C-c .

That command in org-mode brings up a 3-month calendar and a minibuffer
prompt for entering a date. With nothing entered at the prompt, just a
RET, a timestamp with the current date is inserted like so:

    <2016-02-09 Tue>

If a date is picked from the calender, say March 26, then that date
is inserted:

    <2016-03-26 Sat>

If, for example, 2pm is entered at the minibuffer prompt and March 8
is picked from the calender, then a timestamp like so gets inserted:

    <2016-03-08 Tue 14:00>

I find this to be a very nice, intuitive interface. Time-of-day is
easily added, but only if explicitly input. Otherwise just the date
shows up. I'm having a hard time setting this up for org-capture...
I can get close with something like:

  (setq org-capture-templates
      '(("t" "todo" entry (file+headline "~/org/todo.org" "Tasks")
      "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t) t)\n")))

But that always inserts a time-of-day into the timestamp, using the
current time if nothing is input at the minibuffer prompt. So if I
just pick March 8 from the calender, that date will be inserted along
with the current time-of-day like so:

    ** TODO
        SCHEDULED: <2016-03-08 Mon 00:53>

Which pretty much always necessitates a manual edit of the time to
either remove it or adjust it to something relevant.

When explicitly adding a time value at the prompt in the minibuffer,
2pm for example, then picking March 8, this would show up:

    ** TODO
        SCHEDULED: <2016-03-08 Tue 14:00>

And that works great. It's just the aforementioned situation where no
time-of-day is entered and the current time-of-day gets associated
with some future-date timestamp rather than just having that date show
up by itself with no time-of-day.

Is there some way to have the `C-c .` behaviour outlined above happen
in org-capture?

TIA for any help,

John

-- 
John Magolske
http://b79.net/contac

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-capture -- optionally add time-of-day as with C-c . ?
  2016-02-10  9:22 org-capture -- optionally add time-of-day as with C-c . ? John Magolske
@ 2016-02-10 18:47 ` Charles Millar
  2016-02-10 19:19 ` Aaron Ecay
  1 sibling, 0 replies; 4+ messages in thread
From: Charles Millar @ 2016-02-10 18:47 UTC (permalink / raw)
  To: emacs-orgmode

Hi John,

On 02/10/2016 04:22 AM, John Magolske wrote:
> In setting up org-capture, I'd like to have behaviour similar to what
> `org-time-stamp` provides, which by default is bound to:
>
>      C-c .
>
> That command in org-mode brings up a 3-month calendar and a minibuffer
> prompt for entering a date. With nothing entered at the prompt, just a
> RET, a timestamp with the current date is inserted like so:
>
>      <2016-02-09 Tue>
>
> If a date is picked from the calender, say March 26, then that date
> is inserted:
>
>      <2016-03-26 Sat>
>
> If, for example, 2pm is entered at the minibuffer prompt and March 8
> is picked from the calender, then a timestamp like so gets inserted:
>
>      <2016-03-08 Tue 14:00>
>
> I find this to be a very nice, intuitive interface. Time-of-day is
> easily added, but only if explicitly input. Otherwise just the date
> shows up. I'm having a hard time setting this up for org-capture...
> I can get close with something like:
>
>    (setq org-capture-templates
>        '(("t" "todo" entry (file+headline "~/org/todo.org" "Tasks")
>        "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t) t)\n")))
>
> But that always inserts a time-of-day into the timestamp, using the
> current time if nothing is input at the minibuffer prompt. So if I
> just pick March 8 from the calender, that date will be inserted along
> with the current time-of-day like so:
>
>      ** TODO
>          SCHEDULED: <2016-03-08 Mon 00:53>
>
> Which pretty much always necessitates a manual edit of the time to
> either remove it or adjust it to something relevant.
>
> When explicitly adding a time value at the prompt in the minibuffer,
> 2pm for example, then picking March 8, this would show up:
>
>      ** TODO
>          SCHEDULED: <2016-03-08 Tue 14:00>
>
> And that works great. It's just the aforementioned situation where no
> time-of-day is entered and the current time-of-day gets associated
> with some future-date timestamp rather than just having that date show
> up by itself with no time-of-day.
>
> Is there some way to have the `C-c .` behaviour outlined above happen
> in org-capture?
>
>
Have you tried the template expansion %^T (active time stamp prompt with 
date and time); Also %^U is the inactive equivalent, etc.

Charlie Millar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-capture -- optionally add time-of-day as with C-c . ?
  2016-02-10  9:22 org-capture -- optionally add time-of-day as with C-c . ? John Magolske
  2016-02-10 18:47 ` Charles Millar
@ 2016-02-10 19:19 ` Aaron Ecay
  2016-02-10 19:57   ` John Magolske
  1 sibling, 1 reply; 4+ messages in thread
From: Aaron Ecay @ 2016-02-10 19:19 UTC (permalink / raw)
  To: John Magolske, emacs-orgmode

Hi John,

Using %^T seems to give the desired behavior you describe in your
message.  Can you try it and see if it works for you?  (Regrettably,
it’s not obvious from the docstring of ‘org-capture-templates’ that it
should behave like that, since %T is supposed to insert a time
unconditionally.  But in my testing, %^T only inserts a time if one is
entered by the user.)

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-capture -- optionally add time-of-day as with C-c . ?
  2016-02-10 19:19 ` Aaron Ecay
@ 2016-02-10 19:57   ` John Magolske
  0 siblings, 0 replies; 4+ messages in thread
From: John Magolske @ 2016-02-10 19:57 UTC (permalink / raw)
  To: emacs-orgmode

Hi Aaron,

* Aaron Ecay <aaronecay@gmail.com> [160210 11:22]:
> Using %^T seems to give the desired behavior you describe in your
> message.  Can you try it and see if it works for you?  (Regrettably,
> it’s not obvious from the docstring of ‘org-capture-templates’ that it
> should behave like that, since %T is supposed to insert a time
> unconditionally.  But in my testing, %^T only inserts a time if one is
> entered by the user.)

I just tried %^T and it did not work -- a time-of-day was included in
all cases. What *did* work however is the lowercase %^t version. With
that in my org-capture template, just the date is inserted, except when
an explicit time-of-day is entered at the minibuffer prompt. Then that
time is added after the date. This makes picking dates & times with
org-capture a breeze.

Thanks for clueing me in!

John

-- 
John Magolske
http://b79.net/contact

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-10 19:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-10  9:22 org-capture -- optionally add time-of-day as with C-c . ? John Magolske
2016-02-10 18:47 ` Charles Millar
2016-02-10 19:19 ` Aaron Ecay
2016-02-10 19:57   ` John Magolske

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).