org-latex-preview: Prioritise near latex previews

* lisp/org-latex-preview.el (org-latex-preview-fragments): Reorder
gathered latex fragments so that they are processed starting at the
window start position.  When previewing a large file, this makes a
significant difference to the perceived speed of the processing.
Remove references to `org-preview-latex-image-directory' from this
function, as it is no longer used to cache images.
This commit is contained in:
Karthik Chikmagalur 2023-01-02 01:58:17 -08:00 committed by TEC
parent f02c40835b
commit 18095e6578
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 9 additions and 10 deletions

View File

@ -757,16 +757,15 @@ protection against placing doubled up overlays."
(overlay-recenter (or end (point-max))))
(unless (eq (get-char-property (point) 'org-overlay-type)
'org-latex-overlay)
(let ((image-dir (expand-file-name
(concat org-preview-latex-image-directory "org-ltximg")
dir)))
(unless (file-exists-p image-dir)
(make-directory image-dir t)))
(if (assq processing-type org-latex-preview-process-alist)
(org-latex-preview--create
processing-type (org-latex-preview-collect-fragments beg end))
(error "Unknown conversion process %s for previewing LaTeX fragments"
processing-type))))
(let ((ws (window-start)))
(if (assq processing-type org-latex-preview-process-alist)
(org-latex-preview--create
processing-type
(nconc (org-latex-preview-collect-fragments (max ws beg) end)
(when (< beg ws)
(org-latex-preview-collect-fragments beg (1- ws)))))
(error "Unknown conversion process %s for previewing LaTeX fragments"
processing-type)))))
(defun org-format-latex
(prefix &optional beg end dir overlays msg forbuffer processing-type)