LaTeX fragments: Better error message when latex/dvipng unavailable
Thomas Morgan writes: > I just tried exporting an Org file with LaTeX fragments to HTML > on a computer that doesn't have dvipng. There were error messages > in *Messages* ("Failed to create png file..."), but this wasn't > obvious to me at first glance because those messages were replaced > in the echo area by "Exporting... done" before I could see them. > > So I was wondering, is there a good way to make the user aware of > those errors? Maybe by printing "Exporting... done (with errors)"? There is now a better error message when either the latex or the dvipng program does not exist.
This commit is contained in:
parent
8619361669
commit
d3689276ec
|
@ -1,6 +1,10 @@
|
|||
2009-04-30 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-macs.el (org-check-external-command): New defsubst.
|
||||
|
||||
* org.el (org-mode-map): New key for reload.
|
||||
(org-format-latex): Better error message when external programs
|
||||
are not available.
|
||||
|
||||
* org-agenda.el (org-agenda-mode-map): Bind `org-reload'.
|
||||
|
||||
|
|
|
@ -425,7 +425,10 @@ the first non-white thing on a line. It will also find the math delimiters
|
|||
like $a=b$ and \\( a=b \\) for inline math, $$a=b$$ and \\[ a=b \\] for
|
||||
display math.
|
||||
|
||||
This option can also be set with the +OPTIONS line, e.g. \"LaTeX:t\"."
|
||||
This option can also be set with the +OPTIONS line, e.g. \"LaTeX:t\".
|
||||
|
||||
The default is nil, because this option needs the `dvipng' program which
|
||||
is not available on all systems."
|
||||
:group 'org-export-translation
|
||||
:group 'org-export-latex
|
||||
:type 'boolean)
|
||||
|
|
|
@ -165,6 +165,18 @@ We use a macro so that the test can happen at compilation time."
|
|||
((assoc key option) (cdr (assoc key option)))
|
||||
(t (cdr (assq 'default option)))))
|
||||
|
||||
(defsubst org-check-external-command (cmd &optional use no-error)
|
||||
"Check if external progam CMD for USE exists, error if not.
|
||||
When the program does exist, return it's path.
|
||||
When it does not exist and NO-ERROR is set, return nil.
|
||||
Otherwise, throw an error. The optional argument USE can describe what this
|
||||
program is needed for, so that the error message can be more informative."
|
||||
(or (executable-find cmd)
|
||||
(if no-error
|
||||
nil
|
||||
(error "Can't find `%s'%s" cmd
|
||||
(if use (format " (%s)" use) "")))))
|
||||
|
||||
(defsubst org-inhibit-invisibility ()
|
||||
"Modified `buffer-invisibility-spec' for Emacs 21.
|
||||
Some ops with invisible text do not work correctly on Emacs 21. For these
|
||||
|
|
|
@ -13521,6 +13521,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
|
|||
(matchers (plist-get opt :matchers))
|
||||
(re-list org-latex-regexps)
|
||||
(cnt 0) txt link beg end re e checkdir
|
||||
executables-checked
|
||||
m n block linkfile movefile ov)
|
||||
;; Check if there are old images files with this prefix, and remove them
|
||||
(when (file-directory-p todir)
|
||||
|
@ -13549,6 +13550,14 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
|
|||
(unless checkdir ; make sure the directory exists
|
||||
(setq checkdir t)
|
||||
(or (file-directory-p todir) (make-directory todir)))
|
||||
|
||||
(unless executables-checked
|
||||
(org-check-external-command
|
||||
"latex" "needed to convert LaTeX fragments to images")
|
||||
(org-check-external-command
|
||||
"dvipng" "needed to convert LaTeX fragments to images")
|
||||
(setq executables-checked t))
|
||||
|
||||
(org-create-formula-image
|
||||
txt movefile opt forbuffer)
|
||||
(if overlays
|
||||
|
|
Loading…
Reference in New Issue