0

With the cursor on a file link, I'd like to set up an org-capture template which inserts the template into the target of the link.

I guess I add something like

(setq org-capture-templates 
   '(("m" "Topic"
       entry
       (file (get-path-to-link-target-at-point))
       "\n* Topic %?")))

to my init.el in order to achieve what I'm looking for. But I'm not able to code such a function get-path-to-link-target-at-point. So how do I get the file path of a link target at my cursor location?

2
  • Is the problem the coding part (about which I would recommend googling) or the fact that the get-path-to-link-target-at-point function is not "called"? Commented Dec 14, 2019 at 2:01
  • The function was not being called, if I recall correctly.
    – vdegner
    Commented Dec 26, 2019 at 8:48

1 Answer 1

1

The content of org-capture-templates is basically a series of forms that are not evaluated. That is why you put the quote.

This means that in order to call that function you would need to add a comma to unquote and possibly a backtick.

This is what I do in mine code usually:

(setq org-capture-templates 
   `(("m" "Topic"
       entry
       (file ,(get-path-to-link-target-at-point))
       "\n* Topic %?")))

Hope it helps.

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.