lisp/org-capture.el: Restore org-store-link-plist

* org-capture.el (org-capture-fill-template): Restore original
`org-store-link-plist' after calling `org-store-link'.

To replace a %K escape (link to currently clocked task),
`org-capture-fill-template' calls `org-store-link'.  This call has the
side-effect of replacing the contents of `org-store-link-plist'.  As a
result, expected template expansions using the original
`org-store-link-plist' do not happen.

For example, suppose `org-capture' is called from a message buffer with the
template "%:subject %:from" while the clock is running.  Then
%:subject and %:from are not substituted because of the behaviour
above.  If the clock is not running, there is no problem.

Current fix restores `org-store-link-plist' to its original value
after `org-capture-fill-template' calls `org-store-link'.

TINYCHANGE
This commit is contained in:
Anand Deopurkar 2024-05-17 20:39:51 +10:00 committed by Ihor Radchenko
parent ee58259bc7
commit 0ebb36caea
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 3 deletions

View File

@ -1675,9 +1675,12 @@ Expansion occurs in a temporary Org mode buffer."
(org-no-properties org-clock-heading)
""))
(v-K (if (marker-buffer org-clock-marker)
(org-with-point-at org-clock-marker
(org-store-link nil nil))
""))
(let ((original-link-plist org-store-link-plist)
(clocked-task-link (org-with-point-at org-clock-marker
(org-store-link nil nil))))
(setq org-store-link-plist original-link-plist)
clocked-task-link)
""))
(v-f (or (org-capture-get :original-file-nondirectory) ""))
(v-F (or (org-capture-get :original-file) ""))
(org-capture--clipboards