branch: externals/org commit ed64e94eaf7a1683a13fd39372a4d0a0672b611f Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com> Commit: Ihor Radchenko <yanta...@posteo.net>
ol: Reuse existing overlay when previewing links * lisp/ol.el (org-link-preview-region): If a preview overlay exists on a link region when previewing that link, reuse it instead of placing a second one. Reported-by: stardiviner <numbch...@gmail.com> Link: https://orgmode.org/list/87ecygixi4....@gmail.com --- lisp/ol.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 9e46b43a5c..c08bfe67bf 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -2069,13 +2069,15 @@ buffer boundaries with possible narrowing." (not (org-element-contents-begin link))) (org-element-property :path link)))) ;; Create an overlay to hold the preview - (let ((ov (make-overlay - (org-element-begin link) - (progn - (goto-char - (org-element-end link)) - (unless (eolp) (skip-chars-backward " \t")) - (point))))) + (let ((ov (or (cdr-safe (get-char-property-and-overlay + (org-element-begin link) 'org-image-overlay)) + (make-overlay + (org-element-begin link) + (progn + (goto-char + (org-element-end link)) + (unless (eolp) (skip-chars-backward " \t")) + (point)))))) (overlay-put ov 'modification-hooks (list 'org-link-preview--remove-overlay)) (push ov org-link-preview-overlays)