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
.
2 Answers
[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.
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:
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.org-attach-dir
andorg-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.org-attach-complete-link
.attachment
type link that use the aforementionedorg-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.