* org-element approach to modify or add ID to every headline
@ 2015-08-09 3:01 Grant Rettke
2015-08-09 7:44 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Grant Rettke @ 2015-08-09 3:01 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
Good evening,
Emacs 24.4 and Org from Git.
Goal:
1) Visit every headline
2) If there is an ID property
1) Then replace it's value with a UUID
3) If there is not an ID property
1) Add an ID property and give it a UUID.
`org-uuid' [provides] the functionality to add the ID with a UUID.
[This post] explains how to do it:
┌────
│ (require 'org-id)
│ (save-excursion
│ (goto-char (point-max))
│ (while (outline-previous-heading)
│ (org-id-get-create)))
└────
What is the best way to do it with `org-element'?
[provides]
http://orgmode.org/w/?p=org-mode.git;a=blob_plain;f=lisp/org-id.el;hb=HEAD
[This post]
https://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-element approach to modify or add ID to every headline
2015-08-09 3:01 org-element approach to modify or add ID to every headline Grant Rettke
@ 2015-08-09 7:44 ` Nicolas Goaziou
2015-08-10 1:23 ` Grant Rettke
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2015-08-09 7:44 UTC (permalink / raw)
To: Grant Rettke; +Cc: emacs-orgmode@gnu.org
Hello,
Grant Rettke <gcr@wisdomandwonder.com> writes:
> Goal:
>
> 1) Visit every headline
> 2) If there is an ID property
> 1) Then replace it's value with a UUID
> 3) If there is not an ID property
> 1) Add an ID property and give it a UUID.
>
> `org-uuid' [provides] the functionality to add the ID with a UUID.
>
> [This post] explains how to do it:
>
> ┌────
> │ (require 'org-id)
> │ (save-excursion
> │ (goto-char (point-max))
> │ (while (outline-previous-heading)
> │ (org-id-get-create)))
> └────
>
> What is the best way to do it with `org-element'?
Using `org-element' here would be sub-optimal. Headlines are context
insensitive, i.e., you don't need a parser to find one.
Anyway, the following should do:
(dolist (p (nreverse
(org-element-map (org-element-parse-buffer 'headline) 'headline
(lambda (headline) (org-element-property :begin headline)))))
(goto-char p)
(org-id-get-create))
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-15 1:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-09 3:01 org-element approach to modify or add ID to every headline Grant Rettke
2015-08-09 7:44 ` Nicolas Goaziou
2015-08-10 1:23 ` Grant Rettke
2015-08-15 1:54 ` Samuel W. Flint
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.