[PATCH v4 5/7] Introduce _notmuch_message_has_term()
[notmuch-archives.git] / 16 / 46326ca1f3098a8d6854b1e192cc571ddf2c7b
1 Return-Path: <BATV+bbc4756b788e67be553a+2433+infradead.org+hohndel@bombadil.srs.infradead.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 084DA431FC1\r
6         for <notmuch@notmuchmail.org>; Thu, 22 Apr 2010 16:17:40 -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=unavailable\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 Tv5wto1EcjCL for <notmuch@notmuchmail.org>;\r
16         Thu, 22 Apr 2010 16:17:37 -0700 (PDT)\r
17 Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id D7CF74196F2\r
19         for <notmuch@notmuchmail.org>; Thu, 22 Apr 2010 16:17:37 -0700 (PDT)\r
20 Received: from localhost ([::1] helo=x200.gr8dns.org)\r
21         by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux))\r
22         id 1O55eK-0003vZ-VC; Thu, 22 Apr 2010 23:17:37 +0000\r
23 Received: by x200.gr8dns.org (Postfix, from userid 500)\r
24         id 207D4C0249; Thu, 22 Apr 2010 16:17:36 -0700 (PDT)\r
25 From: Dirk Hohndel <hohndel@infradead.org>\r
26 To: Sebastian Spaeth <Sebastian@SSpaeth.de>,  notmuch@notmuchmail.org\r
27 Subject: Re: [notmuch] Fcc, Maildir, and Emacs message-mode -- a bit of code\r
28 In-Reply-To: <87ochbx3er.fsf@SSpaeth.de>\r
29 References: <873a1zs3t5.fsf@jhu.edu> <87ochbx3er.fsf@SSpaeth.de>\r
30 Date: Thu, 22 Apr 2010 16:17:36 -0700\r
31 Message-ID: <m3bpdbrsa7.fsf@x200.gr8dns.org>\r
32 User-Agent: notmuch 0.2-183-g625ff29 (Emacs 23.1.1/i386-redhat-linux-gnu)\r
33 MIME-Version: 1.0\r
34 Content-Type: text/plain; charset=us-ascii\r
35 X-SRS-Rewrite: SMTP reverse-path rewritten from <hohndel@infradead.org> by\r
36         bombadil.infradead.org See http://www.infradead.org/rpr.html\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Thu, 22 Apr 2010 23:17:40 -0000\r
50 \r
51 On Thu, 22 Apr 2010 11:06:04 +0200, "Sebastian Spaeth" <Sebastian@SSpaeth.de> wrote:\r
52 > As Carl stated that he would probably merge this one if someone tested\r
53 > it, here it comes: I tested it and it works great. When I define a\r
54 > non-existing directory as maildir it aborts with an error message that\r
55 > is visible to the user.\r
56\r
57 > I put this in a branch based on cworth/master and with Jesse's\r
58 > permission, I renamed the functions and did some further cleanup (It's\r
59 > also integrated in the build system)\r
60\r
61 > The git branch is here:\r
62 > http://github.com/spaetz/notmuch-all-feature/tree/feature/elisp-fcc\r
63\r
64 > It's not enabled by default. Enable it with:\r
65\r
66 > (setq message-fcc-handler-function \r
67 >       '(lambda (destdir) \r
68 >          (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))\r
69\r
70 > (add-hook 'message-send-hook \r
71 >           '(lambda ()\r
72 >              (message-add-header "Fcc: ~/mail/INBOX.Sent")))\r
73 \r
74 I am now using this patch together with this little snippet in my .emacs\r
75 file to FCC into per-from-address specific sent folders\r
76 \r
77 ;; This is the list of alternatives that should be configurable as\r
78 ;; defcustom (or simply set in .emacs for now)\r
79 (setq notmuch-fcc-dirs '(\r
80       ("Dirk Hohndel <dirk.hohndel@intel.com>" . "Maildir/Sent Items")\r
81       ("Dirk Hohndel <hohndel@infradead.org>" . "MaildirInfradead/Sent")))\r
82 \r
83 ;This constructs a path, concatenating the content of the variable\r
84 ;"message-directory" and the second part in the alist:\r
85 (defun my-fcc-header-setup ()\r
86 (let ((subdir (cdr (assoc (message-fetch-field "from") notmuch-fcc-dirs))))\r
87      (message-add-header (concat "Fcc: " message-directory subdir))))\r
88 (add-hook 'message-send-hook 'my-fcc-header-setup)\r
89 \r
90 (setq message-fcc-handler-function\r
91        '(lambda (destdir)\r
92            (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))\r
93 \r
94 I am using the message-send-hook (instead of the\r
95 message-header-setup-hook as Sebastian initially suggested) because I\r
96 tend to edit the From line in my message buffer and want to make sure\r
97 that it uses the final From line. Also, this way the FCC also works\r
98 correctly with replies (the message-header-setup-hook doesn't get called\r
99 by our notmuch-reply function, it seems).\r
100 \r
101 The disadvantage is that with the message-send-hook I don't get to see /\r
102 correct the FCC line in the message buffer - but since I trust the logic\r
103 here (and tested it quite a bit), I'm less concerned about this.\r
104 \r
105 Finally, for other emacs-newbies like me - this concats the\r
106 message-directory variable with the path that you setup in the\r
107 notmuch-fcc-dirs associative array... so the path to the sent folder\r
108 needs to be relative to that.\r
109 \r
110 Carl - I'd love to see this in 0.3\r
111 \r
112 /D\r
113 \r
114 -- \r
115 Dirk Hohndel\r
116 Intel Open Source Technology Center\r