forked from mirrors/org-mode
org-latex-preview: Mention latex buffer if no dvi
* lisp/org-latex-preview.el (org-latex-preview--failure-callback, org-latex-preview--create-image-async): When the image conversion step fails due to a missing input file, point the user to the LaTeX output buffer instead of the image conversion output buffer.
This commit is contained in:
parent
7834e6a850
commit
f52b7b4c89
|
@ -1387,8 +1387,7 @@ Returns a list of async tasks started."
|
||||||
;; │ │ which can rerun the async tree if needed.
|
;; │ │ which can rerun the async tree if needed.
|
||||||
;; │ └─ Delete tempfiles (`org-latex-preview--cleanup-callback').
|
;; │ └─ Delete tempfiles (`org-latex-preview--cleanup-callback').
|
||||||
;; └─ (failure)
|
;; └─ (failure)
|
||||||
;; ├─ Run `org-latex-preview--failure-callback' (remove overlays).
|
;; └─ Run `org-latex-preview--failure-callback' (remove overlays and emit msg).
|
||||||
;; └─ Message "creating latex previews failed. please see %s for details".
|
|
||||||
;;
|
;;
|
||||||
;; dvipng case:
|
;; dvipng case:
|
||||||
;; ├─ Compile tex file ⟶ stdout to `org-latex-preview--latex-preview-filter'
|
;; ├─ Compile tex file ⟶ stdout to `org-latex-preview--latex-preview-filter'
|
||||||
|
@ -1398,8 +1397,7 @@ Returns a list of async tasks started."
|
||||||
;; │ │ which can rerun the async tree if needed.
|
;; │ │ which can rerun the async tree if needed.
|
||||||
;; │ └─ Delete tempfiles (`org-latex-preview--cleanup-callback')
|
;; │ └─ Delete tempfiles (`org-latex-preview--cleanup-callback')
|
||||||
;; └─ (failure)
|
;; └─ (failure)
|
||||||
;; ├─ Run `org-latex-preview--failure-callback' (remove overlays).
|
;; └─ Run `org-latex-preview--failure-callback' (remove overlays and emit msg).
|
||||||
;; └─ Message "creating latex previews failed. please see %s for details".
|
|
||||||
;;
|
;;
|
||||||
;; generic case:
|
;; generic case:
|
||||||
;; └─ Compile tex file ⟶ stdout to `org-latex-preview--latex-preview-filter'
|
;; └─ Compile tex file ⟶ stdout to `org-latex-preview--latex-preview-filter'
|
||||||
|
@ -1411,8 +1409,7 @@ Returns a list of async tasks started."
|
||||||
;; │ └─ Call `org-latex-preview--check-all-fragments-produced',
|
;; │ └─ Call `org-latex-preview--check-all-fragments-produced',
|
||||||
;; │ which can rerun the async tree if needed.
|
;; │ which can rerun the async tree if needed.
|
||||||
;; └─ (failure)
|
;; └─ (failure)
|
||||||
;; ├─ Run `org-latex-preview--failure-callback' (remove overlays).
|
;; └─ Run `org-latex-preview--failure-callback' (remove overlays and emit msg).
|
||||||
;; └─ Message "creating latex previews failed. please see %s for details".
|
|
||||||
;;
|
;;
|
||||||
;; With continuous, synchronous processing:
|
;; With continuous, synchronous processing:
|
||||||
;;
|
;;
|
||||||
|
@ -1451,8 +1448,6 @@ Returns a list of async tasks started."
|
||||||
(plist-put (cddr img-extract-async) :failure
|
(plist-put (cddr img-extract-async) :failure
|
||||||
(list
|
(list
|
||||||
#'org-latex-preview--failure-callback
|
#'org-latex-preview--failure-callback
|
||||||
(format "Creating LaTeX preview images failed (exit code %%d). Please see %s for details"
|
|
||||||
(propertize org-latex-preview--image-log 'face 'warning))
|
|
||||||
#'org-latex-preview--cleanup-callback))
|
#'org-latex-preview--cleanup-callback))
|
||||||
(when org-latex-preview-process-finish-functions
|
(when org-latex-preview-process-finish-functions
|
||||||
;; Extra callbacks to run after image generation
|
;; Extra callbacks to run after image generation
|
||||||
|
@ -1487,11 +1482,23 @@ Returns a list of async tasks started."
|
||||||
'org-latex-preview-process-finish-functions
|
'org-latex-preview-process-finish-functions
|
||||||
args))
|
args))
|
||||||
|
|
||||||
(defun org-latex-preview--failure-callback (_exit _buf extended-info)
|
(defun org-latex-preview--failure-callback (exit-code _buf extended-info)
|
||||||
"Clear overlays corresponding to previews that failed to generate.
|
"Clear overlays corresponding to previews that failed to generate with EXIT-CODE.
|
||||||
|
|
||||||
EXTENDED-INFO contains the information needed to identify such
|
EXTENDED-INFO contains the information needed to identify such
|
||||||
previews."
|
previews."
|
||||||
|
(message "Creating LaTeX preview images failed (exit code %d). Please see %s for details"
|
||||||
|
exit-code
|
||||||
|
(if (pcase (plist-get extended-info :processor)
|
||||||
|
('dvisvgm (eq exit-code 252)) ; Input file does not exist.
|
||||||
|
('dvipng ; Same check, just a bit more involved.
|
||||||
|
(and (eq exit-code 1)
|
||||||
|
(with-current-buffer
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(search-forward ": No such file or directory" nil t))))))
|
||||||
|
(propertize org-latex-preview--latex-log 'face 'warning)
|
||||||
|
(propertize org-latex-preview--image-log 'face 'warning)))
|
||||||
(cl-loop for fragment in (plist-get extended-info :fragments)
|
(cl-loop for fragment in (plist-get extended-info :fragments)
|
||||||
for path = (plist-get fragment :path)
|
for path = (plist-get fragment :path)
|
||||||
when (not path)
|
when (not path)
|
||||||
|
|
Loading…
Reference in New Issue