(defun insert-property(&optional p)
"insert PROPERTY value of pdftools link"
(unless p (setq p "TEST"))
(message "property passed is: %s" p)
(let ((pvalue
(save-window-excursion
(message "%s" (org-capture-get :original-buffer))
(switch-to-buffer (org-capture-get :original-buffer))
(message "retrieved property is: %s" (org-entry-get (point) p))
(org-entry-get (point) p)
)))
pvalue))
I don't think you need any (insert x)
call for a start: the function itself should not insert the string - it should just return it.
I had a fiddle and came up with the above function, just to satisfy my own curiosity. I hope it helps. I used org-capture-get
and also (point)
but maybe that's an alternative way.
Just add %(insert-property "TEST")%
in my capture template.
Test data:-
*** scratchpad :tangle no:noexport:
:PROPERTIES:
:TEST: HELLO WORLD
:END:
My template:-
("t" "Todo" entry
(file+headline "refile.org" "Tasks To Refile")
"* TODO %? %(insert-property "TEST")%
:PROPERTIES:
:DateCreated: %T
:END:
")