emacs org-odt-export-as-odf-and-open odt outside emacs

依然范特西╮ 提交于 2019-12-10 11:35:43

问题


The intuitive use for the orgmode option to export and view and odt file should be to view it in an libre/open office. However, I've so far had no luck in getting it to work; it always opens as a compressed archive in emacs. By inserting into my .emacs

(add-to-list 'org-file-apps '("\\.odt\\'" . "xdg-open %s"))

I open them properly when accessing links to files in org files, but it doesn't seem to effect the export-and-view option. I've looked into changing org-odt-export-as-odf-and-open but have not been able to see it make a difference. Any help would be appreciated. Once again, I want org-odt-export-as-odf-and-open to open the odf with xdg-open or libreoffice, not Emacs.

Thanks!


回答1:


The function you are calling is for exporting OpenDocument formulas (.odf files), not OpenDocument text documents (.odt files):

Export LaTeX fragment as OpenDocument formula and immediately open it.
Use `org-odt-export-as-odf' to read LaTeX fragment and OpenDocument
formula file.

Since the exported file doesn't have a .odt extension your addition to org-file-apps doesn't affect it.

I don't see any built-in function to export Org mode documents to LibreOffice Writer files and open them, but it is trivial to write:

(defun my-org-export-to-odt-and-open ()
  (interactive)
  (org-open-file (org-odt-export-to-odt)))



回答2:


EDIT A more graceful solution was given on the org-mode list that doesn't require editing any of your packaged org files. Simply add the following to your .emacs to rebind what 'system is doing:

(setcdr (assq 'system org-file-apps-defaults-gnu ) "xdg-open %s")
There's an error in the current version of the code. It can be fixed by editing line 97 of ox-odt.el: :menu-entry '(?o "Export to ODT" ((?o "As ODT file" org-odt-export-to-odt) (?O "As ODT file and open" (lambda (a s v b) (if a (org-odt-export-to-odt t s v) (org-open-file (org-odt-export-to-odt nil s v) 'system)))))) by removing that last `'system`, so you have: :menu-entry '(?o "Export to ODT" ((?o "As ODT file" org-odt-export-to-odt) (?O "As ODT file and open" (lambda (a s v b) (if a (org-odt-export-to-odt t s v) (org-open-file (org-odt-export-to-odt nil s v) )))))) You may also need to edit the ox-odt.elc equivalently if you are using a compiled version.


回答3:


I've tried the solution of WorldsEndless but it doesn't work for me, instead I use this variation

(setcdr (assq 'system org-file-apps-defaults-gnu ) '(call-process "xdg-open" nil 0 nil file))


来源:https://stackoverflow.com/questions/24434854/emacs-org-odt-export-as-odf-and-open-odt-outside-emacs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!