0

I use org-attach mostly to "move" files and store them under various TODO items. I find this an invaluable feature for keeping receipts and other important documents. The limitation of org-attachments is that there is no way of knowing what files are kept under the item just by looking at the entry. Org uses the keyword :ATTACH: to indicate that that entry has an attachment. One can also tell this by the fact that there is an ID generated under properties. It would however be a nice feature to be able to see at least the filenames one has under that entry, without having to actually call org-attach.

8
  • 1
    FWIW, I just do C-c C-a F (i.e. org-attach-reveal-in-emacs) to examine attachments. Having the filenames in the Org mode file would clutter it up too much for my taste. But you might want to submit a feature request to the Org mode mailing list.
    – NickD
    Commented Jan 14, 2021 at 16:07
  • 1
    There is some resistance to add more options to Org mode (there are hundreds, not all of them documented and not all of them useful). But as I said, you can always submit a feature request (or, better, a patch to add the feature).
    – NickD
    Commented Jan 14, 2021 at 17:10
  • 1
    You should be able to cobble something together with org-attach-dir and org-attach-file-list (which see). The difficulty will be in keeping the attachment list in the Org mode file and the file list in the attachment directory in sync.
    – NickD
    Commented Jan 14, 2021 at 17:59
  • 1
    You can create links a bit more conveniently with org-attach-complete-link.
    – NickD
    Commented Jan 14, 2021 at 18:38
  • 1
    BTW, there is an attachment type link that use the aforementioned org-attach-complete-link so you don't have to write any code: C-c C-l att TAB RET <select file with TAB completion> RET <description> RET will do it.
    – NickD
    Commented Jan 14, 2021 at 19:39

2 Answers 2

1

[Capturing and summarizing the comments as an answer.]

Although org-attach does not provide an automatic way to add the list of files in the attachment directory of a headline node to that node explicitly, it does provide some mechanisms which could be used to do so. There is no problem about getting the current list:

(org-attach-file-list (org-attach-dir))

evaluated at a particular node, would return the list of files; inserting it in e.g. a drawer should not be too difficult. Keeping the two lists in sync is doable as well: one possibility is to add a function to org-attach-after-change-hook that recalculates the list and recreates the drawer from scratch. This is just an outline of course: an implementation would be nice.

One other possibility (which apparently meets the OP's requirements) is to manually create links to the entries. This too requires maintenance to keep things in sync, but assuming that links are mostly added and almost never deleted, the method will probably work well. It is based on the fact that Org mode supports attachment links: one can then use the standard link creation mechanism of Org mode, C-c C-l (bound to org-insert-link) as follows:

C-c C-l att TAB RET <select attachment file with TAB completion> RET RET

The attachment link type uses org-attach-complete-link which provides tab completion for the files in the attachment directory of the node. The above invocation creates a link without a description, so the link looks like this:

[[attachment:filename]]

but a description can of course be provided if required. Note that the link does not contain the path of the attachment directory: the value of that is retrieved from the metadata stored in the node (the ID property that is added) in order to retrieve the file. That keeps the clutter in the Org mode file down a bit.

1

Thanks to @NickD I did submit a feature request to the orgmode team and received a very helpful response from them. I believe that listing all the attached files used to be the built-in, but was removed a few years ago. One can, however, still implement it for personal use. The function and correspondence can be found at this public message URL:

https://orgmode.org/list/87sg70vsvy.fsf@localhost/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.