all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Org-capture %K "Link to the currently clocked task" link with id?
@ 2021-05-19 13:26 Nathaniel W Griswold
  2021-05-19 17:29 ` Nathaniel W Griswold
  0 siblings, 1 reply; 17+ messages in thread
From: Nathaniel W Griswold @ 2021-05-19 13:26 UTC (permalink / raw)
  To: emacs-orgmode

Looking at the source (org-capture.el), it appears org-capture doesn't allow you to make a permalink for "Link to the currently clocked task", or %K in your template.

`org-capture-fill-template` looks like this:

...
	 (v-K (if (marker-buffer org-clock-marker)
		  (org-link-make-string
		   (format "%s::*%s"
			   (buffer-file-name (marker-buffer org-clock-marker))
			   v-k)
		   v-k)
		""))
... 

So i guess it's hardcoded to just make a bracket link.

I guess i can hack something, but can you guys make a nice change to the source so that i can have a permalink to my clocked in task? Or is there something i'm missing and i can actually do it already?

Thank you

Nate

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

* Re: Org-capture %K "Link to the currently clocked task" link with id?
  2021-05-19 13:26 Org-capture %K "Link to the currently clocked task" link with id? Nathaniel W Griswold
@ 2021-05-19 17:29 ` Nathaniel W Griswold
  2021-05-24 12:25   ` Nathaniel W Griswold
  0 siblings, 1 reply; 17+ messages in thread
From: Nathaniel W Griswold @ 2021-05-19 17:29 UTC (permalink / raw)
  To: emacs-orgmode

Rereading my message, i realized it might not be clear what i mean here.

I use (org-id-link-to-org-use-id t) because i like to be able to still follow links after i archive stuff. I want that behavior here so i want the link to an `id:<UUID>` link instead of a `file:/path/to/file` link.

Nate

> On May 19, 2021, at 8:26 AM, Nathaniel W Griswold <nate@manicmind.earth> wrote:
> 
> Looking at the source (org-capture.el), it appears org-capture doesn't allow you to make a permalink for "Link to the currently clocked task", or %K in your template.
> 
> `org-capture-fill-template` looks like this:
> 
> ...
> 	 (v-K (if (marker-buffer org-clock-marker)
> 		  (org-link-make-string
> 		   (format "%s::*%s"
> 			   (buffer-file-name (marker-buffer org-clock-marker))
> 			   v-k)
> 		   v-k)
> 		""))
> ... 
> 
> So i guess it's hardcoded to just make a bracket link.
> 
> I guess i can hack something, but can you guys make a nice change to the source so that i can have a permalink to my clocked in task? Or is there something i'm missing and i can actually do it already?
> 
> Thank you
> 
> Nate



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

* Org-capture %K "Link to the currently clocked task" link with id?
  2021-05-19 17:29 ` Nathaniel W Griswold
@ 2021-05-24 12:25   ` Nathaniel W Griswold
  2021-05-29  8:10     ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Nathaniel W Griswold @ 2021-05-24 12:25 UTC (permalink / raw)
  To: emacs-orgmode

> 
> On May 19, 2021, at 8:26 AM, Nathaniel W Griswold <nate@manicmind.earth> wrote:
> 
> Looking at the source (org-capture.el), it appears org-capture doesn't allow you to make a permalink for "Link to the currently clocked task", or %K in your template.
> 
> I use (org-id-link-to-org-use-id t) because i like to be able to still follow links after i archive stuff. I want that behavior here so i want the link to an `id:<UUID>` link instead of a `file:/path/to/file` link.


Would a patch for this be welcome? Does anyone have any suggestions or ideas? I was thinking it should just respect current value of `org-id-link-to-org-use-id` but maybe there should be something more specific?

Thanks!

Nate

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

* Re: Org-capture %K "Link to the currently clocked task" link with id?
  2021-05-24 12:25   ` Nathaniel W Griswold
@ 2021-05-29  8:10     ` Ihor Radchenko
  2023-12-07 18:53       ` [PATCH] lisp/org-capture.el: use link ID's for %K Kenny Ballou
  0 siblings, 1 reply; 17+ messages in thread
From: Ihor Radchenko @ 2021-05-29  8:10 UTC (permalink / raw)
  To: Nathaniel W Griswold; +Cc: emacs-orgmode

