0

I am trying to create links within the body of an outline to files that are attached to that outline using the guidance in the documentation

***** Test outline                                                    :ATTACH:
      :PROPERTIES:
      :ID:       385a7ddd-0bb9-478c-9b3c-9bd87f14b344
      :Attachments: test-file
      :END:

[[attachment:test-file]]

I realise my example is not identical to the docs but the item in the docs doesn't seem to have an attachment. When I click on my resulting link I get a dialog "No match - create this as a new heading?" which is exactly the behaviour for any internal link for which no heading matches i.e. it doesn't seem to be interpreting this as an attachment link. If I click 'Yes' it gives me a new heading attachment:test-file

What am I doing wrong? How can you create a link to an outline attachment?

2
  • Have you changed any of the defaults? If not, have you created a data/ directory in the same place where the Org mode file is? Is there a subdirectory 38/ under data/? Is there a subdirectory 5a7ddd-0bb9-478c-9b3c-9bd87f14b344/ under data/38/? Is there a file test-file under data/38/5a7ddd-0bb9-478c-9b3c-9bd87f14b344? Is the file readable? AFAIK, org-attach does not add an Attachments property, so who added that? But if you created that data/ directory and then did C-c C-a a giving it an existing file, then the link should work (and it does for me, FWIW).
    – NickD
    Jan 14 at 2:21
  • If you evaluate this in your *scratch* buffer: (assoc "attachment" org-link-parameters) what does it return?
    – NickD
    Jan 14 at 3:04
1

The link is dispatched to a wrong handler, which means your org-attach package is probably not loaded yet. You can verify it by inspecting the org-link-parameters variable to check whether the attachment link type is present: evaluate (assoc "attachment" org-link-parameters) - if it returns nil, that means that org-attach is not loaded yet. You can also check by asking for help on one of its functions, e.g. C-h f org-attach: the doc string will say [Arg list not available until function definition is loaded.] in that case.

You can just add:

(with-eval-after-load 'org
  (require ‘org-attach))

to your init file (and restart emacs), so that all of the features that org-attach provides will always be available. Or invoke one of its autoload functions like org-attach or org-attach-dired-to-subtree before you try to follow an attachment link: that will trigger the autoload of the file which will add the attachment type to org-link-parameters and allow such links to be resolved properly.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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