Re: message-default-mail-headers not working in notmuch 0.22
[notmuch-archives.git] / 1f / 1de5960b9e63626cf1b6ee545a21c53b750d09
1 Return-Path: <markwalters1009@gmail.com>\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 309A4431E84\r
6         for <notmuch@notmuchmail.org>; Thu,  5 Dec 2013 12:04:56 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id P5ck4EiXXhOn for <notmuch@notmuchmail.org>;\r
18         Thu,  5 Dec 2013 12:04:49 -0800 (PST)\r
19 Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com\r
20         [209.85.212.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 6FD12431FD8\r
23         for <notmuch@notmuchmail.org>; Thu,  5 Dec 2013 12:04:49 -0800 (PST)\r
24 Received: by mail-wi0-f178.google.com with SMTP id ca18so216068wib.17\r
25         for <notmuch@notmuchmail.org>; Thu, 05 Dec 2013 12:04:48 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=+1n+4a7WWXFLfMTwF3MGnzUAOPyaYy0Zw6dwT4JrMnA=;\r
29         b=l2Dwpb+T9k4z9e7Bl+fZYMrhhkYDJOJkWMsZjszOEPRp6P6g4DK8JGQkG9xA9aW8GF\r
30         rXpw3MCagUNvrzzLek5l2Ca1+H+O5wwEZi8+wZvNIh21wGXKwLiuHL3KeJRUfcaaZEyV\r
31         0ZIPE1Z7u6ua7+8ggmN8kRRyiUVGhlyndS85/VGdSR/ZjWm0Mvp2qHdVRp3YEaqWMO+W\r
32         1YcBl/9BHz5gNzIn6Mumn7dJFu/dZnMSsPvN/htQX5AQD0IXdpsT+yLGuY+V9E5NB2lj\r
33         v9e8N31DGolnjj9d7U3ek9P+xOJOz9sQ3IaJhsIdfP/SJun9He9+KX9PhYzJjOUHhEX0\r
34         m3Nw==\r
35 X-Received: by 10.194.60.73 with SMTP id f9mr19097793wjr.65.1386273888231;\r
36         Thu, 05 Dec 2013 12:04:48 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id nb16sm9433226wic.0.2013.12.05.12.04.46\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Thu, 05 Dec 2013 12:04:47 -0800 (PST)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH WIP v3 1/3] emacs: show: mark tags changed since buffer loaded\r
45 Date: Thu,  5 Dec 2013 20:04:29 +0000\r
46 Message-Id: <1386273871-24214-2-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 In-Reply-To: <1386273871-24214-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1386273871-24214-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Thu, 05 Dec 2013 20:04:56 -0000\r
63 \r
64 This shows any tags changed in the show buffer since it was loaded or\r
65 refreshed. By default a removed tag is displayed with strike-through\r
66 in red and an added tag is displayed underlined in green.\r
67 \r
68 One nice feature is that this makes it clear when a message was unread\r
69 when you first loaded the buffer (previously the unread tag could be\r
70 removed before a user realised that it had been unread).\r
71 ---\r
72  emacs/notmuch-show.el |   34 +++++++++++++++++++++++++++++-----\r
73  emacs/notmuch-tag.el  |   30 ++++++++++++++++++++----------\r
74  2 files changed, 49 insertions(+), 15 deletions(-)\r
75 \r
76 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
77 index 784644c..d64d407 100644\r
78 --- a/emacs/notmuch-show.el\r
79 +++ b/emacs/notmuch-show.el\r
80 @@ -211,6 +211,18 @@ For example, if you wanted to remove an \"unread\" tag and add a\r
81    :type '(repeat string)\r
82    :group 'notmuch-show)\r
83  \r
84 +(defface notmuch-show-deleted-tag-face\r
85 +  '((t :strike-through "red" :inherit 'notmuch-tag-face))\r
86 +  "Face for tags that have been removed"\r
87 +  :group 'notmuch-show\r
88 +  :group 'notmuch-faces)\r
89 +\r
90 +(defface notmuch-show-added-tag-face\r
91 +  '((t :underline "green"))\r
92 +  "Face for tags that have been added"\r
93 +  :group 'notmuch-show\r
94 +  :group 'notmuch-faces)\r
95 +\r
96  \r
97  (defmacro with-current-notmuch-show-message (&rest body)\r
98    "Evaluate body with current buffer set to the text of current message"\r
99 @@ -341,11 +353,21 @@ operation on the contents of the current buffer."\r
100    "Update the displayed tags of the current message."\r
101    (save-excursion\r
102      (goto-char (notmuch-show-message-top))\r
103 -    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
104 -       (let ((inhibit-read-only t))\r
105 -         (replace-match (concat "("\r
106 -                                (notmuch-tag-format-tags tags)\r
107 -                                ")"))))))\r
108 +    (let* ((orig-tags (notmuch-show-get-prop :orig-tags))\r
109 +          (all-tags (sort (delete-dups (append tags orig-tags)) #'string<))\r
110 +          (display-tags (mapcar (lambda (tag) (cond ((and (member tag tags) (member tag orig-tags))\r
111 +                                                     tag)\r
112 +                                                    ((not (member tag tags))\r
113 +                                                     (cons tag 'deleted))\r
114 +                                                    ((not (member tag orig-tags))\r
115 +                                                     (cons tag 'added))))\r
116 +                                all-tags)))\r
117 +\r
118 +      (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
119 +         (let ((inhibit-read-only t))\r
120 +           (replace-match (concat "("\r
121 +                                  (notmuch-tag-format-tags display-tags)\r
122 +                                  ")")))))))\r
123  \r
124  (defun notmuch-clean-address (address)\r
125    "Try to clean a single email ADDRESS for display. Return a cons\r
126 @@ -1167,6 +1189,8 @@ function is used."\r
127  \r
128        (jit-lock-register #'notmuch-show-buttonise-links)\r
129  \r
130 +      (notmuch-show-mapc (lambda () (notmuch-show-set-prop :orig-tags (notmuch-show-get-tags))))\r
131 +\r
132        ;; Set the header line to the subject of the first message.\r
133        (setq header-line-format (notmuch-sanitize (notmuch-show-strip-re (notmuch-show-get-subject))))\r
134  \r
135 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
136 index b60f46c..fac2c3b 100644\r
137 --- a/emacs/notmuch-tag.el\r
138 +++ b/emacs/notmuch-tag.el\r
139 @@ -137,16 +137,26 @@ This can be used with `notmuch-tag-format-image-data'."\r
140  \r
141  (defun notmuch-tag-format-tag (tag)\r
142    "Format TAG by looking into `notmuch-tag-formats'."\r
143 -  (let ((formats (assoc tag notmuch-tag-formats)))\r
144 -    (cond\r
145 -     ((null formats)           ;; - Tag not in `notmuch-tag-formats',\r
146 -      tag)                     ;;   the format is the tag itself.\r
147 -     ((null (cdr formats))     ;; - Tag was deliberately hidden,\r
148 -      nil)                     ;;   no format must be returned\r
149 -     (t                                ;; - Tag was found and has formats,\r
150 -      (let ((tag tag))         ;;   we must apply all the formats.\r
151 -       (dolist (format (cdr formats) tag)\r
152 -         (setq tag (eval format))))))))\r
153 +  (let* ((status (if (consp tag) (cdr tag)))\r
154 +        (tag (if (consp tag) (car tag) tag))\r
155 +        (formats (append (assoc tag notmuch-tag-formats)))\r
156 +        (tag\r
157 +         (cond\r
158 +          ((null formats)              ;; - Tag not in `notmuch-tag-formats',\r
159 +           tag)                        ;;   the format is the tag itself.\r
160 +          ((null (cdr formats))        ;; - Tag was deliberately hidden,\r
161 +           nil)                        ;;   no format must be returned\r
162 +          (t                           ;; - Tag was found and has formats,\r
163 +           (let ((tag tag))            ;;   we must apply all the formats.\r
164 +             (dolist (format (cdr formats) tag)\r
165 +               (setq tag (eval format))))))))\r
166 +    (when tag\r
167 +      (cond\r
168 +       ((eq status 'deleted)\r
169 +       (notmuch-combine-face-text-property-string tag 'notmuch-show-deleted-tag-face))\r
170 +       ((eq status 'added)\r
171 +       (notmuch-combine-face-text-property-string tag 'notmuch-show-added-tag-face))\r
172 +       (t tag)))))\r
173  \r
174  (defun notmuch-tag-format-tags (tags)\r
175    "Return a string representing formatted TAGS."\r
176 -- \r
177 1.7.9.1\r
178 \r