Nathaniel W Griswold <nate@manicmind.earth> writes:
> Would a patch for this be welcome? Does anyone have any suggestions or ideas? I was thinking it should just respect current value of `org-id-link-to-org-use-id` but maybe there should be something more specific?

Sounds useful to me. Ideally, it would be even better to remove
hard-coded replacements in org-capture-fill-template and use some kind
of (?char . #'fill-function) alist to allow more flexibility.

Best,
Ihor


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

* [PATCH] lisp/org-capture.el: use link ID's for %K
  2021-05-29  8:10     ` Ihor Radchenko
@ 2023-12-07 18:53       ` Kenny Ballou
  2023-12-08 13:56         ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Kenny Ballou @ 2023-12-07 18:53 UTC (permalink / raw)
  To: yantar92; +Cc: emacs-orgmode, nate, Kenny Ballou

* org-capture.el (org-capture-fill-template): fill %K values using org
ID's if `org-id-link-to-org-use-id' is non-nil.
* doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.

Reported-by: Nathaniel W Griswold <nate@manicmind.earth>
Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
Link: https://list.orgmode.org/EF459D47-FCA4-4A18-AFC7-3E62159F186C@manicmind.earth/

TINYCHANGE
---
 etc/ORG-NEWS        |  8 ++++++++
 lisp/org-capture.el | 14 +++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 59c45b2aa..924ce43cc 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -539,6 +539,14 @@ Currently implemented options are:
   tasks this technically violates the iCalendar spec, but some
   iCalendar programs support this usage.
 
+*** Capture template expansion now supports ID links
+:PROPERTIES:
+:ID:       6f1f4f77-2b16-4a4d-8c84-fb7ba5ddf1e5
+:END:
+
+The capture template expansion element `%K' now creates links using
+the `ID' property of the currently clocked task if
+`org-id-link-to-use-org-id' is non-nil.
 ** New features
 *** =ob-plantuml.el=: Support tikz file format output
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index e482f667f..08fe34979 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1675,11 +1675,15 @@ Expansion occurs in a temporary Org mode buffer."
 		  (org-no-properties org-clock-heading)
 		""))
 	 (v-K (if (marker-buffer org-clock-marker)
-		  (org-link-make-string
-		   (format "%s::*%s"
-			   (buffer-file-name (marker-buffer org-clock-marker))
-			   v-k)
-		   v-k)
+                  (if org-id-link-to-org-use-id
+                      (org-link-make-string
+                       (format "id:%s" (org-id-get org-clock-marker))
+                       v-k)
+		    (org-link-make-string
+		     (format "%s::*%s"
+			     (buffer-file-name (marker-buffer org-clock-marker))
+			     v-k)
+		     v-k))
 		""))
 	 (v-f (or (org-capture-get :original-file-nondirectory) ""))
 	 (v-F (or (org-capture-get :original-file) ""))

base-commit: 3b719399036f44cbaabf399b3254d6ab3ba462d9
-- 
2.41.0



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

* Re: [PATCH] lisp/org-capture.el: use link ID's for %K
  2023-12-07 18:53       ` [PATCH] lisp/org-capture.el: use link ID's for %K Kenny Ballou
@ 2023-12-08 13:56         ` Ihor Radchenko
  2023-12-08 18:47           ` Kenny Ballou
  0 siblings, 1 reply; 17+ messages in thread
From: Ihor Radchenko @ 2023-12-08 13:56 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: yantar92, emacs-orgmode

Kenny Ballou <kb@devnulllabs.io> writes:

> * org-capture.el (org-capture-fill-template): fill %K values using org
> ID's if `org-id-link-to-org-use-id' is non-nil.
> * doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.

Thanks for the patch!

> +                  (if org-id-link-to-org-use-id
> +                      (org-link-make-string
> +                       (format "id:%s" (org-id-get org-clock-marker))
> +                       v-k)

`org-id-link-to-org-use-id' may have a number of non-nil values with
slightly different behaviour: t, create-if-interactive,
create-if-interactive-and-no-custom-id, use-existing, nil.

Your patch will only work as expected for t and nil values, but not for
others. You may consider leveraging `org-store-link' to account for all
the possibilities.

-- 
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] 17+ messages in thread

* Re: [PATCH] lisp/org-capture.el: use link ID's for %K
  2023-12-08 13:56         ` Ihor Radchenko
@ 2023-12-08 18:47           ` Kenny Ballou
  2023-12-08 19:01             ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Kenny Ballou @ 2023-12-08 18:47 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: yantar92, emacs-orgmode


On 2023-12-08 13:56 GMT, Ihor Radchenko wrote:
> Kenny Ballou <kb@devnulllabs.io> writes:
>> +                  (if org-id-link-to-org-use-id
>> +                      (org-link-make-string
>> +                       (format "id:%s" (org-id-get org-clock-marker))
>> +                       v-k)
>
> `org-id-link-to-org-use-id' may have a number of non-nil values with
> slightly different behaviour: t, create-if-interactive,
> create-if-interactive-and-no-custom-id, use-existing, nil.
>
> Your patch will only work as expected for t and nil values, but not for
> others. You may consider leveraging `org-store-link' to account for all
> the possibilities.

This worked for the value of `use-existing', which is how I tested it.
But I see your point, the behavior should be more flexible to the other
values of `org-id-link-to-org-use-id'.

I'm currently struggling through modifying it to work with
`org-store-link'.  Something, save-excursion -> org-clock-goto ->
org-store-link -> org-insert-link is what I'm trying for now, but that's
not quite working.  I'll come back to this in a few hours.

If you have any other specific suggestions I'm missing, please let me
know.  Otherwise, look for a new patch, hopefully soon!

--
-Kenny


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

* Re: [PATCH] lisp/org-capture.el: use link ID's for %K
  2023-12-08 18:47           ` Kenny Ballou
@ 2023-12-08 19:01             ` Ihor Radchenko
  2023-12-09 22:53               ` Kenny Ballou
  0 siblings, 1 reply; 17+ messages in thread
From: Ihor Radchenko @ 2023-12-08 19:01 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: yantar92, emacs-orgmode

Kenny Ballou <kb@devnulllabs.io> writes:

> I'm currently struggling through modifying it to work with
> `org-store-link'.  Something, save-excursion -> org-clock-goto ->
> org-store-link -> org-insert-link is what I'm trying for now, but that's
> not quite working.  I'll come back to this in a few hours.

The last step is unnecessary. You may just examine `org-stored-links'
(documented in the docstring of `org-store-link') or
`org-store-link-plist' (undocumented, but containing more info and also
used by `org-capture-fill-template').

-- 
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] 17+ messages in thread

* Re: [PATCH] lisp/org-capture.el: use link ID's for %K
  2023-12-08 19:01             ` Ihor Radchenko
@ 2023-12-09 22:53               ` Kenny Ballou
  2023-12-10 12:19                 ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Kenny Ballou @ 2023-12-09 22:53 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: yantar92, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 934 bytes --]


On 2023-12-08 19:01 GMT, Ihor Radchenko wrote:
> Kenny Ballou <kb@devnulllabs.io> writes:
>
>> I'm currently struggling through modifying it to work with
>> `org-store-link'.  Something, save-excursion -> org-clock-goto ->
>> org-store-link -> org-insert-link is what I'm trying for now, but that's
>> not quite working.  I'll come back to this in a few hours.
>
> The last step is unnecessary. You may just examine `org-stored-links'
> (documented in the docstring of `org-store-link') or
> `org-store-link-plist' (undocumented, but containing more info and also
> used by `org-capture-fill-template').

I ended up using `org-store-link-plist'.  For some reason that I don't
understand, the `save-excursion' -> `org-store-link' was not updating
`org-stored-links'.  Similarly, I had to use `save-window-excursion' or
the `org-clock-goto' would really break things.

If there's a better approach for getting the link, I'm all ears.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-org-capture.el-use-link-ID-s-for-K.patch --]
[-- Type: text/x-patch, Size: 2500 bytes --]

From e618508cdfbf899b93d5081aeec3eda18d5bd306 Mon Sep 17 00:00:00 2001
From: Kenny Ballou <kb@devnulllabs.io>
Date: Thu, 7 Dec 2023 10:29:46 -0700
Subject: [PATCH] lisp/org-capture.el: use link ID's for %K

* org-capture.el (org-capture-fill-template): fill %K values using org
ID's if `org-id-link-to-org-use-id' is non-nil.
* doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.

Reported-by: Nathaniel W Griswold <nate@manicmind.earth>
Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
Link: https://list.orgmode.org/EF459D47-FCA4-4A18-AFC7-3E62159F186C@manicmind.earth/

TINYCHANGE
---
 etc/ORG-NEWS        |  8 ++++++++
 lisp/org-capture.el | 16 +++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 59c45b2aa..924ce43cc 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -539,6 +539,14 @@ Currently implemented options are:
   tasks this technically violates the iCalendar spec, but some
   iCalendar programs support this usage.
 
+*** Capture template expansion now supports ID links
+:PROPERTIES:
+:ID:       6f1f4f77-2b16-4a4d-8c84-fb7ba5ddf1e5
+:END:
+
+The capture template expansion element `%K' now creates links using
+the `ID' property of the currently clocked task if
+`org-id-link-to-use-org-id' is non-nil.
 ** New features
 *** =ob-plantuml.el=: Support tikz file format output
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index e482f667f..5bb65de53 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1675,11 +1675,17 @@ Expansion occurs in a temporary Org mode buffer."
 		  (org-no-properties org-clock-heading)
 		""))
 	 (v-K (if (marker-buffer org-clock-marker)
-		  (org-link-make-string
-		   (format "%s::*%s"
-			   (buffer-file-name (marker-buffer org-clock-marker))
-			   v-k)
-		   v-k)
+                  (if (and (org-clock-is-active) org-id-link-to-org-use-id)
+                      (save-window-excursion
+                        (org-clock-goto)
+                        (org-store-link nil)
+                        (let ((link (plist-get org-store-link-plist :link)))
+                          (org-link-make-string link v-k)))
+		    (org-link-make-string
+		     (format "%s::*%s"
+			     (buffer-file-name (marker-buffer org-clock-marker))
+			     v-k)
+		     v-k))
 		""))
 	 (v-f (or (org-capture-get :original-file-nondirectory) ""))
 	 (v-F (or (org-capture-get :original-file) ""))

base-commit: 282c0fb6d1d2e6289a5b535a7ee9888f845b760b
-- 
2.41.0


[-- Attachment #3: Type: text/plain, Size: 12 bytes --]


-- 
-Kenny

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

* Re: [PATCH] lisp/org-capture.el: use link ID's for %K
  2023-12-09 22:53               ` Kenny Ballou
@ 2023-12-10 12:19                 ` Ihor Radchenko
  2023-12-11 15:33                   ` Kenny Ballou
                                     ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Ihor Radchenko @ 2023-12-10 12:19 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: yantar92, emacs-orgmode

Kenny Ballou <kb@devnulllabs.io> writes:

>> The last step is unnecessary. You may just examine `org-stored-links'
>> (documented in the docstring of `org-store-link') or
>> `org-store-link-plist' (undocumented, but containing more info and also
>> used by `org-capture-fill-template').
>
> I ended up using `org-store-link-plist'.  For some reason that I don't
> understand, the `save-excursion' -> `org-store-link' was not updating
> `org-stored-links'.

I can see it from the code now. Basically, instead of updating
`org-stored-links', `org-store-link' returns the link when called
non-interactively (with nil INTERACTIVE? argument).
Now documented on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5e809903d

> ... Similarly, I had to use `save-window-excursion' or
> the `org-clock-goto' would really break things.

You should not use `org-clock-goto' - it is intended for interactive use
and does a lot of unnecessary work.
You may instead do (org-with-point-at org-clock-marker ...)

-- 
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] 17+ messages in thread

* Re: [PATCH] lisp/org-capture.el: use link ID's for %K
  2023-12-10 12:19                 ` Ihor Radchenko
@ 2023-12-11 15:33                   ` Kenny Ballou
  2023-12-11 15:46                   ` Kenny Ballou
       [not found]                   ` <20231211154357.23020-1-kb@devnulllabs.io>
  2 siblings, 0 replies; 17+ messages in thread
From: Kenny Ballou @ 2023-12-11 15:33 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: yantar92, emacs-orgmode


On 2023-12-10 12:19 GMT, Ihor Radchenko wrote:
> Kenny Ballou <kb@devnulllabs.io> writes:
>
>>
>> I ended up using `org-store-link-plist'.  For some reason that I don't
>> understand, the `save-excursion' -> `org-store-link' was not updating
>> `org-stored-links'.
>
> I can see it from the code now. Basically, instead of updating
> `org-stored-links', `org-store-link' returns the link when called
> non-interactively (with nil INTERACTIVE? argument).
> Now documented on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5e809903d

Thank you for this!

>
>> ... Similarly, I had to use `save-window-excursion' or
>> the `org-clock-goto' would really break things.
>
> You should not use `org-clock-goto' - it is intended for interactive use
> and does a lot of unnecessary work.
> You may instead do (org-with-point-at org-clock-marker ...)

Yes, it felt heavy handed, and I haven't quite figured out how to query
the current set of functions for desired functionality.  Thank you for
your patience in this process, I believe it has really simplified the
change and the resulting patch (to follow).

Using your suggestions, I believe we can simply grab the link from
`org-store-link' and use it (almost) directly as the value of %K.
Furthermore, we do not need to branch off `org-id-link-to-use-id'
because the correct behavior is captured by `org-store-link'.

My remaining question is whether I should use `current-prefix-arg' or
not?  I'm not sure if that would be surprising or not, or if it would
even get to `org-store-link' when doing a capture.

-- 
-Kenny


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

* [PATCH] lisp/org-capture.el: use link ID's for %K
  2023-12-10 12:19                 ` Ihor Radchenko
  2023-12-11 15:33                   ` Kenny Ballou
@ 2023-12-11 15:46                   ` Kenny Ballou
       [not found]                   ` <20231211154357.23020-1-kb@devnulllabs.io>
  2 siblings, 0 replies; 17+ messages in thread
From: Kenny Ballou @ 2023-12-11 15:46 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Kenny Ballou, Nathaniel W Griswold

* org-capture.el (org-capture-fill-template): fill %K values using link
value from `org-store-link', which respects `org-id-link-to-use-id'.
* doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.

Reported-by: Nathaniel W Griswold <nate@manicmind.earth>
Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
Link: https://list.orgmode.org/EF459D47-FCA4-4A18-AFC7-3E62159F186C@manicmind.earth/

TINYCHANGE
---
 etc/ORG-NEWS        | 6 ++++++
 lisp/org-capture.el | 8 +++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 9328f333c..55ab2453c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -539,6 +539,12 @@ Currently implemented options are:
   tasks this technically violates the iCalendar spec, but some
   iCalendar programs support this usage.
 
+*** Capture template expansion now supports ID links
+
+The capture template expansion element `%K' creates links using
+`org-store-link', which respects the values of
+`org-id-link-to-use-id'.
+
 ** New features
 *** =ob-plantuml.el=: Support tikz file format output
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index e482f667f..ee86a3ee0 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1675,11 +1675,9 @@ Expansion occurs in a temporary Org mode buffer."
 		  (org-no-properties org-clock-heading)
 		""))
 	 (v-K (if (marker-buffer org-clock-marker)
-		  (org-link-make-string
-		   (format "%s::*%s"
-			   (buffer-file-name (marker-buffer org-clock-marker))
-			   v-k)
-		   v-k)
+                  (save-excursion
+                    (org-with-point-at org-clock-marker
+                      (substring-no-properties (org-store-link current-prefix-arg nil))))
 		""))
 	 (v-f (or (org-capture-get :original-file-nondirectory) ""))
 	 (v-F (or (org-capture-get :original-file) ""))

base-commit: 420ed4e0338d12e26c62d3666ca39e7cff323d05
-- 
2.41.0



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

* Re: [PATCH] lisp/org-capture.el: use link ID's for %K
       [not found]                     ` <87ttoo7dna.fsf@localhost>
@ 2023-12-11 21:21                       ` Kenny Ballou
  2023-12-12  4:13                         ` [PATCH] lisp/org-capture.el: use `org-store-link' for %K values Kenny Ballou
  0 siblings, 1 reply; 17+ messages in thread
From: Kenny Ballou @ 2023-12-11 21:21 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode, yantar92


On 2023-12-11 19:16 GMT, Ihor Radchenko wrote:
>
>> +*** Capture template expansion now supports ID links
>> +
>> +The capture template expansion element `%K' creates links using
>> +`org-store-link', which respects the values of
>> +`org-id-link-to-use-id'.
>
> Here, we simply use Org markup. So, =%K=, ~org-store-link~, and ~org-id-link-to-use-id~.
> See doc/Documentation_Standards.org for details.

I'll update for the new patch version.

>
>> +                  (save-excursion
>
> `save-excursion' should be unnecessary here. `org-with-point-at' already
> takes care about restoring window configuration and point.
>

Correct, I'll remove it.  The patch is now much simpler :)

>> +                    (org-with-point-at org-clock-marker
>> +                      (substring-no-properties (org-store-link current-prefix-arg nil))))
>>  		""))
>
> Using `current-prefix-arg' is incorrect here.
> `org-capture-fill-template' is called from `org-capture' that assigns a
> completely different meaning to the prefix argument (see the
> docstring).
>

Okay, I'll pass `nil' instead.  I'm not sure any other value makes
sense.

> Also, why `substring-no-properties'?

I figured the link should not come with the face properties inherited
from `org-store-link'.  If that's incorrect, I'll drop it.  It seems to
work either way.

-- 
-Kenny


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

* [PATCH] lisp/org-capture.el: use `org-store-link' for %K values
  2023-12-11 21:21                       ` Kenny Ballou
@ 2023-12-12  4:13                         ` Kenny Ballou
  2023-12-12  4:32                           ` Kenny Ballou
  0 siblings, 1 reply; 17+ messages in thread
From: Kenny Ballou @ 2023-12-12  4:13 UTC (permalink / raw)
  To: yantar92; +Cc: emacs-orgmode, yantar92, Kenny Ballou, Nathaniel W Griswold

* org-capture.el (org-capture-fill-template): fill %K values using link
value from `org-store-link', which respects `org-id-link-to-use-id'.
* doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.

Reported-by: Nathaniel W Griswold <nate@manicmind.earth>
Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
Link: https://list.orgmode.org/EF459D47-FCA4-4A18-AFC7-3E62159F186C@manicmind.earth/

TINYCHANGE
---
 etc/ORG-NEWS        | 5 +++++
 lisp/org-capture.el | 7 ++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 9328f333c..9858df045 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -539,6 +539,11 @@ Currently implemented options are:
   tasks this technically violates the iCalendar spec, but some
   iCalendar programs support this usage.
 
+*** Capture template expansion now supports ID links
+
+The capture template expansion element =%K= creates links using
+~org-store-link~, which respects the values of ~org-id-link-to-use-id~.
+
 ** New features
 *** =ob-plantuml.el=: Support tikz file format output
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index e482f667f..73ea9d1df 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1675,11 +1675,8 @@ Expansion occurs in a temporary Org mode buffer."
 		  (org-no-properties org-clock-heading)
 		""))
 	 (v-K (if (marker-buffer org-clock-marker)
-		  (org-link-make-string
-		   (format "%s::*%s"
-			   (buffer-file-name (marker-buffer org-clock-marker))
-			   v-k)
-		   v-k)
+                  (org-with-point-at org-clock-marker
+                    (org-store-link current-prefix-arg nil))
 		""))
 	 (v-f (or (org-capture-get :original-file-nondirectory) ""))
 	 (v-F (or (org-capture-get :original-file) ""))

