I want to insert upon creating a heading a PROPERTIES drawer. So far I have this
(defadvice org-insert-heading (after add-id-stuff activate)
(template-myid))
(defun template-myid ()
(insert "\n:PROPERTIES:\n:TIME: "
(format "%s" (format-time-string "%Y-%m-%dT%H:%M:%S"))
"\n:VERTEX: "
(format "%s" (shell-command "uuidgen" t))
"\n:EDGES: \n:END:"))
This is working -- sort of. My problem is the uuid is getting thrown around. The output looks like this
* Heading
:PROPERTIES:
:TIME: 2020-03-10T23:34:17
:VERTEX: 12836
:EDGES:
:END:32bf9499-f9e2-49d9-b8e7-9edb40272411
Not sure how to make this behave. It would be nice to simply call org-tempo and insert my ready-made template, but I've not figured out how to do that...
This works
which produced
Got help from NickD's suggestion above, Diego Zamboni over at the org-mode mail list ([email protected]), a Chris Wellons article, along with puzzling out the usual official ref dump suspects. Still, I'm not sure why
(shell-command "uuidgen" t)produces two outputs. This is what they look like in*scratch*although a straight
uuidgenat the bash command line produces just the UUID. What's happening to produce the2827above first? I couldn't fathom the*Help*onshell-command.The
(org-id-uuid)function is in org-id.el and seems very thorough at its randomness.Also, does anyone know how I could have done this by
advise-ing a function in org-mode tempo templates? I could never figure out what function was actually handling the<...-TAB.