* v2 Image toggle fixes for emacs 29.1
@ 2023-09-24 9:51 David Bremner
2023-09-24 9:51 ` [PATCH v2 1/4] emacs: save undisplayer function for MIME parts David Bremner
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: David Bremner @ 2023-09-24 9:51 UTC (permalink / raw)
To: notmuch
This obsoletes the series
id:20230916235137.334886-2-david@tethera.net
The update consists of the following bugfix:
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7a4b489d..4cc5aa57 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1036,7 +1036,7 @@ will return nil if the CID is unknown or cannot be retrieved."
;; We have to save the depth as we can't find the depth
;; when narrowed.
(depth (notmuch-show-get-depth))
- (mime-type (plist-get part-args :computed-type)))
+ (mime-type (plist-get (cadr part-args) :computed-type)))
(save-restriction
(narrow-to-region part-beg part-end)
(delete-region part-beg part-end)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 1/4] emacs: save undisplayer function for MIME parts
2023-09-24 9:51 v2 Image toggle fixes for emacs 29.1 David Bremner
@ 2023-09-24 9:51 ` David Bremner
2023-09-24 9:51 ` [PATCH v2 2/4] emacs/show: save redisplay redisplay data when showing lazy part David Bremner
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2023-09-24 9:51 UTC (permalink / raw)
To: notmuch
For some kinds of MIME parts (at least images), our trickery with
overlays will not work, so save the more drastic function created by
Gnus that actually deletes the part from the buffer. In an ideal world
we would return this function as (part of) a value, but here the call
stack is too complicated for anything that simple, so we stash it in
the part plist and rely on that being preserved (unlike the mm handle,
which is transient).
---
emacs/notmuch-lib.el | 1 +
1 file changed, 1 insertion(+)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 84ba8c5e..a09f4ab8 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -703,6 +703,7 @@ current buffer, if possible."
(when (mm-inlinable-p handle)
(set-buffer display-buffer)
(mm-display-part handle)
+ (plist-put part :undisplayer (mm-handle-undisplayer handle))
t))))))
;;; Generic Utilities
--
2.40.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/4] emacs/show: save redisplay redisplay data when showing lazy part.
2023-09-24 9:51 v2 Image toggle fixes for emacs 29.1 David Bremner
2023-09-24 9:51 ` [PATCH v2 1/4] emacs: save undisplayer function for MIME parts David Bremner
@ 2023-09-24 9:51 ` David Bremner
2023-09-24 9:51 ` [PATCH v2 3/4] emacs: save image redisplay data during non-lazy display David Bremner
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2023-09-24 9:51 UTC (permalink / raw)
To: notmuch
This data will be used to redisplay an image that is hidden by
deleting it from the buffer. We cannot easily delay until the image
is hidden, as we won't have the original data at that point.
---
emacs/notmuch-show.el | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 36cce619..107ce1b8 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1019,10 +1019,13 @@ will return nil if the CID is unknown or cannot be retrieved."
(part-end (copy-marker (point) t))
;; We have to save the depth as we can't find the depth
;; when narrowed.
- (depth (notmuch-show-get-depth)))
+ (depth (notmuch-show-get-depth))
+ (mime-type (plist-get (cadr part-args) :computed-type)))
(save-restriction
(narrow-to-region part-beg part-end)
(delete-region part-beg part-end)
+ (when (and mime-type (string-match "^image/" mime-type))
+ (button-put button :notmuch-redisplay-data part-args))
(apply #'notmuch-show-insert-bodypart-internal part-args)
(indent-rigidly part-beg
part-end
--
2.40.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/4] emacs: save image redisplay data during non-lazy display
2023-09-24 9:51 v2 Image toggle fixes for emacs 29.1 David Bremner
2023-09-24 9:51 ` [PATCH v2 1/4] emacs: save undisplayer function for MIME parts David Bremner
2023-09-24 9:51 ` [PATCH v2 2/4] emacs/show: save redisplay redisplay data when showing lazy part David Bremner
@ 2023-09-24 9:51 ` David Bremner
2023-09-24 9:51 ` [PATCH v2 4/4] emacs/show: special case toggling display of images David Bremner
2023-10-01 11:13 ` v2 Image toggle fixes for emacs 29.1 David Bremner
4 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2023-09-24 9:51 UTC (permalink / raw)
To: notmuch
This data will eventually be used to redisplay hidden images. A
certain amount of refactoring is done here to avoid code
duplication.
---
emacs/notmuch-show.el | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 107ce1b8..54cf00c6 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1109,14 +1109,18 @@ is t, hide the part initially and show the button."
(and deep button)
(and high button)
(and long button))))
- (content-beg (point)))
+ (content-beg (point))
+ (part-data (list msg part mime-type nth depth button)))
;; Store the computed mime-type for later use (e.g. by attachment handlers).
(plist-put part :computed-type mime-type)
- (if show-part
- (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)
+ (cond
+ (show-part
+ (apply #'notmuch-show-insert-bodypart-internal part-data)
+ (when (and button (string-match "^image/" mime-type))
+ (button-put button :notmuch-redisplay-data part-data)))
+ (t
(when button
- (button-put button :notmuch-lazy-part
- (list msg part mime-type nth depth button))))
+ (button-put button :notmuch-lazy-part part-data))))
;; Some of the body part handlers leave point somewhere up in the
;; part, so we make sure that we're down at the end.
(goto-char (point-max))
--
2.40.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/4] emacs/show: special case toggling display of images
2023-09-24 9:51 v2 Image toggle fixes for emacs 29.1 David Bremner
` (2 preceding siblings ...)
2023-09-24 9:51 ` [PATCH v2 3/4] emacs: save image redisplay data during non-lazy display David Bremner
@ 2023-09-24 9:51 ` David Bremner
2023-10-01 11:13 ` v2 Image toggle fixes for emacs 29.1 David Bremner
4 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2023-09-24 9:51 UTC (permalink / raw)
To: notmuch
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: v2 Image toggle fixes for emacs 29.1
2023-09-24 9:51 v2 Image toggle fixes for emacs 29.1 David Bremner
` (3 preceding siblings ...)
2023-09-24 9:51 ` [PATCH v2 4/4] emacs/show: special case toggling display of images David Bremner
@ 2023-10-01 11:13 ` David Bremner
2023-10-01 13:39 ` Michael J Gruber
4 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2023-10-01 11:13 UTC (permalink / raw)
To: notmuch
David Bremner <david@tethera.net> writes:
> This obsoletes the series
>
> id:20230916235137.334886-2-david@tethera.net
>
> The update consists of the following bugfix:
>
I have applied this series to release and master (and uploaded a
pre-release for 0.38.1)
d
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: v2 Image toggle fixes for emacs 29.1
2023-10-01 11:13 ` v2 Image toggle fixes for emacs 29.1 David Bremner
@ 2023-10-01 13:39 ` Michael J Gruber
2023-10-01 19:08 ` David Bremner
0 siblings, 1 reply; 8+ messages in thread
From: Michael J Gruber @ 2023-10-01 13:39 UTC (permalink / raw)
To: David Bremner; +Cc: notmuch
Am So., 1. Okt. 2023 um 13:13 Uhr schrieb David Bremner <david@tethera.net>:
>
> I have applied this series to release and master (and uploaded a
> pre-release for 0.38.1)
Is "pre" the new "rc", or how is this supposed to sort?
Michael
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: v2 Image toggle fixes for emacs 29.1
2023-10-01 13:39 ` Michael J Gruber
@ 2023-10-01 19:08 ` David Bremner
0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2023-10-01 19:08 UTC (permalink / raw)
To: notmuch@notmuchmail.org
Michael J Gruber <michaeljgruber+grubix+git@gmail.com> writes:
> Am So., 1. Okt. 2023 um 13:13 Uhr schrieb David Bremner <david@tethera.net>:
>>
>> I have applied this series to release and master (and uploaded a
>> pre-release for 0.38.1)
>
> Is "pre" the new "rc", or how is this supposed to sort?
>
> Michael
sorry about that. yeah, luckily rc1 sorts after pre0, so I guess I can
switch if/when there is a second release candidate.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-10-01 19:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-24 9:51 v2 Image toggle fixes for emacs 29.1 David Bremner
2023-09-24 9:51 ` [PATCH v2 1/4] emacs: save undisplayer function for MIME parts David Bremner
2023-09-24 9:51 ` [PATCH v2 2/4] emacs/show: save redisplay redisplay data when showing lazy part David Bremner
2023-09-24 9:51 ` [PATCH v2 3/4] emacs: save image redisplay data during non-lazy display David Bremner
2023-09-24 9:51 ` [PATCH v2 4/4] emacs/show: special case toggling display of images David Bremner
2023-10-01 11:13 ` v2 Image toggle fixes for emacs 29.1 David Bremner
2023-10-01 13:39 ` Michael J Gruber
2023-10-01 19:08 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).