Search code examples
emacsorg-mode

Grabbing subheaders in org-mode capture template.


I'm using org-mode to write some prose. I'm using the org-capture templates as a convenient way to make notes about edits I need to make later. As I am writing, I can quickly capture an idea or make a note about something that needs to be researched later, and then continue writing.

The problem is that the capture template is not grabbing subheadings, so I need to search the entire text to determine where the edit should be.

Here is the current capture template:

("h" "Writing TODO" entry (file+headline "~/Book-Outline.org" "EDITS")
"* TODO - %?\n \%i\n \%a")

The more specific the capture information, the easier it will be to go back to the exact location in the book to make the edits. Additional ideas or suggestions are appreciated if the capture templates will not do this.


Solution

  • The solution I use is something like:

    ("h" "Writing TODO" entry (file+headline "~/Book-Outline.org" "EDITS")
    "* TODO - %?\n %i\n[[%l][In file %f]]")
    

    It creates an org link to the file when org-capture was called

    From Emacs doc here

    • %l: like %a, but only insert the literal link.
    • %f: file visited by current buffer when org-capture was called.

    Another possible explanation:

    In my Org templates I do not use \, maybe you can try to replace your \%a by %a, without the \. (I have not checked that, sorry).