Can't set org-open-file-at-point to open file externally

What happened?

I’m a non-programmer who uses doom emacs for academic papers. The default behavior of doom seems to be to render .docx files and then load them. First, the conversion fails for me with .docx files, although it works for pdfs. Second, I would prefer to open both kinds of files with my default programs externally.

I would tell you what I tried, but I really have no idea how to change the default behavior of org-open-file-at-point.

What did you expect to happen

See above

Steps to reproduce

System information

Loading data dump...

This can be customized by changing the org-file-apps variable.

;; add to $DOOMDIR/config.el
(after! org
  (add-to-list 'org-file-apps '("\\.docx$" . default)))
;; Adjust the `"\\.docx$"` regex to apply to more files

In this case, default essentially tells Emacs to open links with your system’s default application. system will work better if you override default with earlier modifications to org-file-apps.

You can see documentation about this variable by typing C-h v org-file-apps (it must be done after the Org library is loaded; which has happened if you’ve opened an org file/buffer).

As an alternative: invoking org-open-at-point with two universal arguments will forcibly open that link in your system default app. I.e. SPC u u then M-x org-open-file-at-point (either on RET or C-c C-o).

Hope that helps!

Thanks so much for your response. But even after adding that code, org-open-file-at-point still goes to a conversion process. In treemacs, I can open files externally with "o x" and it opens with my default app for docx files.

I was unable to preface the command with two universal arguments, as SPC u is mapped to “undo.”

Many apologies. Yes, I was able to do two universal arguments but got the same conversion process.

On GNU Linux, default application refer to mailcap default. Mailcap refers to your settings either in ~/.mailcap or /etc/mailcap. If those settings configure emacs to open docx files, the suggested configuration will indeed change nothing.

You may consider changing your mailcap setting or, alternatively, use

;; add to $DOOMDIR/config.el
(after! org
  (add-to-list 'org-file-apps '("\\.docx$" . "lowriter %s")))
;; Adjust the `"\\.docx$"` regex to apply to more files

In the above, I assume that you want to open the document in LibreOffice Writer (lowriter) app. You may change it to your application of choice if needed.

Thanks so much. I had something like that but didn’t include (after! org. This is what I am using now so I can have my default app open docx files:

(after! org
  (add-to-list 'org-file-apps '("\\.docx$" . "xdg-open %s")))

Thanks again.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.