--- /dev/null
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 9573C431FC2\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 07:39:18 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id NwsnQOGx2q3b for <notmuch@notmuchmail.org>;\r
+ Mon, 6 Feb 2012 07:39:17 -0800 (PST)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+ [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 964FD431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 07:39:16 -0800 (PST)\r
+Received: by werb10 with SMTP id b10so5266654wer.26\r
+ for <notmuch@notmuchmail.org>; Mon, 06 Feb 2012 07:39:14 -0800 (PST)\r
+Received: by 10.216.138.8 with SMTP id z8mr7076894wei.20.1328542754496;\r
+ Mon, 06 Feb 2012 07:39:14 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+ (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+ by mx.google.com with ESMTPS id j16sm47483467wie.4.2012.02.06.07.39.10\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Mon, 06 Feb 2012 07:39:11 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 4D825A05C6; Mon, 6 Feb 2012 15:39:09 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: Add more processing of displayed headers.\r
+Date: Mon, 6 Feb 2012 15:39:05 +0000\r
+Message-Id: <1328542748-19530-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.8.3\r
+In-Reply-To: <1328542748-19530-1-git-send-email-dme@dme.org>\r
+References: <1327052612-1040-1-git-send-email-dme@dme.org>\r
+ <1328542748-19530-1-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 06 Feb 2012 15:39:19 -0000\r
+\r
+Wrap headers to the width of the window and indent continuations.\r
+---\r
+ emacs/notmuch-show.el | 43 ++++++++++++++++++++++++++++++++++++-------\r
+ 1 files changed, 36 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 7469e2e..a589d37 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -68,9 +68,16 @@ any given message."\r
+ :type 'boolean\r
+ :group 'notmuch-show)\r
+ \r
+-(defvar notmuch-show-markup-headers-hook '(notmuch-show-colour-headers)\r
++(defcustom notmuch-show-markup-headers-hook '(notmuch-show-colour-headers\r
++ notmuch-show-fill-headers\r
++ notmuch-show-indent-continuations)\r
+ "A list of functions called to decorate the headers listed in\r
+-`notmuch-message-headers'.")\r
++`notmuch-message-headers'."\r
++ :type 'hook\r
++ :options '(notmuch-show-colour-headers\r
++ notmuch-show-fill-headers\r
++ notmuch-show-indent-continuations)\r
++ :group 'notmuch-show)\r
+ \r
+ (defcustom notmuch-show-hook '(notmuch-show-turn-on-visual-line-mode)\r
+ "Functions called after populating a `notmuch-show' buffer."\r
+@@ -269,13 +276,35 @@ operation on the contents of the current buffer."\r
+ (overlay-put (make-overlay (point) (re-search-forward ".*$"))\r
+ 'face face)))\r
+ \r
+-(defun notmuch-show-colour-headers ()\r
++(defun notmuch-show-colour-headers (depth)\r
+ "Apply some colouring to the current headers."\r
+ (goto-char (point-min))\r
+ (while (looking-at "^[A-Za-z][-A-Za-z0-9]*:")\r
+ (notmuch-show-fontify-header)\r
+ (forward-line)))\r
+ \r
++(defun notmuch-show-fill-headers (depth)\r
++ "Wrap the text of the current headers."\r
++\r
++ ;; '-5' to allow for the indentation code.\r
++ (let ((fill-column (- (window-width) depth 5)))\r
++ (goto-char (point-min))\r
++ (while (not (eobp))\r
++ (let ((start (point)))\r
++ (end-of-line)\r
++ ;; We're left at the start of the next line, so there's no need\r
++ ;; to move forward after filling.\r
++ (fill-region-as-paragraph start (point))))))\r
++\r
++(defun notmuch-show-indent-continuations (depth)\r
++ "Indent any continuation lines."\r
++ (goto-char (point-min))\r
++ (while (not (eobp))\r
++ (if (not (looking-at "^[A-Za-z][-A-Za-z0-9]*:"))\r
++ ;; Four spaces tends to work well with 'To' and 'Cc' headers.\r
++ (insert " "))\r
++ (forward-line)))\r
++\r
+ (defun notmuch-show-spaces-n (n)\r
+ "Return a string comprised of `n' spaces."\r
+ (make-string n ? ))\r
+@@ -366,7 +395,7 @@ message at DEPTH in the current thread."\r
+ "Insert a single header."\r
+ (insert header ": " header-value "\n"))\r
+ \r
+-(defun notmuch-show-insert-headers (headers)\r
++(defun notmuch-show-insert-headers (headers depth)\r
+ "Insert the headers of the current message."\r
+ (let ((start (point)))\r
+ (mapc (lambda (header)\r
+@@ -379,7 +408,7 @@ message at DEPTH in the current thread."\r
+ (save-excursion\r
+ (save-restriction\r
+ (narrow-to-region start (point-max))\r
+- (run-hooks 'notmuch-show-markup-headers-hook)))))\r
++ (run-hook-with-args 'notmuch-show-markup-headers-hook depth)))))\r
+ \r
+ (define-button-type 'notmuch-show-part-button-type\r
+ 'action 'notmuch-show-part-button-default\r
+@@ -671,7 +700,7 @@ current buffer, if possible."\r
+ ;; Override `notmuch-message-headers' to force `From' to be\r
+ ;; displayed.\r
+ (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date")))\r
+- (notmuch-show-insert-headers (plist-get message :headers)))\r
++ (notmuch-show-insert-headers (plist-get message :headers) 0))\r
+ \r
+ ;; Blank line after headers to be compatible with the normal\r
+ ;; message display.\r
+@@ -864,7 +893,7 @@ current buffer, if possible."\r
+ ;; Set `headers-start' to point after the 'Subject:' header to be\r
+ ;; compatible with the existing implementation. This just sets it\r
+ ;; to after the first header.\r
+- (notmuch-show-insert-headers headers)\r
++ (notmuch-show-insert-headers headers depth)\r
+ (save-excursion\r
+ (goto-char content-start)\r
+ ;; If the subject of this message is the same as that of the\r
+-- \r
+1.7.8.3\r
+\r