base-commit: 420ed4e0338d12e26c62d3666ca39e7cff323d05
-- 
2.41.0



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

* (no subject)
  2023-12-12  4:13                         ` [PATCH] lisp/org-capture.el: use `org-store-link' for %K values Kenny Ballou
@ 2023-12-12  4:32                           ` Kenny Ballou
  2023-12-12  4:32                             ` [PATCH] lisp/org-capture.el: use `org-store-link' for %K values Kenny Ballou
  0 siblings, 1 reply; 17+ messages in thread
From: Kenny Ballou @ 2023-12-12  4:32 UTC (permalink / raw)
  To: yantar92; +Cc: emacs-orgmode, yantar92


Forgive for the noise, I just double checked the patch and noticed the `current-prefix-arg' was still being used.  Fixed.



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

* [PATCH] lisp/org-capture.el: use `org-store-link' for %K values
  2023-12-12  4:32                           ` Kenny Ballou
@ 2023-12-12  4:32                             ` Kenny Ballou
  2023-12-12 12:46                               ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Kenny Ballou @ 2023-12-12  4:32 UTC (permalink / raw)
  To: yantar92; +Cc: emacs-orgmode, yantar92, Kenny Ballou, Nathaniel W Griswold

* org-capture.el (org-capture-fill-template): fill %K values using link
value from `org-store-link', which respects `org-id-link-to-use-id'.
* doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.

