emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Non-interactive insertion of future-dates
@ 2012-01-25 16:42 Simon Campese
  2012-01-25 17:37 ` Borbus
  2012-01-25 17:56 ` Jonathan Leech-Pepin
  0 siblings, 2 replies; 5+ messages in thread
From: Simon Campese @ 2012-01-25 16:42 UTC (permalink / raw)
  To: emacs-orgmode

Dear community,

I want to setup a capture-template that sets a
SCHEDULE-property in the future (say one week from today) without any
user interaction.

Currently, I almost achieve this by inserting the line

:SCHEDULED: <%(org-read-date nil nil nil nil nil "+1w")>

into my template. When I now call the template, I end up in the
date-time-prompt, with "+1w" prefilled, so that manually have to press
enter. 

Maybe it is trivial to call an interactive lisp-function and emulate
some keypress, in which case I would be thankful for the code that
achieves this (my lisp-skills are limited). Also, one should be able to
achieve what I want by using format-time-string and increment the
current time, but again my lisp-skills prohibit me from implementing it
myself. 

In any case, it might be a good idea to include non-interactive access
to relative times in template expansion, so that for example one
can state something like %t[+1w] or %{+1w}t in the template to get the
date one week from today (one should spend some more time to specify the
actual input-format of course...). What do you think? 


Thank you very much,

Simon

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

* Re: Non-interactive insertion of future-dates
  2012-01-25 16:42 Non-interactive insertion of future-dates Simon Campese
@ 2012-01-25 17:37 ` Borbus
  2012-01-28 17:42   ` Simon Campese
  2012-01-25 17:56 ` Jonathan Leech-Pepin
  1 sibling, 1 reply; 5+ messages in thread
From: Borbus @ 2012-01-25 17:37 UTC (permalink / raw)
  To: emacs-orgmode

On 25/01/12 16:42, Simon Campese wrote:
> I want to setup a capture-template that sets a
> SCHEDULE-property in the future (say one week from today) without any
> user interaction.
> 
> Currently, I almost achieve this by inserting the line
> 
> :SCHEDULED: <%(org-read-date nil nil nil nil nil "+1w")>
> 
> into my template. When I now call the template, I end up in the
> date-time-prompt, with "+1w" prefilled, so that manually have to press
> enter. 

I think what you want is to use the parameter from-string which doesn't
ask for a user input at all but just uses that string as if you did
input it interactively:

(org-read-date nil nil "+1w")

-- 
Borbus.

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

* Re: Non-interactive insertion of future-dates
  2012-01-25 16:42 Non-interactive insertion of future-dates Simon Campese
  2012-01-25 17:37 ` Borbus
@ 2012-01-25 17:56 ` Jonathan Leech-Pepin
  2012-01-28 22:38   ` Simon Campese
  1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Leech-Pepin @ 2012-01-25 17:56 UTC (permalink / raw)
  To: Simon Campese; +Cc: emacs-orgmode

Hello,


On Wed, Jan 25, 2012 at 11:42, Simon Campese <emacs-orgmode@campese.de> wrote:
>
> Dear community,
>
> I want to setup a capture-template that sets a
> SCHEDULE-property in the future (say one week from today) without any
> user interaction.
>
> Currently, I almost achieve this by inserting the line
>
> :SCHEDULED: <%(org-read-date nil nil nil nil nil "+1w")>
>
> into my template. When I now call the template, I end up in the
> date-time-prompt, with "+1w" prefilled, so that manually have to press
> enter.
>
> Maybe it is trivial to call an interactive lisp-function and emulate
> some keypress, in which case I would be thankful for the code that
> achieves this (my lisp-skills are limited). Also, one should be able to
> achieve what I want by using format-time-string and increment the
> current time, but again my lisp-skills prohibit me from implementing it
> myself.

A similar question had come up on StackOverflow (
http://stackoverflow.com/questions/7986935/using-org-capture-templates-to-schedule-a-todo-for-the-day-after-today/7988809#7988809
).

My answer there should apply, adjusting the offset from +1d to +1w :

    SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+1d\"))

