1

When using org export, if I expert to ODT and open, Emacs opens the file internally, as an archive.

I want it to open the ODT file in Libreoffice.

what do I need to change to do that?

1
  • 1
    C-c C-e o O from an opened org file and the odt file is created and opened with LibreOffice. How did you proceed?
    – gigiair
    Jul 17, 2023 at 18:12

2 Answers 2

0

I am assuming that your are on Linux ...

Based on https://kjambunathan.github.io/org-mode-ox-odt/Getting-Started-with-ODT-export.html#Configuration, add the following to your init file

;; (setcdr (assq 'system org-file-apps-defaults-gnu) "xdg-open %s")
(setcdr (assq 'system org-file-apps-gnu) "xdg-open %s")

(advice-add 'org-open-file :around
            (lambda (orig-fun &rest args)
              ;; Work around a weird problem with xdg-open.
              (let ((process-connection-type nil))
                (apply orig-fun args))))

Then C-c C-e o O (small-o and capital-O) will open the file in LibreOffice.


The above snippet tells org that xdg-open is the system command for opening ODT or any other file (that org-mode doesn't know about)

gnu in org-file-apps-gnu tells you that you are configuring a Linux like system.

If you are on some other OSes, say Windows, find the configuration variable (=the counterpart of org-file-apps-gnu) that sets the system command for opening files, and change it to open (=or any other equivalent command)

In recent versions of Emacs browse-url-of-dired-file (=W in dired-mode) does the open in a system-specific way. IIRC, you can use a Elisp form (instead of a *shell* command for configuring the open command)

I have no experience with non-Linux systems ... so I cannot help much with those systems.


Start from M-x customize-variable org-file-apps or consult other related variables org-file-apps-macos, org-file-apps-windowsnt

0

When you run vanilla Emacs without configuration, odt files will open as a buffer if you have OpenOffice installed. See: https://lucidmanager.org/productivity/reading-ebooks-with-emacs/

It seems that some parts of Org mode modifies the auto-mode-alist variable that associated Open Office formats with archive-mode.

A workaround is to evaluate:

(use-package ox-odt
  :ensure nil
  :config
  (add-to-list 'auto-mode-alist
               '("\\.\\(?:OD[CFIGPST]\\|od[cfigpst]\\)\\'"
                 . doc-view-mode-maybe)))

This line corrects the bug in ox-odt.el which overrides the defaults.

1
  • Update: Org mode developers confirmed the bug and are working to fix it. Dec 9, 2023 at 19:43

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.