[PATCH 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / 68 / 88d5c5ace22f4e9d526a7bfb55029af58f78e3
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 E4BD3431FAF\r
6         for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 00:17:57 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 H-wpUlnol1tI for <notmuch@notmuchmail.org>;\r
16         Thu, 26 Jan 2012 00:17:57 -0800 (PST)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  037E9431FB6    for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 00:17:56 -0800\r
21  (PST)\r
22 Received: by wgbdt12 with SMTP id dt12so261044wgb.2\r
23         for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 00:17:55 -0800 (PST)\r
24 Received: by 10.180.109.198 with SMTP id hu6mr2336871wib.16.1327565875804;\r
25         Thu, 26 Jan 2012 00:17:55 -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 q7sm4041570wix.5.2012.01.26.00.17.53\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Thu, 26 Jan 2012 00:17:54 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id 75B759FFA4; Thu, 26 Jan 2012 08:17:52 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH 2/2] emacs: Add more processing of displayed headers.\r
36 Date: Thu, 26 Jan 2012 08:17:51 +0000\r
37 Message-Id: <1327565871-19729-3-git-send-email-dme@dme.org>\r
38 X-Mailer: git-send-email 1.7.8.3\r
39 In-Reply-To: <1327565871-19729-1-git-send-email-dme@dme.org>\r
40 References: <1327565871-19729-1-git-send-email-dme@dme.org>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Thu, 26 Jan 2012 08:17:58 -0000\r
54 \r
55 Wrap headers to the width of the window and indent continuations.\r
56 ---\r
57  emacs/notmuch-show.el |   43 ++++++++++++++++++++++++++++++++++++-------\r
58  1 files changed, 36 insertions(+), 7 deletions(-)\r
59 \r
60 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
61 index effd2fd..ad286d1 100644\r
62 --- a/emacs/notmuch-show.el\r
63 +++ b/emacs/notmuch-show.el\r
64 @@ -67,9 +67,16 @@ any given message."\r
65    :type 'boolean\r
66    :group 'notmuch-show)\r
67  \r
68 -(defvar notmuch-show-markup-headers-hook '(notmuch-show-colour-headers)\r
69 +(defcustom notmuch-show-markup-headers-hook '(notmuch-show-colour-headers\r
70 +                                             notmuch-show-fill-headers\r
71 +                                             notmuch-show-indent-continuations)\r
72    "A list of functions called to decorate the headers listed in\r
73 -`notmuch-message-headers'.")\r
74 +`notmuch-message-headers'."\r
75 +  :type 'hook\r
76 +  :options '(notmuch-show-colour-headers\r
77 +            notmuch-show-fill-headers\r
78 +            notmuch-show-indent-continuations)\r
79 +  :group 'notmuch-show)\r
80  \r
81  (defcustom notmuch-show-hook '(notmuch-show-turn-on-visual-line-mode)\r
82    "Functions called after populating a `notmuch-show' buffer."\r
83 @@ -268,13 +275,35 @@ operation on the contents of the current buffer."\r
84      (overlay-put (make-overlay (point) (re-search-forward ".*$"))\r
85                  'face face)))\r
86  \r
87 -(defun notmuch-show-colour-headers ()\r
88 +(defun notmuch-show-colour-headers (depth)\r
89    "Apply some colouring to the current headers."\r
90    (goto-char (point-min))\r
91    (while (looking-at "^[A-Za-z][-A-Za-z0-9]*:")\r
92      (notmuch-show-fontify-header)\r
93      (forward-line)))\r
94  \r
95 +(defun notmuch-show-fill-headers (depth)\r
96 +  "Wrap the text of the current headers."\r
97 +\r
98 +  ;; '-5' to allow for the indentation code.\r
99 +  (let ((fill-column (- (window-width) depth 5)))\r
100 +    (goto-char (point-min))\r
101 +    (while (not (eobp))\r
102 +      (let ((start (point)))\r
103 +       (end-of-line)\r
104 +       ;; We're left at the start of the next line, so there's no need\r
105 +       ;; to move forward after filling.\r
106 +       (fill-region-as-paragraph start (point))))))\r
107 +\r
108 +(defun notmuch-show-indent-continuations (depth)\r
109 +  "Indent any continuation lines."\r
110 +  (goto-char (point-min))\r
111 +  (while (not (eobp))\r
112 +    (if (not (looking-at "^[A-Za-z][-A-Za-z0-9]*:"))\r
113 +       ;; Four spaces tends to work well with 'To' and 'Cc' headers.\r
114 +       (insert "    "))\r
115 +    (forward-line)))\r
116 +\r
117  (defun notmuch-show-spaces-n (n)\r
118    "Return a string comprised of `n' spaces."\r
119    (make-string n ? ))\r
120 @@ -329,7 +358,7 @@ message at DEPTH in the current thread."\r
121    "Insert a single header."\r
122    (insert header ": " header-value "\n"))\r
123  \r
124 -(defun notmuch-show-insert-headers (headers)\r
125 +(defun notmuch-show-insert-headers (headers depth)\r
126    "Insert the headers of the current message."\r
127    (let ((start (point)))\r
128      (mapc (lambda (header)\r
129 @@ -342,7 +371,7 @@ message at DEPTH in the current thread."\r
130      (save-excursion\r
131        (save-restriction\r
132         (narrow-to-region start (point-max))\r
133 -       (run-hooks 'notmuch-show-markup-headers-hook)))))\r
134 +       (run-hook-with-args 'notmuch-show-markup-headers-hook depth)))))\r
135  \r
136  (define-button-type 'notmuch-show-part-button-type\r
137    'action 'notmuch-show-part-button-default\r
138 @@ -633,7 +662,7 @@ current buffer, if possible."\r
139      ;; Override `notmuch-message-headers' to force `From' to be\r
140      ;; displayed.\r
141      (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date")))\r
142 -      (notmuch-show-insert-headers (plist-get message :headers)))\r
143 +      (notmuch-show-insert-headers (plist-get message :headers) 0))\r
144  \r
145      ;; Blank line after headers to be compatible with the normal\r
146      ;; message display.\r
147 @@ -826,7 +855,7 @@ current buffer, if possible."\r
148      ;; Set `headers-start' to point after the 'Subject:' header to be\r
149      ;; compatible with the existing implementation. This just sets it\r
150      ;; to after the first header.\r
151 -    (notmuch-show-insert-headers headers)\r
152 +    (notmuch-show-insert-headers headers depth)\r
153      ;; Headers should include a blank line (backwards compatibility).\r
154      (insert "\n")\r
155      (save-excursion\r
156 -- \r
157 1.7.8.3\r
158 \r