Alternately you can include the SCHEDULED: portion within the
timestamp insertion itself.  This example will also include a fixed
time at which to schedule the item (unneeded in this case I suspect
but it could be of use elsewhere) :

    (org-insert-time-stamp (org-read-date nil t \"+1w 12:00\") t nil
\"SCHEDULED: \")

> In any case, it might be a good idea to include non-interactive access
> to relative times in template expansion, so that for example one
> can state something like %t[+1w] or %{+1w}t in the template to get the
> date one week from today (one should spend some more time to specify the
> actual input-format of course...). What do you think?

I agree, adding the ability to automatically have relative dates would
allow for quicker capture templates if you regularly need to to set
them with a specific offset.

> Thank you very much,
>
> Simon

Regards,

Jonathan

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

* Re: Non-interactive insertion of future-dates
  2012-01-25 17:37 ` Borbus
@ 2012-01-28 17:42   ` Simon Campese
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Campese @ 2012-01-28 17:42 UTC (permalink / raw)
  To: emacs-orgmode

Thanks Borbus, it works! See my followup to Jonathan's answer on my plans to add
relative dates to the template expansion.


Best wishes,

Simon

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

* Re: Non-interactive insertion of future-dates
  2012-01-25 17:56 ` Jonathan Leech-Pepin
@ 2012-01-28 22:38   ` Simon Campese
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Campese @ 2012-01-28 22:38 UTC (permalink / raw)
  To: Jonathan Leech-Pepin; +Cc: emacs-orgmode

Hey Jonathan,

thanks for the hints, it works like a charm! As far as I can overlook
this, adding relative dates to the template expansion should not be a
lot of work, basically one just has to add a simple wrapper to
org-read-date. I gave some more thoughts to an appropriate symbol and
the best I could come up with is '_'. I therefore propose the following: 

% {EXP}t, %_{EXP}T, %_{EXP}u, %_{EXP}U 

in a capture-template inserts an (in-)active date-/timestamp that would
have resulted from manually entering the expression EXP at the
interactive date-/timeprompt. 

If no serious objections come up, I will put this on my todo-list.


Best wishes,

Simon



On Wed, 25 Jan 2012 12:56:37 -0500, Jonathan Leech-Pepin <jonathan.leechpepin@gmail.com> wrote:
> Hello,
> 
> 
> On Wed, Jan 25, 2012 at 11:42, Simon Campese <emacs-orgmode@campese.de> wrote:
> >
> > Dear community,
> >
> > I want to setup a capture-template that sets a
> > SCHEDULE-property in the future (say one week from today) without any
> > user interaction.
> >
> > Currently, I almost achieve this by inserting the line
> >
> > :SCHEDULED: <%(org-read-date nil nil nil nil nil "+1w")>
> >
> > into my template. When I now call the template, I end up in the
> > date-time-prompt, with "+1w" prefilled, so that manually have to press
> > enter.
> >
> > Maybe it is trivial to call an interactive lisp-function and emulate
> > some keypress, in which case I would be thankful for the code that
> > achieves this (my lisp-skills are limited). Also, one should be able to
> > achieve what I want by using format-time-string and increment the
> > current time, but again my lisp-skills prohibit me from implementing it
> > myself.
> 
> A similar question had come up on StackOverflow (
> http://stackoverflow.com/questions/7986935/using-org-capture-templates-to-schedule-a-todo-for-the-day-after-today/7988809#7988809
> ).
> 
> My answer there should apply, adjusting the offset from +1d to +1w :
> 
>     SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+1d\"))
> 
> Alternately you can include the SCHEDULED: portion within the
> timestamp insertion itself.  This example will also include a fixed
> time at which to schedule the item (unneeded in this case I suspect
> but it could be of use elsewhere) :
> 
>     (org-insert-time-stamp (org-read-date nil t \"+1w 12:00\") t nil
> \"SCHEDULED: \")
> 
> > In any case, it might be a good idea to include non-interactive access
> > to relative times in template expansion, so that for example one
> > can state something like %t[+1w] or %{+1w}t in the template to get the
> > date one week from today (one should spend some more time to specify the
> > actual input-format of course...). What do you think?
> 
> I agree, adding the ability to automatically have relative dates would
> allow for quicker capture templates if you regularly need to to set
> them with a specific offset.
> 
> > Thank you very much,
> >
> > Simon
> 
> Regards,
> 
> Jonathan

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

end of thread, other threads:[~2012-01-28 22:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-25 16:42 Non-interactive insertion of future-dates Simon Campese
2012-01-25 17:37 ` Borbus
2012-01-28 17:42   ` Simon Campese
2012-01-25 17:56 ` Jonathan Leech-Pepin
2012-01-28 22:38   ` Simon Campese

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).