Karthik Chikmagalur <[email protected]> writes:

>>>>> (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
>>>
>>> Not sure how to propagate this error back to org-latex-preview.  Please
>>> advise.
>>
>> That's a simple check whether preview.sty exists. Such a check can be
>> done in org-latex-preview itself before even trying to run latex. Is
>> there any problem doing it?
>
> It can't be done before every LaTeX run, that will slow things down.
> How would you arrange to do it once?

You have
(if-let ((format-file (org-latex-preview--precompile processing-info header
                                                              (not 
relative-file-p))))
             (setq header (concat "%& " (file-name-sans-extension format-file)))
           (setq precompile-failed-msg
                 (concat 
                  (format "Precompile failed for buffer %s."
                          (plist-get processing-info :org-buffer))
                  (when-let ((filename (buffer-file-name
                                        (plist-get processing-info 
:org-buffer))))
                    (format " (File %s)" filename)))))

So, you already have error handling.
Simply make it more elaborate adding the warning about preview.sty.

-- 
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>

Reply via email to