been using org-mode for a little over a year, but still have a ton to learn. Here's the setup and question: i've got a straightforward date-tree daily notes / tasks setup, and i'm trying to figure out how to append to a sub-heading within that structure. At the top-level, my main file is structured like this:

* 2020
** 2020-11 November
*** 2020-11 November
**** 2020-11-24 Tuesday
***** tasks
***** log
***** meetings
***** notes

And I want to create a capture template that appends a note under today's "* log". I'm currently using a capture template like this:

   ("y" "Work Task" entry (file+olp+datetree "~/org/journal/work.org")
    "* TODO %?\n%U" :empty-lines 1)

Which is fine, but it adds the task to the date correctly, but not the TASKS sub-heading. Any idea how I'd set that up?

  • There is no way to answer the question without a lot more detail about the structure of the file where the capture will end up. If you have a capture template that you are using already, please add it to the question and describe how it fails to satisfy your requiremenets. – NickD Nov 24 '20 at 18:05
  • thanks for the response, @nickd. tweaked my writeup above. – baronvoz Nov 30 '20 at 16:40

One way is to search the subtree for the log heading and, if it finds one, set the point to that location.

(setq org-capture-templates
      '(("y" "Work Task" entry (file+function
                (lambda ()
                   (org-date-to-gregorian (org-today)) t)
                  (re-search-forward "^\\*.+ log" nil t)))
     "* TODO %?\n%U" :empty-lines 1)))
  • works perfectly, thank you! – baronvoz Dec 2 '20 at 14:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.