From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oMv2M+AGEGVExAAAauVa8A:P1 (envelope-from ) for ; Sun, 24 Sep 2023 11:52:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id oMv2M+AGEGVExAAAauVa8A (envelope-from ) for ; Sun, 24 Sep 2023 11:52:32 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4E41544C8E for ; Sun, 24 Sep 2023 11:52:32 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1695549152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=fHfMjuizVLodHHiyeL7CcI2RO5xfpZQ5mC2ofy0jAcg=; b=eACwos5pEvIH95Df0nf6OlZdJX0hrxJoKg5Z0NgCOgVdKJtt3UKMIyZxbxHFQpkXAoMcCM oAEifzrZW6Kj4eyN+70P4/kJh60EaEUweGvumgtnNBHvy4t15mBD5E5GrljkZdaJbct/DA J1U/1+zrQ9/Nq68nhOQZYJHaVSFZ2F1b7ucnROIXOdAivQCEFMcNucGP+r4J6lQ13n3vRU PlYsiOcYzeI/W502S6IDt80RINRYIcgvHNw/nkTUaoiJDKaWD7qKWbiE66wHRvhT97KdWZ daqKlb9BGtZ23PVbzZ62loQCaTgnHwBmQhwJNWwVm0OLcwDf5hGA9HFhvCdKow== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1695549152; a=rsa-sha256; cv=none; b=CP/0vE1tGHNeWvjkX3YrO0K3iRGHsNOm5Pq79bPD0bgy1EW5oU/BEhDhRrsHXp7zb3hQBc 619c6oK/v0nRzDkdyKy4Ha6QzukrtUKcgPD/0vvvmrhdAxy6CXGFMrqes/HREYrCMqgNjZ 63wpKGqxzPQX44fITL7nZe7eKStK5E2NBXBXqnCiuZpLNM8eVbwqDpf+Ysb1jSjFwbphib obOISsUuGcvqtC4dWicsGIfPfTyuKx2iATSehD1LGLiDPL3NskczHjIYCxcT+6og2r/2Ci Dds9REHJXc6GzgVWZEfzHrWNL5CFbMPe1lWhMmy/TpWwXPL053m9W5xS4OOhxA== Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3AFB160987; Sun, 24 Sep 2023 09:52:14 +0000 (UTC) Received: from phubs.tethera.net (phubs.tethera.net [IPv6:2607:5300:60:3a9d::1]) by mail.notmuchmail.org (Postfix) with ESMTPS id 00E975F419 for ; Sun, 24 Sep 2023 09:52:10 +0000 (UTC) Received: from tethera.net (fctnnbsc51w-159-2-210-253.dhcp-dynamic.fibreop.nb.bellaliant.net [159.2.210.253]) by phubs.tethera.net (Postfix) with ESMTPS id CC5FA180068; Sun, 24 Sep 2023 06:52:08 -0300 (ADT) Received: (nullmailer pid 1394257 invoked by uid 1000); Sun, 24 Sep 2023 09:52:05 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH v2 4/4] emacs/show: special case toggling display of images Date: Sun, 24 Sep 2023 06:51:52 -0300 Message-Id: <20230924095152.1394168-5-david@tethera.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230924095152.1394168-1-david@tethera.net> References: <20230924095152.1394168-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 6XBNGE6MU6QGRQVYFV5RBJTKJQ7IDK3T X-Message-ID-Hash: 6XBNGE6MU6QGRQVYFV5RBJTKJQ7IDK3T X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE X-Migadu-Spam-Score: -1.11 X-Migadu-Scanner: mx2.migadu.com X-Migadu-Queue-Id: 4E41544C8E X-Spam-Score: -1.11 X-TUID: e3ZVAktxXh2d 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 -- 2.40.1