I'm looking to build a capture template that, when run, prompts the user for more information to determine the path of the target file.
I have a few pieces already.
A function which asks the user for data and returns a string:
(defun my/get-121-orgfile ()
"Ask the user for the name of the participant so that we can build"
(interactive)
(read-string "Participant Name: ")
)
An org-capture-template which will run the prompt successfully when emacs loads:
(setq org-capture-templates
`(
("m1" "1-1 meetings")
("m1b" "prep for a 1-1 meeting" entry
(file ,(concat "~/org/meetings/1-2-1/" (my/get-121-orgfile) ".org"))
(file "~/org/templates/meeting-121-prep.org")
:clock-in t)
))
I took the back quote and comma pattern from this SO answer, but I haven't been able to figure out how to scope this behaviour to when I select the template: I want the prompt to pop up each time I hit <org-capture>m1b.
The backquote-comma pattern will not help here: it will call the function at the time that
org-capture-templateis set. What you are trying to do is to call the function when the capture is executed.The only way I know to do that would to use the
(function foo)target mechanism oforg-capture-templates. The doc string says:So you would not be able to use the
(file ...)target as you do above. Instead you have to write a function that gets all the information you want and then visit the target file at the target location and add the filled-out template.This is not a complete answer but it was too long for a comment, but maybe it helps to point you in the right direction.