From c265d964f94c8be8fbe27b0d0270742fe7982f5b Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 30 Apr 2023 18:56:57 +0200 Subject: [PATCH] ox-odt: Improve some warning messages * lisp/ox-odt.el (org-odt--translate-latex-fragments): Reference `org-odt-with-latex' variable in the warning to direct users what to do. Only display the warning when there are LaTeX fragments to convert. --- lisp/ox-odt.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index abbbcf854..cc87d5fa6 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -3711,7 +3711,8 @@ contextual information." (defun org-odt--translate-latex-fragments (tree _backend info) (let ((processing-type (plist-get info :with-latex)) - (count 0)) + (count 0) + (warning nil)) ;; Normalize processing-type to one of dvipng, mathml or verbatim. ;; If the desired converter is not available, force verbatim ;; processing. @@ -3720,18 +3721,25 @@ contextual information." (if (and (fboundp 'org-format-latex-mathml-available-p) (org-format-latex-mathml-available-p)) (setq processing-type 'mathml) - (warn "LaTeX to MathML converter not available. Falling back to verbatim.") + (setq warning "`org-odt-with-latex': LaTeX to MathML converter not available. Falling back to verbatim.") (setq processing-type 'verbatim))) ((dvipng imagemagick) (unless (and (org-check-external-command "latex" "" t) (org-check-external-command (if (eq processing-type 'dvipng) "dvipng" "convert") "" t)) - (warn "LaTeX to PNG converter not available. Falling back to verbatim.") + (setq warning "`org-odt-with-latex': LaTeX to PNG converter not available. Falling back to verbatim.") (setq processing-type 'verbatim))) (otherwise - (warn "Unknown LaTeX option. Forcing verbatim.") + (setq warning "`org-odt-with-latex': Unknown LaTeX option. Forcing verbatim.") (setq processing-type 'verbatim))) + ;; Display warning if the selected PROCESSING-TYPE is not + ;; available, but there are fragments to be converted. + (when warning + (org-element-map tree '(latex-fragment latex-environment) + (lambda (_) (warn warning)) + info 'first-match nil t)) + ;; Store normalized value for later use. (when (plist-get info :with-latex) (plist-put info :with-latex processing-type))