[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / bb / a8bf3ef70d3a24735448ab46d9fb79911269ca
1 Return-Path: <tom@dbservice.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 784C9431FBC\r
6         for <notmuch@notmuchmail.org>; Mon, 21 Dec 2009 19:18:24 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id gX2SIwQxfNGa for <notmuch@notmuchmail.org>;\r
11         Mon, 21 Dec 2009 19:18:23 -0800 (PST)\r
12 Received: from office.neopsis.com (office.neopsis.com [78.46.209.98])\r
13         by olra.theworths.org (Postfix) with ESMTP id 79870431FAE\r
14         for <notmuch@notmuchmail.org>; Mon, 21 Dec 2009 19:18:23 -0800 (PST)\r
15 Received: from calvin.caurea.org ([62.65.141.13])\r
16         (authenticated user tom@dbservice.com) by office.neopsis.com\r
17         (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits))\r
18         for notmuch@notmuchmail.org; Tue, 22 Dec 2009 04:18:21 +0100\r
19 Message-ID: <4B303A7D.5090803@dbservice.com>\r
20 Date: Tue, 22 Dec 2009 04:18:21 +0100\r
21 From: Tomas Carnecky <tom@dbservice.com>\r
22 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US;\r
23         rv:1.9.3a1pre) Gecko/20091216 Lightning/1.1a1pre Shredder/3.1a1pre\r
24 MIME-Version: 1.0\r
25 To: notmuch@notmuchmail.org\r
26 References: <1261450617-24616-1-git-send-email-tom@dbservice.com>\r
27 In-Reply-To: <1261450617-24616-1-git-send-email-tom@dbservice.com>\r
28 Content-Type: text/plain; charset=UTF-8; format=flowed\r
29 Content-Transfer-Encoding: 7bit\r
30 Subject: Re: [notmuch] [PATCH] Add post-add and post-tag hooks\r
31 X-BeenThere: notmuch@notmuchmail.org\r
32 X-Mailman-Version: 2.1.12\r
33 Precedence: list\r
34 List-Id: "Use and development of the notmuch mail system."\r
35         <notmuch.notmuchmail.org>\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
37         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
39 List-Post: <mailto:notmuch@notmuchmail.org>\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
43 X-List-Received-Date: Tue, 22 Dec 2009 03:18:24 -0000\r
44 \r
45 On 12/22/09 3:56 AM, Tomas Carnecky wrote:\r
46  > The post-add hook is run by 'notmuch new' after each new message is \r
47 added,\r
48  > post-tag is run after a tag has been added or removed. The hooks are \r
49 stored\r
50  > in the users home directory (~/.notmuch/hooks/).\r
51  >\r
52  > Since post-tag is run unconditionally every time a new tag is added \r
53 or removed,\r
54  > that means it is also invoked when 'notmuch new' adds the two implicit\r
55  > tags (inbox, unread). So make sure your scripts don't choke on that \r
56 and can\r
57  > be both executed in parallel.\r
58 \r
59 What are these good for? I (try to) use these two hooks to automatically \r
60 tag messages. But not in the usual way, I don't use static scripts, I \r
61 use a spam filter. I hope to be able to teach it to classify the \r
62 messages, not only spam/ham but also add tags such as patch (does that \r
63 message contain a patch?), tag messages based on which mailing lists the \r
64 messages belong etc.\r
65 \r
66 I use dspam as the spam filter. Each tag is actually a virtual user that \r
67 exists in dspam. When adding new messages dspam classifies the mails and \r
68 I assign the tags based on the result. If dspam deemed the message Spam \r
69 then I set the tag. To train dspam I use the post-tag hook: whenever I \r
70 change a tag (for example add 'spam' to a falsely unrecognized spam), \r
71 the post-tag hook retrains dspam.\r
72 \r
73 Since the post-add hook is running synchronously with 'notmuch new', \r
74 this adds quite a bit overhead. Depending on how fast the spam filter \r
75 is, it adds more or less time to do the import of new messages. It also \r
76 depends on how many tags you want to assign - dspam has to run once for \r
77 each tag to see if the tag should be assigned or not.\r
78 \r
79 tom\r
80 \r
81 --- >8 --- post-add\r
82 #!/bin/bash\r
83 \r
84 # This is so that the post-tag doesn't trigger retraining!\r
85 export NOTMUCH_POST_ADD=1\r
86 \r
87 MESSAGEID=$1\r
88 FILENAME=$2\r
89 \r
90 # Array of tags.\r
91 tags=( spam )\r
92 for tag in "${tags[@]}"; do\r
93          RESULT="$(/opt/dspam/bin/dspam --user $tag --deliver=summary < \r
94 $FILENAME)"\r
95 \r
96          if echo $RESULT | grep -q 'result="Spam";'; then\r
97                  echo $tag\r
98          fi\r
99 done\r
100 \r
101 # I remove the inbox flag from all new messages and keep only 'unread'\r
102 echo "-inbox"\r
103 --- >8 ---\r
104 \r
105 --- >8 --- post-tag\r
106 #!/bin/sh\r
107 \r
108 if [ "$NOTMUCH_POST_ADD" ]; then\r
109          echo "Exiting due to running in post-add"\r
110          exit\r
111 fi\r
112 \r
113 MESSAGEID=$1\r
114 FILENAME=$2\r
115 TAG=$3\r
116 ADDREMOVE=$4\r
117 \r
118 if [ "x$ADDREMOVE" = "xadded" ]; then\r
119          CLASS="spam"\r
120 else\r
121          CLASS="innocent"\r
122 fi\r
123 \r
124 /opt/dspam/bin/dspam --user $TAG --source=error --class=$CLASS < $FILENAME\r
125 --- >8 ---\r
126 \r