i want to capture into a datetree inside the current buffer. Below is my snippet. But unfortunately it doesn't work. Always an error: org-capture-expand-file: Invalid file location: nil

I use emacs 28 with Org 9.4 on Linux Fedora34.

("a" "Datetree in act. Buffer"
       entry (file+olp+datetree (buffer-file-name))
       "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\nAdded: %U"
   :empty-lines 1
       :tree-type week)

Does anybody know, how to fix it? The function (buffer-file-name) returns the correct filename with path, exactly like i wrote it as string.

Regards Poul

  • 2
    You want to pass the function itself, not the result of its evaluation. Try (file+olp+datetree buffer-file-name).
    – NickD
    Jun 15 at 16:34
  • Wonderful! Works. Thank you.
    – space_held
    Jun 15 at 18:24
  • Sorry, but i do not understand how to accept your answer.
    – space_held
    Jun 15 at 18:43
  • I made it a comment, not an answer, because it was short and I didn't have to think much about how to make it into an answer :-) So, yes,you can't accept it, but that's OK: don't worry about it. If I find some time, I'll come back and make it into a proper answer. Glad it worked!
    – NickD
    Jun 15 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.