Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d0 / e5aad9ddb9ed9d8156c741604c52710a55fe5f
1 Return-Path: <damien.cassou@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 BE591431FB6\r
6         for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 12:11:26 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id QwEj20YBmlw8 for <notmuch@notmuchmail.org>;\r
17         Sun, 28 Oct 2012 12:11:26 -0700 (PDT)\r
18 Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com\r
19         [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 2097E431FAF\r
22         for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 12:11:25 -0700 (PDT)\r
23 Received: by mail-wi0-f169.google.com with SMTP id hq4so1620521wib.2\r
24         for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 12:11:23 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:x-mailer;\r
27         bh=f/0dWmGrL1TR/3DwWEAj1Oo768CiBwmLGm998VRwXs8=;\r
28         b=lz/SHpvrSJ0cFgnKVLa2yE6/XhdwqLaSeRnJv6nWwsUiGVTlpnFaQu/eczdExXm07h\r
29         GBBWFZQuLudrlPv3V3iVvq7ypx6KZr+KLx1vCCYbO7ynF6LMiX7ZiWWg9x54xrfOppMv\r
30         Robopc5oXxCVycNfdes/Sw6cQucJr1YCD4SPngUG5dbbGzEM0yITApe9KmULIVrBN8hq\r
31         7z4u00d+bEpM5sB58LsD9c5nmJKX3booYZnrMXQP3oyQIVMpWWD1AAsW4f6YcmLbEmIh\r
32         SFgplxB4NNIc+16eDRhXOsVtiiSdSiw8BdjkzMuXRLjRZSZg0e11UGXeWVxkS9YL4x5k\r
33         SVyg==\r
34 Received: by 10.180.84.202 with SMTP id b10mr12217017wiz.13.1351451483547;\r
35         Sun, 28 Oct 2012 12:11:23 -0700 (PDT)\r
36 Received: from localhost.localdomain (ble59-4-82-228-190-150.fbx.proxad.net.\r
37         [82.228.190.150])\r
38         by mx.google.com with ESMTPS id az2sm6991606wib.10.2012.10.28.12.11.21\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sun, 28 Oct 2012 12:11:22 -0700 (PDT)\r
41 From: Damien Cassou <damien.cassou@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH] emacs: Function to query the list of labels from a thread-id\r
44 Date: Sun, 28 Oct 2012 20:11:18 +0100\r
45 Message-Id: <1351451478-11792-1-git-send-email-damien.cassou@gmail.com>\r
46 X-Mailer: git-send-email 1.7.10.4\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Sun, 28 Oct 2012 19:11:26 -0000\r
60 \r
61 This patch adds `notmuch-query-thread-labels-from-id' and\r
62 corresponding test. This function returns the labels of thread whose\r
63 id is passed as argument. The thread labels are the union of the\r
64 labels of emails in the thread. I need this function to integrate\r
65 notmuch-labeler.\r
66 \r
67 Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
68 ---\r
69  emacs/notmuch-query.el |   16 ++++++++++++++++\r
70  test/emacs             |   23 +++++++++++++++++++++++\r
71  2 files changed, 39 insertions(+)\r
72 \r
73 diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el\r
74 index d66baea..8b9a41d 100644\r
75 --- a/emacs/notmuch-query.el\r
76 +++ b/emacs/notmuch-query.el\r
77 @@ -81,4 +81,20 @@ See the function notmuch-query-get-threads for more information."\r
78     (lambda (msg) (plist-get msg :id))\r
79     (notmuch-query-get-threads search-terms)))\r
80 \r
81 +(defun notmuch-query-thread-labels-from-id (thread-id)\r
82 +  "Return the labels of thread whose id is THREAD-ID.\r
83 +The thread labels are the union of the labels of emails in the\r
84 +thread."\r
85 +  (let ((label-lists\r
86 +        (notmuch-query-map-forest\r
87 +         (lambda (msg) (plist-get msg :tags))\r
88 +         (car (notmuch-query-get-threads\r
89 +               (list (concat "thread:" thread-id)))))))\r
90 +    (case (length label-lists)\r
91 +      (0 nil)\r
92 +      (1 (car label-lists))\r
93 +      (otherwise (reduce (lambda (l1 l2)\r
94 +                          (union l1 l2 :test 'string=))\r
95 +                        label-lists)))))\r
96 +\r
97  (provide 'notmuch-query)\r
98 diff --git a/test/emacs b/test/emacs\r
99 index 44f641e..3e8bdb8 100755\r
100 --- a/test/emacs\r
101 +++ b/test/emacs\r
102 @@ -820,5 +820,28 @@ Date: Fri, 05 Jan 2001 15:43:57 +0000\r
103  EOF\r
104  test_expect_equal_file OUTPUT EXPECTED\r
105 \r
106 +test_begin_subtest "Extracting all labels from a thread"\r
107 +add_message \\r
108 +    '[subject]="Extracting all labels from a thread"' \\r
109 +    '[body]="body 1"'\r
110 +first=${gen_msg_cnt}\r
111 +parent=${gen_msg_id}\r
112 +add_message \\r
113 +    '[subject]="Extracting all labels from a thread"' \\r
114 +    '[body]="body 2"' \\r
115 +    "[in-reply-to]=\<$parent\>"\r
116 +add_message \\r
117 +    '[subject]="Extracting all labels from a thread"' \\r
118 +    '[body]="body 3"' \\r
119 +    "[in-reply-to]=\<$parent\>"\r
120 +latest=${gen_msg_id}\r
121 +# Extract the thread-id from one of the emails\r
122 +thread_id=$(notmuch search id:${latest} | sed -e "s/thread:\([a-f0-9]*\).*/\1/")\r
123 +# Add tag "mytagfoo" to one of the emails\r
124 +notmuch tag +mytagfoo id:${latest}\r
125 +test_emacs_expect_t \\r
126 +    "(let ((output (notmuch-query-thread-labels-from-id \"${thread_id}\"))\r
127 +           (expected '(\"inbox\" \"mytagfoo\" \"unread\")))\r
128 +      (notmuch-test-expect-equal output expected))"\r
129 \r
130  test_done\r
131 --\r
132 1.7.10.4\r