unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v1 3/3] emacs: Process format=flowed text
Date: Fri, 21 Dec 2018 14:43:22 +0000	[thread overview]
Message-ID: <20181221144322.27942-4-dme@dme.org> (raw)
In-Reply-To: <20181221144322.27942-1-dme@dme.org>

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

      parent reply	other threads:[~2018-12-21 14:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21 14:43 [PATCH v1 0/3] support for format=flowed display David Edmondson
2018-12-21 14:43 ` [PATCH v1 1/3] notmuch: Include the format parameter of text/plain parts David Edmondson
2018-12-21 22:41   ` David Bremner
2018-12-22 12:08     ` David Edmondson
2018-12-21 14:43 ` [PATCH v1 2/3] emacs: Pass the part to text/plain hook functions David Edmondson
2018-12-21 14:43 ` David Edmondson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181221144322.27942-4-dme@dme.org \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).