0

I would like to use org-capture to quickly store appointments in a journal file, and add a timestamp so that the appointment appears in my agenda. I'm using the following template:

;; excerpted from my .emacs-custom.el
(custom-set-variables
  '(org-capture-templates
        ("a" "Appointment" entry
         (file+olp+datetree "~/org/journal.org")
         "* %?
%T" :time-prompt t))))

This almost works. file+olp+datetree automatically places the new appointment at the correct spot in a date-tree, I am prompted for the actual date and time to use due to :time-prompt t, and the item has a time stamp inserted via the %T in the template.

The only hitch is that if I enter a time range (as for a meeting that will take 30 minutes):

<2019-09-18 Wed 12:30-13:00> 

The time is truncated in my item to:

<2019-09-18 Wed 12:30> 

So I have to manually add the time range myself.

Looking into the source code, it looks like org-capture-set-target-location explicitly cuts off the second part of a time range. That makes sense for the date-tree headings, but it breaks my scheduled timestamp.

Before I start hacking away at the org source code, I wonder if there's a way to accomplish this more directly. Specifically, what I would like:

  1. Get a prompt for a date and time, which could include a time range.
  2. Fill in an org entry, which includes the time I selected as a timestamp.
  3. Store the entry in a date-tree structure in an org file.

What I don't want is to enter the date twice (once for the date-tree, once for the schedule), or to manually fix the date after the entry is created.

To clarify, I want the items stored in a date-tree structure so I can browse through this one file to review my past and coming appointments. I want to add the time stamp so the entries will appear in my org-agenda at the appropriate time and date.

| improve this question | | | | |
  • I don't use date ranges or even a current version of org-mode for that matter, but the manual includes a second type of date range format such as <2004-08-23 Mon>--<2004-08-26 Thu>. Perhaps that alternative format using two time stamps connected with a two dashes could suffice .... – lawlist Sep 10 '19 at 1:43
  • @lawlist I'm not really concerned about the format - your alternative is fine for me. However, the main problem is that with either format I have to manually correct the time after org-capture trims the range off. – Tyler Sep 10 '19 at 13:26
  • The following seems to work as you have described: (setq org-capture-templates '(("a" "Appointment" entry (file+olp+datetree "~/org/journal.org") "* %?\n%^t"))) – lawlist Sep 10 '19 at 16:46
  • @lawlist almost - with that template, I get prompted for the date first, to determine where in the date-tree the entry will go, and then prompted again for the timestamp for the item. I want to enter the date (with time range) once, and have the resulting entry get filed in the date-tree with the correct timestamp. – Tyler Sep 10 '19 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.