Org mode capture

2

2

I'm trying to make a 'class' template for org-capture.

What I want is to easily make this kind of entry:

* TODO <course>: Week <week> Lecture <number>
  SCHEDULED: %^T
** TODO prepare for class: <course>-<week>-<number>
   SCHEDULED: <two days before T> DEADLINE: <one day before T>
** TODO review class: <course>-<week>-<number>
   SCHEDULED: <one day after T> DEADLINE: <two days after T>

Currently, I have this template.

(setq org-capture-templates
   '(
     ("c" "Class" entry (file "~/sydbox/personal/workflow/class.txt")
          "* TODO %^{Course}: Week %^{Week} Lecture %^{Number}\n SCHEDULED: %^T\n ** TODO prepare for %{Course}-%{week}-%{Number}")
     ))

However, now I have no idea how to input the dates. The date and time of the course should be prompted for. I also have no idea how to reuse the answer to a prompt.

Syd Kerckhove

Posted 2014-07-26T05:35:01.933

Reputation: 121

Answers

2

Template expansion allows %\1, %\2, etc. to reuse answers to a prompt, so you might try this:

("c" "Class" entry (file "~/sydbox/personal/workflow/class.txt")
      "* TODO %^{Course}: Week %^{Week} Lecture %^{Number}\n SCHEDULED: %^{Sched}T\n ** TODO prepare for %\\1-%\\2-%\\3")

For entering dates, it should give you a calendar. From there you can use shift-arrow keys to select a date, or these commands.

amitp

Posted 2014-07-26T05:35:01.933

Reputation: 156

Thankyou, but I want to about using any keys at all. All the dates should be in order automatically. – Syd Kerckhove – 2014-07-27T01:20:04.310

Oh I see, I misread, sorry about that. I looked at the org-capture-fill-template function .. I wanted to see whether %(...) would work but it looks like that gets evaluated before the prompts are run, so it can't perform calculations based on the date you enter. :( – amitp – 2014-07-27T15:36:44.837

0

You could try writing a function to do the date arithmetic you want and replace placeholders in the capture template, then use org-capture-before-finalize-hook to run the function before the capture process finishes.

Win

Posted 2014-07-26T05:35:01.933

Reputation: 101