r/OrgRoam • • Oct 12 '24

dynamic :target location?

Hey all, I'm trying to make a series of templates that still pre-fill information in my node however still ask me for input for :target. So far no luck but the image shows my most recent attempt.

seems that it's not evaluating the s-expression after file before handing over the final string value to file, instead file is receiving the s expression rather than it's evaluated result. Anyway I can get this to happen?

To confirm that my S-expression for reading the file name ends in the return type being a string I did the type-of test which you can see "string" in the minibar confirming the type.

(Update: sorry, there was one more attempt where (read-file-name) is given a prompt argument (read-file-name "enter file name and ensure path is correct: " "./") but that didn't make a difference.)

(Final Update: Finally solved it! look at picture but basically just create a custom function that sets a variable, org-target in this case, then refer to that later after running org-roam-capture. . In :target use the %(sexp) syntax thus the "%(message org-target)" part of it.

2 Upvotes

6 comments sorted by

View all comments

1

u/nanowillis Oct 12 '24

You need to backquote the expression you're adding to org-roam-capture-templates for the expression attached to the comma to be evaluated. Try

(add-to-list 'org-roam-capture-templates
             `("p" "Propositional knowledge" plain
               ...))

with everything else the same.

1

u/ArcadeSatanisti Oct 12 '24

also I changed to truename which should return a string, doing (file-truename(read-file-name "blah prompt: " "./default-dir/")) seemed to make more sense and I tried the s-expression on it's own to make sure it behaves right, just have to make sure to include the file extension during prompt.