From 0ebb36caeafddb8245ac2ef261ab96a91281f8bd Mon Sep 17 00:00:00 2001 From: Anand Deopurkar Date: Fri, 17 May 2024 20:39:51 +1000 Subject: [PATCH] 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 --- lisp/org-capture.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index da14f45c0..9d8f855ef 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -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