unofficial mirror of notmuch@notmuchmail.org
 help / color / Atom feed
* [PATCH v2 0/3] support for format=flowed text display
@ 2018-12-22 12:10 David Edmondson
  2018-12-22 12:10 ` [PATCH v2 1/3] notmuch: Include the format parameter of text/plain parts David Edmondson
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: David Edmondson @ 2018-12-22 12:10 UTC (permalink / raw)
  To: notmuch


support for format=flowed text display

This patch improves the display of format=flowed text parts.

I suspect that format=flowed display and some of the other content
washing might interact in annoying ways, but the only way to be sure
is to see how people feel about the results.

v2:
- Update the schemata.


David Edmondson (3):
  notmuch: Include the format parameter of text/plain parts
  emacs: Pass the part to text/plain hook functions
  emacs: Process format=flowed text

 devel/schemata        |  2 ++
 emacs/notmuch-show.el |  5 +++--
 emacs/notmuch-wash.el | 24 +++++++++++++++++++-----
 notmuch-show.c        | 13 +++++++++++++
 4 files changed, 37 insertions(+), 7 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] notmuch: Include the format parameter of text/plain parts
  2018-12-22 12:10 [PATCH v2 0/3] support for format=flowed text display David Edmondson
@ 2018-12-22 12:10 ` David Edmondson
  2018-12-22 12:10 ` [PATCH v2 2/3] emacs: Pass the part to text/plain hook functions David Edmondson
  2018-12-22 12:10 ` [PATCH v2 3/3] emacs: Process format=flowed text David Edmondson
  2 siblings, 0 replies; 8+ messages in thread
From: David Edmondson @ 2018-12-22 12:10 UTC (permalink / raw)
  To: notmuch

During formatted output, if a content type of a text/plain part
has a "format" paramter, include it in the output.
---
 devel/schemata |  2 ++
 notmuch-show.c | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/devel/schemata b/devel/schemata
index 42b1bcf3..194933d4 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -93,6 +93,8 @@ part = {
     # otherwise (leaf parts):
     filename?:      string,
     content-charset?: string,
+    # if content-type is "text/plain" and a "format" parameter exists:
+    format?:        string,
     # A leaf part's body content is optional, but may be included if
     # it can be correctly encoded as a string.  Consumers should use
     # this in preference to fetching the part content separately.
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.
-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] emacs: Pass the part to text/plain hook functions
  2018-12-22 12:10 [PATCH v2 0/3] support for format=flowed text display David Edmondson
  2018-12-22 12:10 ` [PATCH v2 1/3] notmuch: Include the format parameter of text/plain parts David Edmondson
@ 2018-12-22 12:10 ` David Edmondson
  2019-03-28 17:58   ` David Bremner
  2018-12-22 12:10 ` [PATCH v2 3/3] emacs: Process format=flowed text David Edmondson
  2 siblings, 1 reply; 8+ messages in thread
From: David Edmondson @ 2018-12-22 12:10 UTC (permalink / raw)
  To: notmuch

