I want to design an org-capture definition that targets the current org file. Looking at the list of available targets it's not clear to me what I should use. Considering using (current-buffer) as the file name in the Target definition.
1 Answer
(file buffer-name)
will set the target to the current buffer. Here's an example capture template:
("T" "test" plain (file buffer-name) "\n- %?")
Explanation: The doc string for org-capture-templates
says:
... Most target specifications contain a file name. If that file name is the empty string, it defaults to ‘org-default-notes-file’. A file can also be given as a variable or as a function called with no argument.
Emphasis added.
In this case, the function is buffer-name
, which gives the file name associated with the current buffer (when called with no argument).
-
Added an explanation to answer @Matt's question (which was incorrectly submitted as an answer).– NickDCommented Nov 27, 2023 at 16:32