forked from mirrors/org-mode
org-latex-preview: Avoid duplicating cached images
* lisp/org-latex-preview.el (org-latex-preview--cache-image): When caching an image, check if there is already an entry in the `org-persist--index' with the same hash as this one. This avoids missing preview images for fragments with duplicates in a buffer, or across org-persist's cache. Without this measure, when we try to register two fragments identified by the same hash, `org-persist-register' returns a structure with the correct metadata for both, but with the cached image path field missing for the second fragment.
This commit is contained in:
parent
18095e6578
commit
faccbc04e9
|
@ -1199,11 +1199,14 @@ listed in EXTENDED-INFO will be used."
|
|||
"Save the image at PATH with associated INFO in the cache indexed by KEY.
|
||||
Return (path . info)."
|
||||
(let ((label-path-info
|
||||
(org-persist-register `("LaTeX preview cached image data"
|
||||
(file ,path)
|
||||
(elisp-data ,info))
|
||||
(or (org-persist-read "LaTeX preview cached image data"
|
||||
(list :key key)
|
||||
:write-immediately t)))
|
||||
nil nil :read-related t)
|
||||
(org-persist-register `("LaTeX preview cached image data"
|
||||
(file ,path)
|
||||
(elisp-data ,info))
|
||||
(list :key key)
|
||||
:write-immediately t))))
|
||||
(cons (cadr label-path-info) info)))
|
||||
|
||||
(defun org-latex-preview--get-cached (key)
|
||||
|
|
Loading…
Reference in New Issue