Attach to (file-level) nodes?

Suppose I create a new note with M-x org-roam-node-find foo RET (and complete the capture process with C-c C-c).

At this point my node is essentially devoid of content and looks like

:PROPERTIES:
:ID:       A6C81621-352F-49F0-8519-3B6A4375E98C
:END:
#+title: foo
Lorem ipsum

Now I want add an attachment (let’s say a PDF) to this (file) node. I bring up the attachment dispatcher with C-c C-a, hit a, and indicate the PDF I would like to attach. However, the attachment fails with message

user-error: Before first headline at position 1 in buffer 20240404164412-foo.org

Presumably, org-attach is angry that I’m before the first headline; indeed since this is a file-level node with not very much content, it doesn’t even have any headlines. I can work around this by creating a new dummy headline so that the node now looks like

:PROPERTIES:
:ID:       A6C81621-352F-49F0-8519-3B6A4375E98C
:END:
#+title: foo

* Dummy Headline

move point to somewhere on Dummy Headline, and then try to attach again with C-c C-a. It will now work (and add an ID property to “Dummy Headline” in the process), but it will have added the attachment to the “Dummy Headline” rather than the “file-level” node.

Is there a workflow where org-attach will play nice with my (headline-free) node? Or should I just be in the habit of creating at least one Dummy Headline in which to stash my attachments?

I understand that this fundamentally has more to do with org-attach than org-roam. However, because org-roam seems to make extensive use of org’s so-called zeroth section, I was curious what the typical workflow was for other users here. Alternatively, perhaps org-attach could be extended to behave sensibly in the 0th section, especially if there is already a :PROPERTIES: drawer up there anyway?

I went looking on the OrgMode mailing list about this, and it was actually discussed very recently.

From the thread, I gather that this was actually addressed on org-mode’s main branch, but it hasn’t yet made it into a release.

1 Like