emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Force creation of org id in template
@ 2020-10-26 18:26 Michael Heerdegen
  2020-10-26 19:24 ` gusbrs.2016
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2020-10-26 18:26 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

is it possible to tweak `org-capture-templates' entries so that the
creation of an org id for an org entry created with `org-capture' is
forced?

TIA,

Michael.


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

* Re: Force creation of org id in template
  2020-10-26 18:26 Force creation of org id in template Michael Heerdegen
@ 2020-10-26 19:24 ` gusbrs.2016
  2020-10-26 21:33   ` Michael Heerdegen
  0 siblings, 1 reply; 6+ messages in thread
From: gusbrs.2016 @ 2020-10-26 19:24 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: emacs-orgmode

Hi Michael,

On Mon, 26 Oct 2020 at 19:26, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> is it possible to tweak `org-capture-templates' entries so that the
> creation of an org id for an org entry created with `org-capture' is
> forced?

Untested, but how about adding something like the following to your template?

:PROPERTIES:
:ID: %(org-id-new)
:END:

HTH,
Gustavo.


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

* Re: Force creation of org id in template
  2020-10-26 19:24 ` gusbrs.2016
@ 2020-10-26 21:33   ` Michael Heerdegen
  2020-10-26 22:40     ` Gustavo Barros
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2020-10-26 21:33 UTC (permalink / raw)
  To: emacs-orgmode

gusbrs.2016@gmail.com writes:

> Untested, but how about adding something like the following to your
> template?
>
> :PROPERTIES:
> :ID: %(org-id-new)
> :END:

I'm not sure.  I see that creating an id involves slightly more than
adding the property - see the `org-id-add-location' call in
`org-id-get'.  Calling the higher level `org-id-get' or the like in a
%() spec in a template fails however, since when it's called a temp
buffer not associated with a file is current.

And then I'm also not sure if the above is always secure when something
else in the template spec wants to add a (different) property.  Do you
know?

Thanks,

Michael.



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

* Re: Force creation of org id in template
  2020-10-26 21:33   ` Michael Heerdegen
@ 2020-10-26 22:40     ` Gustavo Barros
  2020-10-26 23:30       ` Gustavo Barros
  0 siblings, 1 reply; 6+ messages in thread
From: Gustavo Barros @ 2020-10-26 22:40 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: emacs-orgmode


On Mon, 26 Oct 2020 at 22:33, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> I'm not sure.  I see that creating an id involves slightly more than
> adding the property - see the `org-id-add-location' call in
> `org-id-get'.  Calling the higher level `org-id-get' or the like in a
> %() spec in a template fails however, since when it's called a temp
> buffer not associated with a file is current.
>
> And then I'm also not sure if the above is always secure when something
> else in the template spec wants to add a (different) property.  Do you
> know?

Not really.  `org-id' usually "just works" for me, so I never had to dig
anything deeper there.  But, as far as I recall, this is meant to add
the new ID on the IDs file.  Considering your capture template is likely
to be on your agenda files, this is probably not going to be of
concern (meaning here these files will eventually be scanned and the ID
found).  But, if it is, you could then go with `%(org-id-get nil t)`,
right?  It does seem to be more appropriate either way, I agree.

I have stored here in my init file a message from the list describing
the procedure Org uses to try to find an ID, you might find it useful:
https://lists.gnu.org/archive/html/emacs-orgmode/2009-11/msg01195.html

Regarding the second issue, of course, you should end up with a single
properties drawer, and the template should ensure that.

Best,
Gustavo.


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

* Re: Force creation of org id in template
  2020-10-26 22:40     ` Gustavo Barros
@ 2020-10-26 23:30       ` Gustavo Barros
  2020-10-27  6:12         ` Colin Baxter
  0 siblings, 1 reply; 6+ messages in thread
From: Gustavo Barros @ 2020-10-26 23:30 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: emacs-orgmode


On Mon, 26 Oct 2020 at 19:40, Gustavo Barros <gtvbrs@gmail.com> wrote:

> On Mon, 26 Oct 2020 at 22:33, Michael Heerdegen <michael_heerdegen@web.de> wrote:
>
>> I'm not sure.  I see that creating an id involves slightly more than
>> adding the property - see the `org-id-add-location' call in
>> `org-id-get'.  Calling the higher level `org-id-get' or the like in a
>> %() spec in a template fails however, since when it's called a temp
>> buffer not associated with a file is current.
>>
>> And then I'm also not sure if the above is always secure when something
>> else in the template spec wants to add a (different) property.  Do you
>> know?
>
> Not really.  `org-id' usually "just works" for me, so I never had to dig
> anything deeper there.  But, as far as I recall, this is meant to add
> the new ID on the IDs file.  Considering your capture template is likely
> to be on your agenda files, this is probably not going to be of
> concern (meaning here these files will eventually be scanned and the ID
> found).  But, if it is, you could then go with `%(org-id-get nil t)`,
> right?  It does seem to be more appropriate either way, I agree.
>
> I have stored here in my init file a message from the list describing
> the procedure Org uses to try to find an ID, you might find it useful:
> https://lists.gnu.org/archive/html/emacs-orgmode/2009-11/msg01195.html
>
> Regarding the second issue, of course, you should end up with a single
> properties drawer, and the template should ensure that.

Indeed, `%(org-id-get nil t)` fails.

But the following works:

(defun org-id-get-new-id ()
  (interactive)
  (let ((id (org-id-get nil t)))
    id))

To my surprise, I had to make it interactive. Perhaps that's what made
the previous try fail.

Best,
Gustavo.


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

* Re: Force creation of org id in template
  2020-10-26 23:30       ` Gustavo Barros
@ 2020-10-27  6:12         ` Colin Baxter
  0 siblings, 0 replies; 6+ messages in thread
From: Colin Baxter @ 2020-10-27  6:12 UTC (permalink / raw)
  To: emacs-orgmode

I have this URL to a site which gives a method for generating auto IDs,
which might be useful. I never use IDs so can't report on its
effectiveness. 

https://writequit.org/articles/emacs-org-mode-generate-ids.html#automating-id-creation

Best wishes,




Colin Baxter
URL: http://www.Colin-Baxter.com
---------------------------------------------------------------------
GnuPG fingerprint: 68A8 799C 0230 16E7 BF68  2A27 BBFA 2492 91F5 41C8
---------------------------------------------------------------------
Since mathematicians have invaded the theory of relativity, I do not
understand it myself. A. Einstein



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

end of thread, other threads:[~2020-10-27  6:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 18:26 Force creation of org id in template Michael Heerdegen
2020-10-26 19:24 ` gusbrs.2016
2020-10-26 21:33   ` Michael Heerdegen
2020-10-26 22:40     ` Gustavo Barros
2020-10-26 23:30       ` Gustavo Barros
2020-10-27  6:12         ` Colin Baxter

Code repositories for project(s) associated with this inbox:

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).