From 41a8666c09c702cb851b79a6f5eb3b3f0ba3e52b Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 11 Dec 2022 12:13:44 +0300 Subject: [PATCH] org-display-inline-remove-overlay: Do better job clearing images from cache * lisp/org.el (org-display-inline-remove-overlay): Force remove overlay images from Emacs image cache when un-displaying inline image overlays. This change should: (1) slightly improve Emacs memory usage when the number of inline images is large; (2) Clear images from cache every time Emacs removes the overlay for any reason. (`org-display-inline-remove-overlay' is used in overlay 'modification-hooks.) --- lisp/org.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/org.el b/lisp/org.el index 19f94c5e2..3018e4d6f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16399,6 +16399,10 @@ buffer boundaries with possible narrowing." "Remove inline-display overlay if a corresponding region is modified." (when (and ov after) (delete ov org-inline-image-overlays) + ;; Clear image from cache to avoid image not updating upon + ;; changing on disk. See Emacs bug#59902. + (when (overlay-get ov 'org-image-overlay) + (image-flush (overlay-get ov 'display))) (delete-overlay ov))) (defun org-remove-inline-images (&optional beg end)