Karthik Chikmagalur <[email protected]> writes:
> I'm working on org-latex-preview actively this week, so even incremental
> feedback will be helpful as I can get started on it.
Next step - ox-latex.
> (defvar org-latex-precompile t
> "Precompile the preamble during export.
> This requires the LaTeX package \"mylatexformat\" to be installed.")
Should it be defcustom?
> (defconst org-latex--precompile-log "*Org LaTeX Precompilation*")
> (defvar org-latex-precompile-compiler-map
> '(("pdflatex" . "latex")
> ("xelatex" . "xelatex -no-pdf")
> ("lualatex" . "dvilualatex")))
Missing docstring.
In org-latex--precompile, there is
(preamble-hash
(thread-first
preamble
(concat
(plist-get info :latex-compiler)
(alist-get ?l (plist-get info :precompile-format-spec))
(if tempfile-p "-temp" default-directory))
(sha1)))
but org-latex--remove-cached-preamble has
(preamble-hash
(thread-first
preamble
(concat
latex-compiler
(if tempfile-p "-temp"
default-directory))
(sha1)))
Note how ?l field from :precompile-format-spec is missing.
> (defun org-latex--precompile-preamble (info preamble basepath)
checkdoc warnings.
> (unless (= 0 (call-process "kpsewhich" nil nil nil "preview.sty"))
> (display-warning
> '(org latex-preview preamble-precompilation)
> "The LaTeX package \"preview\" is required for precompilation, but
> could not be found")
> :warning)
This seems out of scope of ox-latex.el
> (defun org-latex-export-to-pdf-and-open (&optional async subtreep
> visible-only body-only ext-plist)
This is a new function that should be announced, maybe added to the
manual (as other similar functions). Also, docstring is missing.
> (defun org-latex-compile (texfile &optional snippet open-pdf)
open-pdf argument is missing in the docstring.
> (let ((failure-msg (format "File %S wasn't produced (exit code %%d). See %%s
> for details."
> outfile))
> async-call-spec)
> (dolist (cmd (reverse (org-compile-file-commands
> texfile process "pdf" spec)))
> (setq async-call-spec
> (list cmd
> :buffer log-buf
> :success
> (or async-call-spec
> (list (and open-pdf (lambda (_ _ _) (org-open-file
> outfile)))
> (lambda (_ buf _)
> (org-latex-compile--postprocess outfile buf
> snippet))))
> :failure
> failure-msg)))
> (message "Compiling %s..." texfile)
> (apply #'org-async-call async-call-spec))
This looks problematic:
1. The awkward dance with the loop reveals problems with design of
org-async-call
2. The call is async, which means that `org-latex-compile' is no longer
guaranteed to return an existing file.
3. I am wondering why the whole new if branch cannot be embedded into
org-compile-file itself. It already tries to copy org-compile-file
behavior by using the same failure message.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
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>