Odd Org-Capture behaviour

Preamble

This previous evening I tried to get a better handle on some of the expansions offered by org capture templates.

My history with org capture has been a bit contentious as it always seems to be the first thing to break on me and as a result I’ve opted to keep my capture templates as short as possible by offloading most of the actual templating to yas-snippet and having the template be just the trigger. (honestly might be the best solution in terms of not getting side-tracked).

Part of the trouble is I’m not actually sure what I should expect to see when using some of the prompt expansions with org-capture.

Allow me to illustrate:

This is the template I attempted to create for myself:

    (setq org-capture-templates
            ("s" "School" entry (file "~/.notes/agenda-school.org")
             "* TODO %^{PROMPT|ECE484|ECE463|ENGR446|ECON180} - \
             %^{PROMPT|Assignment|Midterm} %^{PROMPT} %^{PROMPT}\n \
             :PROPERTIES:\n \
             :CREATED:   %U\n \
             :DEADLINE:  %^t\n \
             :SCHEDULED: %^t\n \
             :END:\n \
             %?" :empty-lines-after 1))

If I trigger the capture (in GUI emacs) however this is what I see:
image

Presumably it should not look like this.
Like maybe I would expect the pre-programmed options for the prompt to appear sure, but not the % or ^ that is part of the capture template syntax. But maybe this is how it behaves? The org-capture documentation does not show an example.

Expectations aside the ^ that is part of the %^{PROMPT} appears to be triggering the org-pretty-entities for superscript.

Also for some reason there’s a whole bunch of spaces between the - and where the prompt for Assignment|Midterm is supposed to be. I guess this is a result of my formatting in my org-conf.el where I break the template across multiple lines.

image

As can be seen above the prompts do complete. The formatting is just jacked up and kind of an eye sore.

I did create a much simpler capture as a test:

 ("z" "Test capture" entry (file "~/.notes/test.org")
               "* TODO %^{PROMPT|Test1|Test2|Test3}\n \
                %?" :empty-lines-after 1)   

Which looks like this when triggered:
image

Which isn’t totally consistent with the other template. None of the pre-programmed options for the prompt are visible but the %? is.

Questions:

  1. Should I be seeing the %^ or the $? or even the prompt values in the capture template when it’s triggered?

  2. How should I be breaking a long capture template across multiple lines without formatting issues?

For context this is my org-capture-templates:

Presumably this is what is causing the goofy formatting.

My org-mode config

org-conf.el (6.7 KB)

I am sure I’ve not actually included all the necessary information to fully diagnose what is happening but I am jet lagged and as my template might suggest, I have class in the morning. So please bear with me.

Yes, it’s normal for capture templates to show the tokens before you fill them out.

And yeah, you’re putting a bunch of spaces in your string trying to make it match up with elisp indentation. You should just start each new line all the way to the left, it’s ugly but that’s how you write multiline strings. If you really hate how it looks you could have each line be it’s own string and join them together.

1 Like