Friday, January 10, 2014

Processing org-mode -> latex-beamer -> pdf in the background

I have enjoyed making slides using org-mode greatly. However, it could be very slow. I currently have 30-page slides (but complicated code blocks and frames on them) and it takes me 10 seconds to compile.

Even worse, Emacs is not concurrent. Thus I have to wait those 10 seconds without being able to continue typing. This is annoying.

The fix is actually simple: launch another Emacs process to compile the file. Now everything works in the background in a non-blocking way. The code is very simple. Bind it with a key and that's it.

  (setq wy-obc-eval-str 
 "--eval=(progn (find-file \"%s\") (org-beamer-export-to-pdf) (kill-emacs))")
   
  (defun wy-org-beamer-concurrent ()
    (interactive)
    (save-buffer)
    (let ((eval-str (format wy-obc-eval-str buffer-file-name)))
      (call-process "emacs" nil 0 nil eval-str "--geometry" "60x5")))

PS: legoscia told me that there is emacs-async package (see question), which can free me from launching another emacs explicitly. This may be a better solution but I haven't tried that out.

No comments:

Post a Comment