format=flowed incorrect line wrapping

classic Classic list List threaded Threaded
6 messages Options
Nicolas Bock Nicolas Bock
Reply | Threaded
Open this post in threaded view
|

format=flowed incorrect line wrapping

Hi,

I can't figure out how to configure notmuch (in Emacs) to properly
wrap emails that are format=flowed. Right now long lines are
wrapped somewhere at around 70 some width.

Thanks already,

Nick
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Dan Čermák Dan Čermák
Reply | Threaded
Open this post in threaded view
|

Re: format=flowed incorrect line wrapping

Hi Nick,

I can turn that behavior off by disabling auto-fill-mode (M-x
auto-fill-mode). You can probably disable that globally via some setting
or via a hook.


Cheers,

Dan

Nicolas Bock <[hidden email]> writes:

> Hi,
>
> I can't figure out how to configure notmuch (in Emacs) to properly
> wrap emails that are format=flowed. Right now long lines are
> wrapped somewhere at around 70 some width.
>
> Thanks already,
>
> Nick
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (847 bytes) Download Attachment
Nicolas Bock Nicolas Bock
Reply | Threaded
Open this post in threaded view
|

Re: format=flowed incorrect line wrapping

Hi Dan,

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.

Best,

Nick

[1]
https://neomutt.org/guide/reference.html#3-287-%C2%A0reflow_text

On Thu, Dec 20 2018, Dan Čermák wrote:

> Hi Nick,
>
> I can turn that behavior off by disabling auto-fill-mode (M-x
> auto-fill-mode). You can probably disable that globally via some setting
> or via a hook.
>
>
> Cheers,
>
> Dan
>
> Nicolas Bock <[hidden email]> writes:
>
>> Hi,
>>
>> I can't figure out how to configure notmuch (in Emacs) to properly
>> wrap emails that are format=flowed. Right now long lines are
>> wrapped somewhere at around 70 some width.
>>
>> Thanks already,
>>
>> Nick
>> _______________________________________________
>> notmuch mailing list
>> [hidden email]
>> https://notmuchmail.org/mailman/listinfo/notmuch
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|

Re: format=flowed incorrect line wrapping

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,
- have notmuch remove newlines as appropriate from the part so that
  the long line wrapping done by `notmuch-wash-wrap-long-lines' takes
  effect.

Does anyone have suggestions as to which might be a better approach?

dme.
--
Another lonely day, no one here but me-o.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|

Re: format=flowed incorrect line wrapping

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?

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.

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Nicolas Bock Nicolas Bock
Reply | Threaded
Open this post in threaded view
|

Re: format=flowed incorrect line wrapping

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.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch