format=flowed incorrect line wrapping
Nicolas Bock
nicolasbock at gmail.com
Fri Dec 21 05:18:56 PST 2018
On Fri, Dec 21 2018, David Edmondson wrote:
> On Friday, 2018-12-21 at 11:54:46 GMT, David Edmondson wrote:
>
>> On Thursday, 2018-12-20 at 07:00:08 -07, Nicolas Bock wrote:
>>
>>> sorry I didn't explain my problem very well. What I am looking
>>> for is to reflow (to borrow a term from NeoMutt [1]) an email
>>> message that I am _reading_ to the buffer width. Currently
>>> format=flowed emails are simply shown as they are in the raw
>>> email body. Editing and sending emails in format=flowed works
>>> fine.
>>
>> Currently emacs doesn't know that the text/plain part has the
>> format=flowed attribute, so it can't do anything about it.
>>
>> Two options occur to me: - ensure that emacs knows the
>> attributes of the part so that it could be
>> extended to do something useful,
>
> Here's a hacky patch that takes this approach. Does it do what
> you would expect?
Hi David,
thanks for the patch! I applied it but it's not doing anything. I
am not sure though that I am actually using the patch, so the fact
that there is no change shouldn't be taken too seriously :) Are
you on IRC? Maybe moving our discussion there would make it
easier.
Thanks!
Nick
> A complication is the indentation of parts, which makes it hard to set a
> good value for `fill-flowed-display-column' (because you don't know the
> indentation depth).
>
> A wash function (which would be the cleaner approach, presuming that we
> passed the part to all wash functions) *does* know the indentation
> depth, and so could perhaps adjust the value of
> `fill-flowed-encode-column' appropriately.
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 78f1af47..18cbc690 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -744,6 +744,11 @@ will return nil if the CID is unknown or cannot be retrieved."
> (save-excursion
> (save-restriction
> (narrow-to-region start (point-max))
> + ;; XXX dme: It would be much nicer to do this using a wash
> + ;; function attached to the hook, but that doesn't currently
> + ;; get access to the part and so cannot check the format.
> + (when (string= (plist-get part :format) "flowed")
> + (fill-flowed))
> (run-hook-with-args 'notmuch-show-insert-text/plain-hook msg depth))))
> t)
>
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 07e9a5db..92d18bb8 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -708,6 +708,19 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
> }
>
> if (GMIME_IS_PART (node->part)) {
> + /* Include the format parameter of text/plain parts if it
> + * exists, allowing the UI to adapt the display of the part as
> + * appropriate.
> + */
> + if (g_mime_content_type_is_type (content_type, "text", "plain")) {
> + const char *format =
> + g_mime_object_get_content_type_parameter (node->part, "format");
> + if (format) {
> + sp->map_key (sp, "format");
> + sp->string (sp, format);
> + }
> + }
> +
> /* For non-HTML text parts, we include the content in the
> * JSON. Since JSON must be Unicode, we handle charset
> * decoding here and do not report a charset to the caller.
>
> dme.
> --
> When I grow up I'll be stable.
More information about the notmuch
mailing list