org-latex-preview: Fix bug when checking previews

*
lisp/org-latex-preview.el (org-latex-preview--check-all-fragments-produced):
When the first fragment in a preview run silently fails to render,
this function tries to cache a nil value as a fragment.  Fix by
checking that the fragment that fails to render is valid as a
fragment.
This commit is contained in:
Karthik Chikmagalur 2024-01-29 23:31:35 -08:00 committed by TEC
parent 157784392c
commit f6c7309e4d
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 3 additions and 4 deletions

View File

@ -2376,11 +2376,10 @@ fragments are regenerated."
;; If output ends prematurely, this is most likely due to an issue with
;; the last "succesfully" produced fragment, and so we mark it as erronious
;; and attempt to re-generate the rest.
(let ((bad-fragment (car fragments))
(bad-fragment-err (plist-get (car fragments) :errors)))
(when-let ((bad-fragment (car fragments)))
(plist-put bad-fragment :errors
(concat bad-fragment-err
(and bad-fragment-err "\n\n")
(concat (when-let ((current-error (plist-get bad-fragment :errors)))
(concat current-error "\n\n"))
"Preview generation catastrophically failed after this fragment."))
(org-latex-preview--remove-cached
(plist-get bad-fragment :key))