Notmuch scripters rejoice! New "notmuch search --output=(...)"
authorCarl Worth <cworth@cworth.org>
Thu, 28 Oct 2010 19:24:45 +0000 (12:24 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:19 +0000 (09:37 -0800)
67/2cee868e862af02675d7db7ede32410c157b4f [new file with mode: 0644]

diff --git a/67/2cee868e862af02675d7db7ede32410c157b4f b/67/2cee868e862af02675d7db7ede32410c157b4f
new file mode 100644 (file)
index 0000000..ab48e2c
--- /dev/null
@@ -0,0 +1,113 @@
+Return-Path: <cworth@cworth.org>\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 54D5840D152\r
+       for <notmuch@notmuchmail.org>; Thu, 28 Oct 2010 12:24:56 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.89\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.89 tagged_above=-999 required=5\r
+       tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, T_MIME_NO_TEXT=0.01]\r
+       autolearn=ham\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 XxyK1yAkCeKW for <notmuch@notmuchmail.org>;\r
+       Thu, 28 Oct 2010 12:24:46 -0700 (PDT)\r
+Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1DD1A40D157\r
+       for <notmuch@notmuchmail.org>; Thu, 28 Oct 2010 12:24:46 -0700 (PDT)\r
+Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
+       id C3C5F2540F4; Thu, 28 Oct 2010 12:24:45 -0700 (PDT)\r
+From: Carl Worth <cworth@cworth.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: Notmuch scripters rejoice! New "notmuch search --output=(...)"\r
+User-Agent: Notmuch/0.3.1-124-gc9e0da3 (http://notmuchmail.org) Emacs/23.2.1\r
+       (i486-pc-linux-gnu)\r
+Date: Thu, 28 Oct 2010 12:24:45 -0700\r
+Message-ID: <8762wmglxe.fsf@yoom.home.cworth.org>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\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: Thu, 28 Oct 2010 19:24:56 -0000\r
+\r
+--=-=-=\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+I just added a new feature to notmuch that I've been wanting for a very\r
+long time. It's a new option to "notmuch search" as follows:\r
+\r
+       --output=3D(summary|threads|messages|files|tags)\r
+\r
+The "summary" value is the default and behaves as "notmuch search"\r
+always has, (printing a one-line summary with a bunch of information\r
+about each thread).\r
+\r
+Each of the other options causes "notmuch search" to print only a single\r
+value, (thread ID, message ID, filename, or tag), one-per-line[*]. This\r
+is intended to be useful in scripts to do things as follows:\r
+\r
+       for spamfile in $(notmuch search tag:spam); do\r
+               rm $spamfile\r
+       done\r
+\r
+Or what have you.\r
+\r
+I hope people find this useful. See "notmuch help search" for more\r
+details.\r
+\r
+Oh, and with this change, the existing "notmuch search-tags" command is\r
+redundant, (it behaves in the same way as "notmuch search\r
+=2D-output=3Dtags"). I think I'll drop search-tags from the list of\r
+documented commands, (but it probably won't be too painful to continue\r
+to support it as a deprecated command name).\r
+\r
+I'm also wondering about "notmuch count". With the new feature above,\r
+one could count matching messages as "notmuch count" does with something\r
+like:\r
+\r
+       notmuch search --output=3Dmessages <search-terms> | wc -l\r
+\r
+That's a bit of a mouthful compared to "notmuch count", but the new\r
+command also enables the counting of matching threads:\r
+\r
+       notmuch search --output=3Dthreads <search-terms> | wc -l\r
+\r
+which is something that "notmuch count" doesn't do.\r
+\r
+I don't think I'll change "notmuch count". It's probably still useful,\r
+(doing what it's documented to do), and it's also likely much more\r
+efficient than either of the above "notmuch search" pipelines.\r
+\r
+=2DCarl\r
+\r
+[*] Or, when under the influence of --format=3Djson, the results are\r
+printed as a single JSON array.\r
+\r
+=2D-=20\r
+carl.d.worth@intel.com\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.10 (GNU/Linux)\r
+\r
+iD8DBQFMyc396JDdNq8qSWgRApC+AJ9PjIt7juIEoNaPoh4U1walfTI8LwCeLFCU\r
+U89KquzFAmV9eUeaAeu2blE=\r
+=JiNM\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r