Reported-by: Nathaniel W Griswold <nate@manicmind.earth>
Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
Link: https://list.orgmode.org/EF459D47-FCA4-4A18-AFC7-3E62159F186C@manicmind.earth/

TINYCHANGE
---
 etc/ORG-NEWS        | 5 +++++
 lisp/org-capture.el | 7 ++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 9328f333c..9858df045 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -539,6 +539,11 @@ Currently implemented options are:
   tasks this technically violates the iCalendar spec, but some
   iCalendar programs support this usage.
 
+*** Capture template expansion now supports ID links
+
+The capture template expansion element =%K= creates links using
+~org-store-link~, which respects the values of ~org-id-link-to-use-id~.
+
 ** New features
 *** =ob-plantuml.el=: Support tikz file format output
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index e482f667f..4bbe2c43a 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1675,11 +1675,8 @@ Expansion occurs in a temporary Org mode buffer."
 		  (org-no-properties org-clock-heading)
 		""))
 	 (v-K (if (marker-buffer org-clock-marker)
-		  (org-link-make-string
-		   (format "%s::*%s"
-			   (buffer-file-name (marker-buffer org-clock-marker))
-			   v-k)
-		   v-k)
+                  (org-with-point-at org-clock-marker
+                    (org-store-link nil nil))
 		""))
 	 (v-f (or (org-capture-get :original-file-nondirectory) ""))
 	 (v-F (or (org-capture-get :original-file) ""))

