1 Return-Path: <dme@dme.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 9573C431FC2
\r
6 for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 07:39:18 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id NwsnQOGx2q3b for <notmuch@notmuchmail.org>;
\r
16 Mon, 6 Feb 2012 07:39:17 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 964FD431FBC
\r
21 for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 07:39:16 -0800 (PST)
\r
22 Received: by werb10 with SMTP id b10so5266654wer.26
\r
23 for <notmuch@notmuchmail.org>; Mon, 06 Feb 2012 07:39:14 -0800 (PST)
\r
24 Received: by 10.216.138.8 with SMTP id z8mr7076894wei.20.1328542754496;
\r
25 Mon, 06 Feb 2012 07:39:14 -0800 (PST)
\r
26 Received: from hotblack-desiato.hh.sledj.net
\r
27 (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])
\r
28 by mx.google.com with ESMTPS id j16sm47483467wie.4.2012.02.06.07.39.10
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Mon, 06 Feb 2012 07:39:11 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id 4D825A05C6; Mon, 6 Feb 2012 15:39:09 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: [PATCH v2] emacs: Add more processing of displayed headers.
\r
36 Date: Mon, 6 Feb 2012 15:39:05 +0000
\r
37 Message-Id: <1328542748-19530-2-git-send-email-dme@dme.org>
\r
38 X-Mailer: git-send-email 1.7.8.3
\r
39 In-Reply-To: <1328542748-19530-1-git-send-email-dme@dme.org>
\r
40 References: <1327052612-1040-1-git-send-email-dme@dme.org>
\r
41 <1328542748-19530-1-git-send-email-dme@dme.org>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Mon, 06 Feb 2012 15:39:19 -0000
\r
56 Wrap headers to the width of the window and indent continuations.
\r
58 emacs/notmuch-show.el | 43 ++++++++++++++++++++++++++++++++++++-------
\r
59 1 files changed, 36 insertions(+), 7 deletions(-)
\r
61 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
62 index 7469e2e..a589d37 100644
\r
63 --- a/emacs/notmuch-show.el
\r
64 +++ b/emacs/notmuch-show.el
\r
65 @@ -68,9 +68,16 @@ any given message."
\r
67 :group 'notmuch-show)
\r
69 -(defvar notmuch-show-markup-headers-hook '(notmuch-show-colour-headers)
\r
70 +(defcustom notmuch-show-markup-headers-hook '(notmuch-show-colour-headers
\r
71 + notmuch-show-fill-headers
\r
72 + notmuch-show-indent-continuations)
\r
73 "A list of functions called to decorate the headers listed in
\r
74 -`notmuch-message-headers'.")
\r
75 +`notmuch-message-headers'."
\r
77 + :options '(notmuch-show-colour-headers
\r
78 + notmuch-show-fill-headers
\r
79 + notmuch-show-indent-continuations)
\r
80 + :group 'notmuch-show)
\r
82 (defcustom notmuch-show-hook '(notmuch-show-turn-on-visual-line-mode)
\r
83 "Functions called after populating a `notmuch-show' buffer."
\r
84 @@ -269,13 +276,35 @@ operation on the contents of the current buffer."
\r
85 (overlay-put (make-overlay (point) (re-search-forward ".*$"))
\r
88 -(defun notmuch-show-colour-headers ()
\r
89 +(defun notmuch-show-colour-headers (depth)
\r
90 "Apply some colouring to the current headers."
\r
91 (goto-char (point-min))
\r
92 (while (looking-at "^[A-Za-z][-A-Za-z0-9]*:")
\r
93 (notmuch-show-fontify-header)
\r
96 +(defun notmuch-show-fill-headers (depth)
\r
97 + "Wrap the text of the current headers."
\r
99 + ;; '-5' to allow for the indentation code.
\r
100 + (let ((fill-column (- (window-width) depth 5)))
\r
101 + (goto-char (point-min))
\r
102 + (while (not (eobp))
\r
103 + (let ((start (point)))
\r
105 + ;; We're left at the start of the next line, so there's no need
\r
106 + ;; to move forward after filling.
\r
107 + (fill-region-as-paragraph start (point))))))
\r
109 +(defun notmuch-show-indent-continuations (depth)
\r
110 + "Indent any continuation lines."
\r
111 + (goto-char (point-min))
\r
112 + (while (not (eobp))
\r
113 + (if (not (looking-at "^[A-Za-z][-A-Za-z0-9]*:"))
\r
114 + ;; Four spaces tends to work well with 'To' and 'Cc' headers.
\r
118 (defun notmuch-show-spaces-n (n)
\r
119 "Return a string comprised of `n' spaces."
\r
120 (make-string n ? ))
\r
121 @@ -366,7 +395,7 @@ message at DEPTH in the current thread."
\r
122 "Insert a single header."
\r
123 (insert header ": " header-value "\n"))
\r
125 -(defun notmuch-show-insert-headers (headers)
\r
126 +(defun notmuch-show-insert-headers (headers depth)
\r
127 "Insert the headers of the current message."
\r
128 (let ((start (point)))
\r
129 (mapc (lambda (header)
\r
130 @@ -379,7 +408,7 @@ message at DEPTH in the current thread."
\r
133 (narrow-to-region start (point-max))
\r
134 - (run-hooks 'notmuch-show-markup-headers-hook)))))
\r
135 + (run-hook-with-args 'notmuch-show-markup-headers-hook depth)))))
\r
137 (define-button-type 'notmuch-show-part-button-type
\r
138 'action 'notmuch-show-part-button-default
\r
139 @@ -671,7 +700,7 @@ current buffer, if possible."
\r
140 ;; Override `notmuch-message-headers' to force `From' to be
\r
142 (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date")))
\r
143 - (notmuch-show-insert-headers (plist-get message :headers)))
\r
144 + (notmuch-show-insert-headers (plist-get message :headers) 0))
\r
146 ;; Blank line after headers to be compatible with the normal
\r
147 ;; message display.
\r
148 @@ -864,7 +893,7 @@ current buffer, if possible."
\r
149 ;; Set `headers-start' to point after the 'Subject:' header to be
\r
150 ;; compatible with the existing implementation. This just sets it
\r
151 ;; to after the first header.
\r
152 - (notmuch-show-insert-headers headers)
\r
153 + (notmuch-show-insert-headers headers depth)
\r
155 (goto-char content-start)
\r
156 ;; If the subject of this message is the same as that of the
\r