all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] lisp/org-capture.el: Restore org-store-link-plist
@ 2024-05-17 11:38 Anand Deopurkar
  2024-05-18 10:56 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Anand Deopurkar @ 2024-05-17 11:38 UTC (permalink / raw)
  To: emacs-orgmode

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-lisp-org-capture.el-Restore-org-store-link-plist.patch --]
[-- Type: text/x-patch, Size: 2048 bytes --]

From 8f603b721ddd7edf1e622a39dc80f4b74a5b5198 Mon Sep 17 00:00:00 2001
From: Anand Deopurkar <anandrdeopurkar@gmail.com>
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
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lisp/org-capture.el: Restore org-store-link-plist
  2024-05-17 11:38 [PATCH] lisp/org-capture.el: Restore org-store-link-plist Anand Deopurkar
@ 2024-05-18 10:56 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-05-18 10:56 UTC (permalink / raw)
  To: Anand Deopurkar; +Cc: emacs-orgmode

Anand Deopurkar <anandrdeopurkar@gmail.com> writes:

> From 8f603b721ddd7edf1e622a39dc80f4b74a5b5198 Mon Sep 17 00:00:00 2001
> From: Anand Deopurkar <anandrdeopurkar@gmail.com>
> Date: Fri, 17 May 2024 20:39:51 +1000
> Subject: [PATCH] lisp/org-capture.el: Restore org-store-link-plist

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0ebb36cae
Thanks for your contribution!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-18 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 11:38 [PATCH] lisp/org-capture.el: Restore org-store-link-plist Anand Deopurkar
2024-05-18 10:56 ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.