I have been using the code below to set a
SOURCE property on captures. If you add
:source t to the template then the
SOURCE property will set to the captures
:annotation (the same as the
%a template parameter). A nice accidental features is that
C-c C-o will find this link in the org file or the agenda.
(defvar org-source-property "SOURCE"
"The property used to store the source of the capture.")
(defvar org-capture-default-source :annotation
"The default org-capture property to get the source from.")
(defun org-capture-source-process-source (source)
"Process the input SOURCE into a string.
This is called by `org-capture-set-source' just before passing
the result into `org-set-property'. It must return a string."
(format "%s" source))
(defun org-capture-set-source (&optional source global)
"Set the source of a captured item.
If the input argument SOURCE is provided and non-nil, set the
source to that. Otherwise look at the :source property of
`org-capture-plist' are parse it as follows.
If :source is nil do nothing.
If :source is a string take that as the source.
If :source is a form evaluate it and take that as the source.
If :source is just t, use the default property (`org-capture-default-source')
Otherwise assume it is property and look it up in `org-capture-plist'.
This function is intended to be called from
`org-capture-current-plist' is still valid. To use the global
capture date instead, set GLOBAL to t."
(let* ((local (not global))
(source (or source (org-capture-get :source local)))
(cond ((stringp source) source)
((listp source) (eval source))
((eq source t) (org-capture-get
(t (org-capture-get source local))
(add-hook 'org-capture-before-finalize-hook #'org-capture-set-source)