I am beginning to use org-mode as an electronic lab notebook, which is working very well. I work on a number of different projects, each of which has its own directory. When I use org-capture, I want the task, etc., to be written to an .org
file in the directory for the current project.
So if I am working in my org lab notebook for Project A and I capture a task, I want that task to go to the capture.org file in the directory for Project A, but when I capture a task from my notebook for Project B, I want the task written to capture.org in that directory instead.
It seems like I could do this with different templates, using something along these lines.
(setq org-capture-templates
'(("t" "Todo" entry (file "~/project_a/capture.org")...)
("u" "Todo" entry (file "~/project_b/capture.org")...)
("v" "Todo" entry (file "~/project_c/capture.org")...)))
The downside of this is that I have to remember or check a lot of different templates each time, making it more distracting to capture something, especially when I'm working on a lot of different projects.
An alternative would be to always insert the capture into the buffer I'm currently working on, but I'd rather not do that.
I think I could also just have a small piece of executable code at the beginning of each notebook that defines all the captures, but there must be a better way than that.
I suspect that there may be some way to do this by giving the target as a function, but I can't figure out how to do that, and I'm not sure whether it's the best way.
What would be ideal is that any capture done in ~/project_a
or any of its subdirectories would go to ~/project_a/capture.org
, but I can easily live with the customization applying only to the specific file (~/project_a/notebook.org
) that I use as my notebooks, since I'll almost always have that open.