Some text/plain hook functions may wish to access the details of the
part that is being manipulated.
---
 emacs/notmuch-show.el |  2 +-
 emacs/notmuch-wash.el | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 78f1af47..b3cefcd9 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -744,7 +744,7 @@ will return nil if the CID is unknown or cannot be retrieved."
     (save-excursion
       (save-restriction
 	(narrow-to-region start (point-max))
-	(run-hook-with-args 'notmuch-show-insert-text/plain-hook msg depth))))
+	(run-hook-with-args 'notmuch-show-insert-text/plain-hook msg part depth))))
   t)
 
 (defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth button)
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 54108d93..54275ec7 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -222,7 +222,7 @@ that PREFIX should not include a newline."
 				   :type button-type)))
 	  (overlay-put overlay 'notmuch-wash-button button))))))
 
-(defun notmuch-wash-excerpt-citations (msg depth)
+(defun notmuch-wash-excerpt-citations (msg part depth)
   "Excerpt citations and up to one signature."
   (goto-char (point-min))
   (beginning-of-line)
@@ -267,7 +267,7 @@ that PREFIX should not include a newline."
 
 ;;
 
-(defun notmuch-wash-elide-blank-lines (msg depth)
+(defun notmuch-wash-elide-blank-lines (msg part depth)
   "Elide leading, trailing and successive blank lines."
 
   ;; Algorithm derived from `article-strip-multiple-blank-lines' in
@@ -295,7 +295,7 @@ that PREFIX should not include a newline."
 
 ;;
 
-(defun notmuch-wash-tidy-citations (msg depth)
+(defun notmuch-wash-tidy-citations (msg part depth)
   "Improve the display of cited regions of a message.
 
 Perform several transformations on the message body:
@@ -326,7 +326,7 @@ Perform several transformations on the message body:
 
 ;;
 
-(defun notmuch-wash-wrap-long-lines (msg depth)
+(defun notmuch-wash-wrap-long-lines (msg part depth)
   "Wrap long lines in the message.
 
 If `notmuch-wash-wrap-lines-length' is a number, this will wrap
@@ -392,7 +392,7 @@ original filename the sender had."
 	  (or (notmuch-wash-subject-to-patch-sequence-number subject) 1)
 	  (notmuch-wash-subject-to-filename subject 52)))
 
-(defun notmuch-wash-convert-inline-patch-to-part (msg depth)
+(defun notmuch-wash-convert-inline-patch-to-part (msg part depth)
   "Convert an inline patch into a fake 'text/x-diff' attachment.
 
 Given that this function guesses whether a buffer includes a
-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] emacs: Process format=flowed text
  2018-12-22 12:10 [PATCH v2 0/3] support for format=flowed text display David Edmondson
  2018-12-22 12:10 ` [PATCH v2 1/3] notmuch: Include the format parameter of text/plain parts David Edmondson
  2018-12-22 12:10 ` [PATCH v2 2/3] emacs: Pass the part to text/plain hook functions David Edmondson
@ 2018-12-22 12:10 ` David Edmondson
  2020-05-30 20:49   ` Jed Brown
  2 siblings, 1 reply; 8+ messages in thread
From: David Edmondson @ 2018-12-22 12:10 UTC (permalink / raw)
  To: notmuch

If a text/plain part is declared as format=flowed, apply the
appropriate transformation for display using flow-fill.el.
---
 emacs/notmuch-show.el |  3 ++-
 emacs/notmuch-wash.el | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index b3cefcd9..823a2d19 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -90,7 +90,8 @@ visible for any given message."
   :group 'notmuch-show
   :group 'notmuch-hooks)
 
-(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-wrap-long-lines
+(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-format=flowed
+						 notmuch-wash-wrap-long-lines
 						 notmuch-wash-tidy-citations
 						 notmuch-wash-elide-blank-lines
 						 notmuch-wash-excerpt-citations)
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 54275ec7..d4f0e883 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -426,6 +426,20 @@ for error."
 
 ;;
 
+(require 'flow-fill)
+
+(defun notmuch-wash-format=flowed (msg part depth)
+  "If the current part content-type included 'format=flowed',
+apply the appropriate transformation."
+  (when (string= (plist-get part :format) "flowed")
+    ;; Adjust `fill-flowed-display-column' to allow for the indent
+    ;; that we will later apply to this content.
+    (let ((fill-flowed-display-column (- (eval fill-flowed-display-column)
+					 (* depth notmuch-show-indent-messages-width))))
+      (fill-flowed))))
+
+;;
+
 (provide 'notmuch-wash)
 
 ;;; notmuch-wash.el ends here
-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] emacs: Pass the part to text/plain hook functions
  2018-12-22 12:10 ` [PATCH v2 2/3] emacs: Pass the part to text/plain hook functions David Edmondson
@ 2019-03-28 17:58   ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2019-03-28 17:58 UTC (permalink / raw)
  To: David Edmondson, notmuch

David Edmondson <dme@dme.org> writes:

> Some text/plain hook functions may wish to access the details of the
> part that is being manipulated.
> ---
>  emacs/notmuch-show.el |  2 +-
>  emacs/notmuch-wash.el | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 78f1af47..b3cefcd9 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -744,7 +744,7 @@ will return nil if the CID is unknown or cannot be retrieved."
>      (save-excursion
>        (save-restriction
>  	(narrow-to-region start (point-max))
> -	(run-hook-with-args 'notmuch-show-insert-text/plain-hook msg depth))))
> +	(run-hook-with-args 'notmuch-show-insert-text/plain-hook msg part depth))))
>    t)
>  

I wonder if it would be better to have depth last as an optional
parameter, so that existing user written hooks don't break. I don't know
if
1) that works in practice
2) there are a non-trivial number of user written text/plain hooks

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] emacs: Process format=flowed text
  2018-12-22 12:10 ` [PATCH v2 3/3] emacs: Process format=flowed text David Edmondson
@ 2020-05-30 20:49   ` Jed Brown
  2020-05-31 11:47     ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: Jed Brown @ 2020-05-30 20:49 UTC (permalink / raw)
  To: David Edmondson, notmuch

Was this proposal dropped or did it just get lost?

David Edmondson <dme@dme.org> writes:

> If a text/plain part is declared as format=flowed, apply the
> appropriate transformation for display using flow-fill.el.
> ---
>  emacs/notmuch-show.el |  3 ++-
>  emacs/notmuch-wash.el | 14 ++++++++++++++
>  2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index b3cefcd9..823a2d19 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -90,7 +90,8 @@ visible for any given message."
>    :group 'notmuch-show
>    :group 'notmuch-hooks)
>  
> -(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-wrap-long-lines
> +(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-format=flowed
> +						 notmuch-wash-wrap-long-lines
>  						 notmuch-wash-tidy-citations
>  						 notmuch-wash-elide-blank-lines
>  						 notmuch-wash-excerpt-citations)
> diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
> index 54275ec7..d4f0e883 100644
> --- a/emacs/notmuch-wash.el
> +++ b/emacs/notmuch-wash.el
> @@ -426,6 +426,20 @@ for error."
>  
>  ;;
>  
> +(require 'flow-fill)
> +
> +(defun notmuch-wash-format=flowed (msg part depth)
> +  "If the current part content-type included 'format=flowed',
> +apply the appropriate transformation."
> +  (when (string= (plist-get part :format) "flowed")
> +    ;; Adjust `fill-flowed-display-column' to allow for the indent
> +    ;; that we will later apply to this content.
> +    (let ((fill-flowed-display-column (- (eval fill-flowed-display-column)
> +					 (* depth notmuch-show-indent-messages-width))))
> +      (fill-flowed))))
> +
> +;;
> +
>  (provide 'notmuch-wash)
>  
>  ;;; notmuch-wash.el ends here
> -- 
> 2.11.0
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] emacs: Process format=flowed text
  2020-05-30 20:49   ` Jed Brown
@ 2020-05-31 11:47     ` David Bremner
  2020-06-01  0:11       ` Jed Brown
  0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2020-05-31 11:47 UTC (permalink / raw)
  To: Jed Brown, David Edmondson, notmuch

Jed Brown <jed@59A2.org> writes:

> Was this proposal dropped or did it just get lost?
>

The latter, I think. Thanks for pinging. It looks like that last
discussion was my comment about breaking the API. Any feedback on that,
either of you?

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] emacs: Process format=flowed text
  2020-05-31 11:47     ` David Bremner
@ 2020-06-01  0:11       ` Jed Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Jed Brown @ 2020-06-01  0:11 UTC (permalink / raw)
  To: David Bremner, David Edmondson, notmuch

David Bremner <david@tethera.net> writes:

> The latter, I think. Thanks for pinging. It looks like that last 
> discussion was my comment about breaking the API. Any feedback 
> on that, either of you?

I don't see why making the argument optional wouldn't work.  However, I
tried applying the patch and am not seeing a change in the display of
format=flowed messages.  It doesn't reflow to my window width
(regardless of whether it is wider or narrower than the soft line breaks
in the format=flowed message).  (I noticed this patch when considering
use of a proportional font for mail reading.)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-22 12:10 [PATCH v2 0/3] support for format=flowed text display David Edmondson
2018-12-22 12:10 ` [PATCH v2 1/3] notmuch: Include the format parameter of text/plain parts David Edmondson
2018-12-22 12:10 ` [PATCH v2 2/3] emacs: Pass the part to text/plain hook functions David Edmondson
2019-03-28 17:58   ` David Bremner
2018-12-22 12:10 ` [PATCH v2 3/3] emacs: Process format=flowed text David Edmondson
2020-05-30 20:49   ` Jed Brown
2020-05-31 11:47     ` David Bremner
2020-06-01  0:11       ` Jed Brown

unofficial mirror of notmuch@notmuchmail.org

Archives are clonable:
	git clone --mirror https://yhetil.org/notmuch/0 notmuch/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 notmuch notmuch/ https://yhetil.org/notmuch \
		notmuch@notmuchmail.org
	public-inbox-index notmuch

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.notmuch.general
	nntp://news.gmane.io/gmane.mail.notmuch.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git