* notmuch-emacs inline image display broken in emacs-29
@ 2023-02-24 4:26 Alex Murray
2023-02-25 13:21 ` David Bremner
0 siblings, 1 reply; 5+ messages in thread
From: Alex Murray @ 2023-02-24 4:26 UTC (permalink / raw)
To: notmuch
Hi folks,
I have noticed that inline image display doesn't work anymore in
emacs-29 / git master and have tracked it down to a change to the way
mm-inline-image inserts an image into the buffer.
In
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=d2186160a9e978960c0f96bc3b4fc65b5affc170
mm-inline-image was changed to use insert-image instead of
put-image. This inserts the image into the buffer using a single space
as the string contents with a display property set as the image contents
so that the single space is not shown itself but instead the image is
shown in its place.
I had thought the culprit then was the use of
notmuch-wash-elide-blank-lines within the default value of
notmuch-show-insert-text/plain-hook - assuming that since the line
containing the image is now just a single space, it then gets deleted
from the buffer and the image is never shown. However, even after
setting notmuch-show-insert-text/plain-hook to nil, images are still not
shown inline by notmuch.
However, if I locally redefine mm-inline-image to use say a period "."
as the string argument to insert-image then the image appears as
expected.
Any thoughts on what may be happening here and how best to resolve this?
Thanks,
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: notmuch-emacs inline image display broken in emacs-29
2023-02-24 4:26 notmuch-emacs inline image display broken in emacs-29 Alex Murray
@ 2023-02-25 13:21 ` David Bremner
2023-02-25 13:48 ` David Bremner
0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2023-02-25 13:21 UTC (permalink / raw)
To: Alex Murray, notmuch
[-- Attachment #1: Type: text/plain, Size: 1733 bytes --]
Alex Murray <alex.murray@canonical.com> writes:
> Hi folks,
>
> I have noticed that inline image display doesn't work anymore in
> emacs-29 / git master and have tracked it down to a change to the way
> mm-inline-image inserts an image into the buffer.
>
> In
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=d2186160a9e978960c0f96bc3b4fc65b5affc170
> mm-inline-image was changed to use insert-image instead of
> put-image. This inserts the image into the buffer using a single space
> as the string contents with a display property set as the image contents
> so that the single space is not shown itself but instead the image is
> shown in its place.
>
> I had thought the culprit then was the use of
> notmuch-wash-elide-blank-lines within the default value of
> notmuch-show-insert-text/plain-hook - assuming that since the line
> containing the image is now just a single space, it then gets deleted
> from the buffer and the image is never shown. However, even after
> setting notmuch-show-insert-text/plain-hook to nil, images are still not
> shown inline by notmuch.
>
> However, if I locally redefine mm-inline-image to use say a period "."
> as the string argument to insert-image then the image appears as
> expected.
>
> Any thoughts on what may be happening here and how best to resolve this?
>
The problem seems to be the call to indent-rigidly in
notmuch-show-lazy-part. The image is actually inserted OK, but then
apparently deleted by indent-rigidly (probably because it looks like
whitespace).
I tried replacing indent-rigidly with a simplified version the and that
leaves the image inserted, but unfortunately doesn't indent it
properly. If you want to play with it, my half working patch is
attached.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-replace-use-of-indent-rigidly-in-notmuch-show-la.patch --]
[-- Type: text/x-diff, Size: 1695 bytes --]
From 484f78e11d7f520b76b30b7d92aec15ff71f215f Mon Sep 17 00:00:00 2001
From: David Bremner <david@tethera.net>
Date: Sat, 25 Feb 2023 09:12:57 -0400
Subject: [PATCH] WIP: replace use of indent-rigidly in notmuch-show-lazy
---
emacs/notmuch-show.el | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 36cce619..522ba1fd 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -324,6 +324,25 @@ position of the message in the thread."
;;; Utilities
+;; force all indentation to be spaces at BOL
+;; Based on apply-on-rectangle, from rect.el
+(defun notmuch--indent-rigidly (start end count)
+ (cond
+ ((zerop count) t)
+ ((< count 0) (indent-rigidly start end count))
+ (t
+ (save-excursion
+ (let ((startpt (progn (goto-char start) (line-beginning-position)))
+ (endpt (progn (goto-char end) (line-end-position)))
+ (spaces (spaces-string count)))
+ (goto-char startpt)
+ (while
+ (progn
+ (insert spaces)
+ (cl-incf endpt count)
+ (and (zerop (forward-line 1)) (bolp)
+ (<= (point) endpt)))))))))
+
(defmacro with-current-notmuch-show-message (&rest body)
"Evaluate body with current buffer set to the text of current message."
`(save-excursion
@@ -1024,7 +1043,7 @@ will return nil if the CID is unknown or cannot be retrieved."
(narrow-to-region part-beg part-end)
(delete-region part-beg part-end)
(apply #'notmuch-show-insert-bodypart-internal part-args)
- (indent-rigidly part-beg
+ (notmuch--indent-rigidly part-beg
part-end
(* notmuch-show-indent-messages-width depth)))
(goto-char part-end)
--
2.39.1
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: notmuch-emacs inline image display broken in emacs-29
2023-02-25 13:21 ` David Bremner
@ 2023-02-25 13:48 ` David Bremner
2023-03-02 2:43 ` Alex Murray
0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2023-02-25 13:48 UTC (permalink / raw)
To: Alex Murray, notmuch
David Bremner <david@tethera.net> writes:
> Alex Murray <alex.murray@canonical.com> writes:
>
> I tried replacing indent-rigidly with a simplified version the and that
> leaves the image inserted, but unfortunately doesn't indent it
> properly. If you want to play with it, my half working patch is
> attached.
>
Actually, the current implementation using indent-rigidly doesn't indent
inlined images properly either, so maybe that is a way forward. I
remember from last time I considered globally replacing our use of
indent-rigidly [1] there were a few issues to be dealt with, but maybe
this is a reasonable approach.
[1]: https://nmbug.notmuchmail.org/nmweb/show/20211214121726.2631714-1-david@tethera.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: notmuch-emacs inline image display broken in emacs-29
2023-02-25 13:48 ` David Bremner
@ 2023-03-02 2:43 ` Alex Murray
2023-04-04 21:44 ` Al Haji-Ali
0 siblings, 1 reply; 5+ messages in thread
From: Alex Murray @ 2023-03-02 2:43 UTC (permalink / raw)
To: David Bremner, notmuch
On Sat, 2023-02-25 at 09:48:08 -0400, David Bremner wrote:
> David Bremner <david@tethera.net> writes:
>
>> Alex Murray <alex.murray@canonical.com> writes:
>>
>> I tried replacing indent-rigidly with a simplified version the and that
>> leaves the image inserted, but unfortunately doesn't indent it
>> properly. If you want to play with it, my half working patch is
>> attached.
>>
>
> Actually, the current implementation using indent-rigidly doesn't indent
> inlined images properly either, so maybe that is a way forward. I
> remember from last time I considered globally replacing our use of
> indent-rigidly [1] there were a few issues to be dealt with, but maybe
> this is a reasonable approach.
>
Thanks for the patch David - I tried the one attached to the previous
email it but it doesn't seem to fix the issue for me.
I also tried the one in [1] and that did seem to help - images in
replies (and hence emails that by default are displayed with an indent)
show up now, but not for emails that are the first ones in a thread (and
hence have no indent by default).
(although I notice in a recent conversation in #notmuch that it did
appear to work for one user - but not sure which patch they were using).
Any ideas where I should start trying to debug this on my side?
I am using a pretty recent build of emacs from master with a the latest
notmuch-emacs bits from MELPA - https://melpa.org/#/notmuch (and the
notmuch binary 0.37 - as packaged in Ubuntu 23.04 with version
0.37-1ubuntu3 FWIW).
> [1]: https://nmbug.notmuchmail.org/nmweb/show/20211214121726.2631714-1-david@tethera.net
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: notmuch-emacs inline image display broken in emacs-29
2023-03-02 2:43 ` Alex Murray
@ 2023-04-04 21:44 ` Al Haji-Ali
0 siblings, 0 replies; 5+ messages in thread
From: Al Haji-Ali @ 2023-04-04 21:44 UTC (permalink / raw)
To: notmuch
Hello Alex and David,
I also came across this issue: inline image are not displayed only when `notmuch-show-indent-content` is non-nil. However, even when `notmuch-show-indent-content` is `nil` they are displayed but cannot be hidden.
As Alex Murray pointed out, the reason is that the function `mm-insert-image` is being changed in Emacs 29 to use `insert-image` instead of `put-image`. `insert-image` inserts images using the `display` property of a whitespace character. The effect is that when `indent-rigidly` is called in `notmuch-show-insert-msg`, whitespace is removed and hence the image is removed. I've filed a bug#62637 on bug-gnu-emacs to discuss this.
An easy fix in `mm-insert-image` is use non-whitespace character (the second argument of `insert-image`) so that it is not deleted by `indent-rigidly`. This change actually makes indenting images work in the new version.
The other issue is that hiding an overlay created around such an image does not seem to work (see bug#62637 for a discussion). A way to resolve this is to add some whitespace (like a newline) inside the overlay before the image, which seems to fix things.
-- Al
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-04 21:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 4:26 notmuch-emacs inline image display broken in emacs-29 Alex Murray
2023-02-25 13:21 ` David Bremner
2023-02-25 13:48 ` David Bremner
2023-03-02 2:43 ` Alex Murray
2023-04-04 21:44 ` Al Haji-Ali
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).