emacsorphanage / ox-pandoc

Another org-mode exporter via pandoc.
GNU General Public License v2.0
46 stars 13 forks source link

bug: batch export should wait for pandoc #6

Open pank opened 2 years ago

pank commented 2 years ago

Hi,

Consider this example

$ cat test.org 
# #+title: test
# * sec
# foobar
$ emacs --batch --no-init-file --eval "(progn (package-initialize) (require 'ox-pandoc))" --file test.org --funcall org-pandoc-export-to-docx
# Running pandoc with args: (-f org -t docx -o test.docx --standalone test.tmpj1jYwb.org)
$ ls | grep docx
# empty; nothing has been exported

pandoc is called via start-process (i.e. asyncroniously). So Emacs isn't waiting for it and the process gets killed immediately because Emacs is done. So Emacs needs to wait for process to end.

$ emacs --batch --no-init-file --eval "(progn (package-initialize) (require 'ox-pandoc))" --file test.org --funcall org-pandoc-export-to-docx --eval "(sleep-for 10)"
# Running pandoc with args: (-f org -t docx -o test.docx --standalone test.tmpm4tPHW.org)
# Exported to test.docx.
$ ls |grep docx
# test.docx

I guess an easy fix would be to call pandoc "syncroniously" when noninteractive is non-nil. Otherwise, it should check that the process is done.

Thanks, Rasmus

a-fent commented 2 years ago

Thank you for the report. For other reasons I already wanted to add synchronous processing without tempfiles (write from a buffer to pandoc on its STDIN and possibly read from its STDOUT), and was going to make this an customisation option.

pank commented 2 years ago

Aside: typically org saves temp files (used for e.g. async export) in a temporary folder (e.g. /tmp on GNU/Linux) which might be a bit elegant than saving the temp file in the same folder as the "proper" file.

minyez commented 1 month ago

Hi @a-fent , I am having the same issue for batch export. While the sleep-for workaround from @pank works for me, it would be really appreciated to have the synchronous process of running pandoc. I am also wondering if there is a way in Emacs to check whether its async processes have finished. If so, it would be better than sleep-for IMHO. Thank you.

yantar92 commented 1 month ago

Minye Zhang @.***> writes:

Hi @a-fent , I am having the same issue for batch export. While the sleep-for workaround from @pank works for me, it would be really appreciated to have the synchronous process of running pandoc.

Feel free to submit a PR.

I am also wondering if there is a way in Emacs to check whether its async processes have finished. If so, it would be better than sleep-for IMHO. Thank you.

`process-status'.

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92

minyez commented 1 month ago

@yantar92 Thank you very much for reply. I made some modifications to address this issue and also #8 , which seems to work for me. I will submit a PR soon for review.