base-commit: 420ed4e0338d12e26c62d3666ca39e7cff323d05
-- 
2.41.0



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

* Re: [PATCH] lisp/org-capture.el: use `org-store-link' for %K values
  2023-12-12  4:32                             ` [PATCH] lisp/org-capture.el: use `org-store-link' for %K values Kenny Ballou
@ 2023-12-12 12:46                               ` Ihor Radchenko
  0 siblings, 0 replies; 17+ messages in thread
From: Ihor Radchenko @ 2023-12-12 12:46 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: emacs-orgmode, yantar92

Kenny Ballou <kb@devnulllabs.io> writes:

> * org-capture.el (org-capture-fill-template): fill %K values using link
> value from `org-store-link', which respects `org-id-link-to-use-id'.
> * doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.
>
> Reported-by: Nathaniel W Griswold <nate@manicmind.earth>
> Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
> Link: https://list.orgmode.org/EF459D47-FCA4-4A18-AFC7-3E62159F186C@manicmind.earth/

Thanks!
Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ac8b92540

You are now also listed as an Org contributor.
https://git.sr.ht/~bzg/worg/commit/dda15239

-- 
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] 17+ messages in thread

end of thread, other threads:[~2023-12-12 12:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-19 13:26 Org-capture %K "Link to the currently clocked task" link with id? Nathaniel W Griswold
2021-05-19 17:29 ` Nathaniel W Griswold
2021-05-24 12:25   ` Nathaniel W Griswold
2021-05-29  8:10     ` Ihor Radchenko
2023-12-07 18:53       ` [PATCH] lisp/org-capture.el: use link ID's for %K Kenny Ballou
2023-12-08 13:56         ` Ihor Radchenko
2023-12-08 18:47           ` Kenny Ballou
2023-12-08 19:01             ` Ihor Radchenko
2023-12-09 22:53               ` Kenny Ballou
2023-12-10 12:19                 ` Ihor Radchenko
2023-12-11 15:33                   ` Kenny Ballou
2023-12-11 15:46                   ` Kenny Ballou
     [not found]                   ` <20231211154357.23020-1-kb@devnulllabs.io>
     [not found]                     ` <87ttoo7dna.fsf@localhost>
2023-12-11 21:21                       ` Kenny Ballou
2023-12-12  4:13                         ` [PATCH] lisp/org-capture.el: use `org-store-link' for %K values Kenny Ballou
2023-12-12  4:32                           ` Kenny Ballou
2023-12-12  4:32                             ` [PATCH] lisp/org-capture.el: use `org-store-link' for %K values Kenny Ballou
2023-12-12 12:46                               ` 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.