2

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 1

2

(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).

1
  • Added an explanation to answer @Matt's question (which was incorrectly submitted as an answer).
    – NickD
    Commented Nov 27, 2023 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.