Context: I am looking for a clean way to declare buffer level metadata to Org files. Some properties can only be declared at level-0 (i.e. buffer level) and others only in a property drawer, which is usually reserved for headline level.
Problem: When using org-id, a property drawer is added to the very beginning of the file, above any other header metadata, which looks strange (and incorrect, if property drawers are to be associated with headings). See the following example of a document after running M-x: org-store-link
:
:PROPERTIES:
:ID: 532C66A1-C2F3-4B7F-9BA6-AB812449E3DF
:END:
#+Title: Cy B. Org's Day Out
#+Author: John Doe
#+Filetags: notes
I have read and tried the methods for using IDs here but could not find any improvement. Ideally, I would like to have something like either of the following examples. Is this possible to do while correctly using org syntax? That is, both (org-get-title)
and (org-id-get)
return a value correctly and M-x: org-lint
does not show issues.
#+Title: Cy B. Org's Day Out
#+Author: John Doe
#+Filetags: notes
#+ID: 532C66A1-C2F3-4B7F-9BA6-AB812449E3DF
OR
:PROPERTIES: ; or "METADATA", "FILEDATA", etc.
:Title: Cy B. Org's Day Out
:Author: John Doe
:Filetags: notes
:ID: 532C66A1-C2F3-4B7F-9BA6-AB812449E3DF
:END:
Some additional documentation to read includes the Org manual on: Tag Inheritance and Property Syntax.
#+TITLE
etc keywords are different from anyTITLE
properties in a property drawer, so you cannot use your last suggestion. At top level, you can use#+PROPERTY: ID ...
instead of the property drawer (but there is no#+ID
keyword). And you will have to turn on property inheritance if you are doing searches (if you useorg-entry-get
you'll need to use the optional argument to the function to make sure that inheritance is turned on). Why are you adding an ID to the file though? How are you using that ID? – NickD Mar 14 '23 at 17:34org-entry-get
led me to [https://emacs.stackexchange.com/a/63102/40099](this answer) which seems satisfactory, usingorg-collect-keywords
. I can define arbitrary keys such as#+ID
and perhaps advise org-id to use that instead. – ics Mar 14 '23 at 20:33uuid->title
. For example, iOS Shortcut which just does a simple lookup and generates the formatted[[id:xxxxx]]
link while in a dumb editor. The mixed keywords-and-property-drawer result created by org-id is just a bit more annoying for me to process and look at in those situations. – ics Mar 14 '23 at 20:39C-c C-x p
(bound toorg-set-property
) creates aPROPERTIES
drawer at top level as well. – NickD Mar 14 '23 at 21:15