Re: Using procmail to set tags
authorAustin Clements <amdragon@MIT.EDU>
Tue, 15 May 2012 13:22:38 +0000 (09:22 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:06 +0000 (09:47 -0800)
e9/9269b47ab3c9a65e240112b82953356365b4de [new file with mode: 0644]

diff --git a/e9/9269b47ab3c9a65e240112b82953356365b4de b/e9/9269b47ab3c9a65e240112b82953356365b4de
new file mode 100644 (file)
index 0000000..e14dc4e
--- /dev/null
@@ -0,0 +1,118 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 701E9431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 06:22:45 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id IRmS+LBF4hlc for <notmuch@notmuchmail.org>;\r
+       Tue, 15 May 2012 06:22:43 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
+       [18.9.25.12])\r
+       by olra.theworths.org (Postfix) with ESMTP id A3B37431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 06:22:43 -0700 (PDT)\r
+X-AuditID: 1209190c-b7fad6d000000920-e1-4fb258a216ab\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 40.13.02336.2A852BF4; Tue, 15 May 2012 09:22:42 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q4FDMfHf027957; \r
+       Tue, 15 May 2012 09:22:41 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4FDMdXL029979\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 15 May 2012 09:22:40 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SUHi3-0003J3-0g; Tue, 15 May 2012 09:22:39 -0400\r
+Date: Tue, 15 May 2012 09:22:38 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Robert Horn <rjhorn@alum.mit.edu>\r
+Subject: Re: Using procmail to set tags\r
+Message-ID: <20120515132238.GO11804@mit.edu>\r
+References: <m3vcjyl4kg.fsf@quad.robs.office>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <m3vcjyl4kg.fsf@quad.robs.office>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsUixG6nrrsoYpO/wYFlwhbXb85kdmD0eLbq\r
+       FnMAYxSXTUpqTmZZapG+XQJXRue0mSwFjwQqnjxexd7AuJe3i5GTQ0LAROLl1iXMELaYxIV7\r
+       69lAbCGBfYwS9/erdjFyAdkbGCUmLj3JDpE4ySRxYB8LRGIJo8TpjWfBulkEVCVmPd3NAmKz\r
+       CWhIbNu/nBHEFgGKT5g5ixXEZhaQlvj2u5kJxBYWUJdY3/kLbCivgI7E1xVbgeIcQEN1JRYu\r
+       UIYIC0qcnPmEBaJVS+LGv5dgJSBjlv/jAAlzCuhJnG/aADZFVEBFYsrJbWwTGIVmIemehaR7\r
+       FkL3AkbmVYyyKblVurmJmTnFqcm6xcmJeXmpRbqGermZJXqpKaWbGEHhyynJs4PxzUGlQ4wC\r
+       HIxKPLxO6zf6C7EmlhVX5h5ilORgUhLljQjb5C/El5SfUpmRWJwRX1Sak1p8iFGCg1lJhFfM\r
+       DCjHm5JYWZValA+TkuZgURLnVdF65yckkJ5YkpqdmlqQWgSTleHgUJLg7Q4HahQsSk1PrUjL\r
+       zClBSDNxcIIM5wEabg9Sw1tckJhbnJkOkT/FqCglzpsPkhAASWSU5sH1wtLLK0ZxoFeEeatB\r
+       qniAqQmu+xXQYCagwY0sYINLEhFSUg2MLOIWqjMtq+yLWyboxKwMLP61he/k35T0hh0t2j+N\r
+       Ls0rDZGOm+jMa2EUvOq3oJ3/gf8Li2Z6CusWuO9/LL7k0tftvlGpzmFvlTbqzt52iuO+35V7\r
+       h9jtA9WskrV+HV8nmudRtYBTPs6ZKb1FSdXC4P+NyctWpqy11vtmVLpV/v/FBQstH2xRYinO\r
+       SDTUYi4qTgQAVBK9wgoDAAA=\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 15 May 2012 13:22:45 -0000\r
+\r
+Quoth Robert Horn on May 14 at  7:34 pm:\r
+> Is it practical (and has anyone documented) using a procmail setup to\r
+> set initial tags for messages using notmuch?\r
+> \r
+> I've just started using emacs-notmuch to read mail, and I'm using a\r
+> system where I have procmail filters to bin mail by category into\r
+> folders.  I can continue this using folder:value for searching, but one\r
+> reason notmuch interests me is the potential to do more.\r
+> \r
+> It's practical for me to assign potentially overlapping tags with a more\r
+> sophisticated procmail setup.  Notmuch tags enable having multiple tags\r
+> on one email.\r
+> \r
+> I don't know enough about the procmail/notmuch process to see just how\r
+> to make this happen.  I'm hoping that someone has already done something\r
+> similar.\r
+\r
+I second Jani's suggestion of using notmuch tag commands from\r
+notmuch's post-new hook if possible (or switching to using searches\r
+instead of tags where that makes sense).  However, if you really need\r
+the flexibility of procmail, I can think of two solutions:\r
+\r
+You can let procmail deliver to folders, like usual, and then use\r
+  notmuch tag tag:inbox folder:X +/-tags\r
+in notmuch's post-new hook to apply tags based on folders (you might\r
+want to add the tag 'new' to your new.tags in ~/.notmuch-config and\r
+filter on tag:new instead of tag:inbox).  If you need multiple tags on\r
+a message, let procmail deliver it to multiple folders.\r
+\r
+Alternatively, you can have procmail record the message ID and desired\r
+tags of the message in a file and then apply those recorded tags in\r
+your post-new hook.  This would achieve the tagging you want more\r
+directly, without mixing in folders and multiple delivery.  The\r
+difficulty would be getting a message ID you could later use in an id:\r
+query.  Simply grabbing the value of the message-id header would work\r
+most of the time, but there's a fair bit of logic for dealing with\r
+strangely formed or completely malformed message-id headers\r
+(see _parse_message_id).\r
+\r
+As far as I know, nobody has tried my second suggestion.  Most people\r
+just switch to using notmuch queries (either to tag or simply to\r
+search).\r