From 302803001317a0ceea5953159a9cfed2b6b02239 Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Sat, 21 Jan 2023 13:03:10 -0800 Subject: [PATCH] org-latex-preview: Fix auto-gen at end of overlay * lisp/org-latex-preview.el (org-latex-preview-auto--maybe-track-element-here): `overlays-at' does not include overlays that end at the position it is called on. This caused auto-generation to not trigger immediately when manually typing the closing delimiters of a LaTeX fragment. Fix this by recording the position just before the end of a newly created overlay. --- lisp/org-latex-preview.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index 37d67905f..94d63f025 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -679,7 +679,9 @@ If an org-latex-overlay is already present, nothing is done." (if (<= elem-beg pos elem-end) (progn (overlay-put ov 'view-text t) - (set-marker org-latex-preview-auto--marker pos) + ;; Record a position safely inside the created overlay + (set-marker org-latex-preview-auto--marker + (min pos (1- elem-end))) (setq org-latex-preview-auto--from-overlay t) nil) (setq org-latex-preview-auto--inhibit t)