Re: [PATCH v3 10/10] cli: address: Add --filter-by option to configure address filtering
[notmuch-archives.git] / cf / a80a5fc22377db7ab420ead903e9ad37be6e6b
1 Return-Path: <prvs=jrosenthal=72618203d@jhu.edu>\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 320304196F2\r
6         for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 08:53:35 -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: -4.2\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham\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 vgAxC43zLduK for <notmuch@notmuchmail.org>;\r
16         Tue, 27 Apr 2010 08:53:34 -0700 (PDT)\r
17 Received: from ipex3.johnshopkins.edu (ipex3.johnshopkins.edu\r
18         [128.220.161.140])\r
19         by olra.theworths.org (Postfix) with ESMTP id D1CC6431FC1\r
20         for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 08:53:33 -0700 (PDT)\r
21 X-IronPort-AV: E=Sophos;i="4.52,280,1270440000"; d="scan'208";a="380272985"\r
22 Received: from c-69-255-36-229.hsd1.md.comcast.net (HELO lucky)\r
23         ([69.255.36.229])\r
24         by ipex3.johnshopkins.edu with ESMTP/TLS/AES256-SHA;\r
25         27 Apr 2010 11:53:32 -0400\r
26 Received: from jkr by lucky with local (Exim 4.69)\r
27         (envelope-from <jrosenthal@jhu.edu>)\r
28         id 1O6n6I-0002Kn-J3; Tue, 27 Apr 2010 11:53:30 -0400\r
29 From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
30 To: Carl Worth <cworth@cworth.org>,\r
31         Notmuch developer list <notmuch@notmuchmail.org>\r
32 Subject: [PATCH-V2 1/2] emacs: Add auto-tagging for replied messages.\r
33 In-Reply-To: <87fx2gnccg.fsf@yoom.home.cworth.org>\r
34 References: <87d3xlkpsc.fsf@jhu.edu> <87fx2gnccg.fsf@yoom.home.cworth.org>\r
35 User-Agent: Notmuch/0.3 (http://notmuchmail.org) Emacs/23.1.1\r
36         (i486-pc-linux-gnu)\r
37 Date: Tue, 27 Apr 2010 11:53:30 -0400\r
38 Message-ID: <87vdbcki2t.fsf@jhu.edu>\r
39 MIME-Version: 1.0\r
40 Content-Type: text/plain; charset=utf-8\r
41 Content-Transfer-Encoding: quoted-printable\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\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: Tue, 27 Apr 2010 15:53:35 -0000\r
55 \r
56 \r
57 Add `notmuch-message-mark-replied', a function for automatically tagging\r
58 replied messages with user-defined tags. The tags (which can be either\r
59 added or removed) can be customized with the customization variable\r
60 `notmuch-message-replied-tags'. This is a simple list of strings. Any\r
61 string prefaced with a "-" will be removed; any string prefaced with a "+"\r
62 (or neither "+" nor "-") will be added.\r
63 \r
64 This adds a new file notmuch-message.el, for functions which target\r
65 message mode (and in the future, notmuch-message mode). Based on some\r
66 conversation, notmuch-message.el will probably end up subsuming\r
67 notmuch-mua.el, but until we figure out exactly how we want to do that,\r
68 they will remain separate files.\r
69 ---\r
70  emacs/notmuch-message.el |   52 ++++++++++++++++++++++++++++++++++++++++++=\r
71 ++++\r
72  1 files changed, 52 insertions(+), 0 deletions(-)\r
73  create mode 100644 emacs/notmuch-message.el\r
74 \r
75 diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el\r
76 new file mode 100644\r
77 index 0000000..0cc4608\r
78 --- /dev/null\r
79 +++ b/emacs/notmuch-message.el\r
80 @@ -0,0 +1,52 @@\r
81 +;; notmuch-message.el --- message-mode functions specific to notmuch\r
82 +;;\r
83 +;; Copyright =C2=A9 Jesse Rosenthal\r
84 +;;\r
85 +;; This file is part of Notmuch.\r
86 +;;\r
87 +;; Notmuch is free software: you can redistribute it and/or modify it\r
88 +;; under the terms of the GNU General Public License as published by\r
89 +;; the Free Software Foundation, either version 3 of the License, or\r
90 +;; (at your option) any later version.\r
91 +;;\r
92 +;; Notmuch is distributed in the hope that it will be useful, but\r
93 +;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
94 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
95 +;; General Public License for more details.\r
96 +;;\r
97 +;; You should have received a copy of the GNU General Public License\r
98 +;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.\r
99 +;;\r
100 +;; Authors: Jesse Rosenthal <jrosenthal@jhu.edu>\r
101 +\r
102 +(require 'message)\r
103 +(require 'notmuch-mua)\r
104 +\r
105 +(defcustom notmuch-message-replied-tags '("replied")\r
106 +  "Tags to be automatically added to or removed from a message when it is =\r
107 replied to.\r
108 +Any tag in the list will be added to a replied message or,=20\r
109 +if it is prefaced with a \"-\", removed.\r
110 +\r
111 +For example, if you wanted to add a \"replied\" tag and remove=20\r
112 +the \"inbox\" and \"todo\", you would set\r
113 +    (\"replied\" \"-inbox\" \"-todo\"\)"\r
114 +  :type 'list\r
115 +  :group 'notmuch)\r
116 +\r
117 +(defun notmuch-message-mark-replied ()\r
118 +  ;; get the in-reply-to header and parse it for the message id.=20\r
119 +  (let ((rep (mail-header-parse-addresses (message-field-value "In-Reply-T=\r
120 o"))))\r
121 +    (when (and notmuch-message-replied-tags rep)\r
122 +      ;; add a "+" to any tag that is doesn't already begin with a "+"\r
123 +      ;; or "-"\r
124 +      (let ((tags (mapcar '(lambda (str)\r
125 +                            (if (not (string-match "^[+-]" str))\r
126 +                                (concat "+" str)\r
127 +                              str))\r
128 +                         notmuch-message-replied-tags)))\r
129 +       (apply 'notmuch-call-notmuch-process "tag"\r
130 +              (append tags (list (concat "id:" (car (car rep)))) nil))))))\r
131 +\r
132 +(add-hook 'message-send-hook 'notmuch-message-mark-replied)\r
133 +\r
134 +(provide 'notmuch-message)\r
135 \ No newline at end of file\r
136 --=20\r
137 1.6.3.3\r
138 \r