forked from mirrors/org-mode
org-latex-preview: Guard against caching nil-files
* lisp/org-latex-preview.el (org-latex-preview--cache-image): When caching an image with `org-latex-preview--cache-image', check that the image path is non-nil. Should this not be true, a warning message is emitted suggesting this is a bug that should be reported to the Org mailing list.
This commit is contained in:
parent
c769032876
commit
13888aeeb3
|
@ -1968,18 +1968,26 @@ Return (path . info).
|
||||||
|
|
||||||
The caching location depends on whether preview persistence is
|
The caching location depends on whether preview persistence is
|
||||||
enabled, see `org-latex-preview-persist'."
|
enabled, see `org-latex-preview-persist'."
|
||||||
(if org-latex-preview-persist
|
(cond
|
||||||
(let ((label-path-info
|
((not path)
|
||||||
(or (org-persist-read org-latex-preview--cache-name
|
(ignore
|
||||||
(list :key key)
|
(display-warning
|
||||||
nil nil :read-related t)
|
'(org latex-preview put-cache)
|
||||||
(org-persist-register `(,org-latex-preview--cache-name
|
(format "Tried to cache %S without a path, skipping. This should not happen, please report it as a bug to the Org mailing list (M-x org-submit-bug-report)." key)
|
||||||
(file ,path)
|
:warning)))
|
||||||
(elisp-data ,info))
|
(org-latex-preview-persist
|
||||||
(list :key key)
|
(let ((label-path-info
|
||||||
:expiry org-latex-preview-persist-expiry
|
(or (org-persist-read org-latex-preview--cache-name
|
||||||
:write-immediately t))))
|
(list :key key)
|
||||||
(cons (cadr label-path-info) info))
|
nil nil :read-related t)
|
||||||
|
(org-persist-register `(,org-latex-preview--cache-name
|
||||||
|
(file ,path)
|
||||||
|
(elisp-data ,info))
|
||||||
|
(list :key key)
|
||||||
|
:expiry org-latex-preview-persist-expiry
|
||||||
|
:write-immediately t))))
|
||||||
|
(cons (cadr label-path-info) info)))
|
||||||
|
(t
|
||||||
(unless org-latex-preview--table
|
(unless org-latex-preview--table
|
||||||
(setq org-latex-preview--table (make-hash-table :test 'equal :size 240)))
|
(setq org-latex-preview--table (make-hash-table :test 'equal :size 240)))
|
||||||
(when-let ((path)
|
(when-let ((path)
|
||||||
|
@ -1988,7 +1996,7 @@ enabled, see `org-latex-preview-persist'."
|
||||||
temporary-file-directory)))
|
temporary-file-directory)))
|
||||||
(copy-file path new-path 'replace)
|
(copy-file path new-path 'replace)
|
||||||
(puthash key (cons new-path info)
|
(puthash key (cons new-path info)
|
||||||
org-latex-preview--table))))
|
org-latex-preview--table)))))
|
||||||
|
|
||||||
(defun org-latex-preview--get-cached (key)
|
(defun org-latex-preview--get-cached (key)
|
||||||
"Retrieve the image path and info associated with KEY.
|
"Retrieve the image path and info associated with KEY.
|
||||||
|
|
Loading…
Reference in New Issue