notmuch.git  about / heads / tags
Unnamed repository; edit this file 'description' to name the repository.
   commit a064a25427f466c6ba7da76c2b58bbac290caf5a (patch)
   parent 0646d485 emacs: save image redisplay data during non-lazy display
     tree ca90dc5f241d289e70cf95fb8b12a11de3483196
   author David Bremner <david@tethera.net>  2023-09-24 06:51:52 -0300
committer David Bremner <david@tethera.net>  2023-10-01 07:47:16 -0300

emacs/show: special case toggling display of images

According to emacs upstream [1], we can't expect overlay invisibility
and images to get along. This commit uses the previously stashed
undisplayer functions to actually remove the images from the buffer.
When the image is toggled, it is essentially redisplayed from scratch,
using the previously stashed redisplay data.

[1]: https://lists.gnu.org/archive/html/emacs-devel/2023-08/msg00593.html
---
 emacs/notmuch-show.el | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 54cf00c6..4cc5aa57 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -644,8 +644,24 @@ message at DEPTH in the current thread."
 		(when show
 		  (button-put button :notmuch-lazy-part nil)
 		  (notmuch-show-lazy-part lazy-part button))
-	      ;; else there must be an overlay.
-	      (overlay-put overlay 'invisible (not show))
+	      (let* ((part (plist-get properties :notmuch-part))
+		     (undisplayer (plist-get part :undisplayer))
+		     (mime-type (plist-get part :computed-type))
+		     (redisplay-data (button-get button
+						 :notmuch-redisplay-data))
+		     (imagep (string-match "^image/" mime-type)))
+		(cond
+		 ((and imagep (not show) undisplayer)
+		  ;; call undisplayer thunk created by gnus.
+		  (funcall undisplayer)
+		  ;; there is an extra newline left
+		  (delete-region
+		   (+ 1 (button-end button))
+		   (+ 2 (button-end button))))
+		 ((and imagep show redisplay-data)
+		  (notmuch-show-lazy-part redisplay-data button))
+		 (t
+		  (overlay-put overlay 'invisible (not show)))))
 	      t)))))))
 
 ;;; Part content ID handling


glossary
--------
Commit objects reference one tree, and zero or more parents.

Single parent commits can typically generate a patch in
unified diff format via `git format-patch'.

Multiple parents means the commit is a merge.

Root commits have no ancestor.  Note that it is
possible to have multiple root commits when merging independent histories.

Every commit references one top-level tree object.

git clone https://yhetil.org/notmuch.git