0

My goal is to get org-capture to store captured notes in a local "notes.org" file located in the same directory as the current working buffer.

I set the template like so:

(setq org-capture-templates
       '(("x"
     "local notes" entry (file+headline (concat ,(file-name-directory buffer-file-name) "notes.org") "Copied regions")
     "* %^{Title} %U \n %i")
    )
       )

Alas, when invoking the template i get Invalid file location: nil.

How should this be done?

2

As the docs say, you can supply a function (with no arguments) to set the file here. Thus:

(setq org-capture-templates
   '(("x"  "local notes" entry 
     (file+headline (lambda () (concat (file-name-directory buffer-file-name) "notes.org")) "Copied regions")
       "* %^{Title} %U \n %i")
))

does the job.

  • Many thanks! How come (concat (file-name-directory buffer-file-name) "notes.org") is not accapted as a function? – Erik Jun 21 '18 at 7:46
  • Because it isn't a function! Functions are either pre-defined using defun or on the fly with lambda. – Fran Burstall Jun 21 '18 at 18:09

Your Answer

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

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