0

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.

4
  • The #+TITLE etc keywords are different from any TITLE 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 use org-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, 2023 at 17:34
  • Right, I understand that about the different title properties. I'm inclined to do without the property drawer because it seems intended only for heading-level properties. Except for the way org-id uses it, I'm not aware of any other examples using a drawer for buffer properties. Some searching into org-entry-get led me to [emacs.stackexchange.com/a/63102/40099](this answer) which seems satisfactory, using org-collect-keywords. I can define arbitrary keys such as #+ID and perhaps advise org-id to use that instead.
    – ics
    Mar 14, 2023 at 20:33
  • Regarding the why, I use Emacs for most of my notetaking on desktop but keep a separate database of IDs so that I can devise simple autocomplete routines on other platforms by doing a lookup on uuid->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, 2023 at 20:39
  • C-c C-x p (bound to org-set-property) creates a PROPERTIES drawer at top level as well.
    – NickD
    Mar 14, 2023 at 21:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.