2

Q: can I set an org-mode link to visit a file in read-only mode?

I want to store a link to another file in an org-mode document, but, when following the link, I want org to visit the file in read-only mode so that I don't go on autopilot and accidentally edit the linked file.

Is it possible to annotate the link so org knows to visit it in read-only mode? Hypothetically:

[[read-only-file:somefile.txt][A file that opens in read-only mode]]
  • You can always use an elisp form (see (info "(org) External links")), in your case [[elisp:(find-file-read-only "somefile.txt")][A file that opens in read-only mode]]. – mutbuerger Jul 21 '16 at 19:03
  • @mutbuerger: thanks! 95% of the way there, but org asks for confirmation to run the elisp. How would one disable the confirmation request? – Dan Jul 21 '16 at 19:10
  • org-confirm-elisp-link-function to nil. – mutbuerger Jul 21 '16 at 19:15
  • 1
    @mutbuerger: perfect! Could you combine your comments into an answer so I can accept it? – Dan Jul 21 '16 at 19:19
4

You can always use an elisp form (see (info "(org) External links")), in your case [[elisp:(find-file-read-only "somefile.txt")][A file that opens in read-only mode]]. For convenience consider setting org-confirm-elisp-link-function to nil.

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.