--- /dev/null
+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 B020D429E53\r
+ for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 08:19:28 -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 nKhQWC4vx+2F for <notmuch@notmuchmail.org>;\r
+ Thu, 24 Oct 2013 08:19:23 -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 74D02429E41\r
+ for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 08:19:18 -0700 (PDT)\r
+X-AuditID: 1209190c-b7fd38e0000009aa-24-52693a751991\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id C0.5C.02474.67A39625; Thu, 24 Oct 2013 11:19:18 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r9OFJFZ8030432; \r
+ Thu, 24 Oct 2013 11:19:15 -0400\r
+Received: from drake.dyndns.org\r
+ (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [216.15.114.40]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r9OFJCh0012917\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Thu, 24 Oct 2013 11:19:14 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1VZMgq-0006du-Pu; Thu, 24 Oct 2013 11:19:12 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 06/11] emacs: Support passing input via\r
+ `notmuch-call-notmuch-*'\r
+Date: Thu, 24 Oct 2013 11:19:06 -0400\r
+Message-Id: <1382627951-25252-7-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+In-Reply-To: <1382627951-25252-1-git-send-email-amdragon@mit.edu>\r
+References: <1382627951-25252-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrVtmlRlksKKJ2aJpurPF6rk8Ftdv\r
+ zmR2YPbYOesuu8et+6/ZPZ6tusUcwBzFZZOSmpNZllqkb5fAlXFs3UrWggUSFW/7t7A1MN4U\r
+ 7mLk4JAQMJF42RXbxcgJZIpJXLi3nq2LkYtDSGAfo8TXpxsZIZyNjBJLp09hhnDuMEmcmb2X\r
+ BcKZC5T5f50VpJ9NQENi2/7ljCC2iIC0xM67s8HizALREkcuz2ADsYUFgiUerPrPDGKzCKhK\r
+ /Nt1hgnE5hVwkNhxayo7xB1KEgtPbQPr5RRwlPj5+hrYTCGgml+/z7BMYORfwMiwilE2JbdK\r
+ NzcxM6c4NVm3ODkxLy+1SNdQLzezRC81pXQTIzi0JHl2ML45qHSIUYCDUYmHV+NDepAQa2JZ\r
+ cWXuIUZJDiYlUd57pplBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4p+kB5XhTEiurUovyYVLS\r
+ HCxK4rw3OeyDhATSE0tSs1NTC1KLYLIyHBxKErydlkCNgkWp6akVaZk5JQhpJg5OkOE8QMOX\r
+ gtTwFhck5hZnpkPkTzEqSonzzgNJCIAkMkrz4Hphsf+KURzoFWHecpAqHmDagOt+BTSYCWjw\r
+ lCVpIINLEhFSUg2MLY9dyibl8WZu+vA4LOgE5/TUUJO6EsNrS1Ia9bnbykVzOLzWGVn4yBRN\r
+ 7PmQkbTumCnTrojVhUztL597Z8zLrJhgUXy4Mzo09oqC05mVcrtCFSsyzh9mO5V4XvNZvnbT\r
+ PUkBPmaFjyqXGssOF9qYl3/2Pdtitegxf53gJzbJy8e+9z5TuKjEUpyRaKjFXFScCACYcusw\r
+ 2AIAAA==\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, 24 Oct 2013 15:19:29 -0000\r
+\r
+This adds support for passing a string to write to notmuch's stdin to\r
+`notmuch-call-notmuch-process' and `notmuch-call-notmuch-sexp'. Since\r
+this makes both interfaces a little more complicated, it also unifies\r
+their documentation better.\r
+---\r
+ emacs/notmuch-lib.el | 39 +++++++++++++++++++++++++++++++++------\r
+ 1 file changed, 33 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 4e0604e..22156f1 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -534,28 +534,55 @@ You may need to restart Emacs or upgrade your notmuch package."))\r
+ ;; `notmuch-logged-error' does not return.\r
+ ))))\r
+ \r
++(defun notmuch-call-notmuch--helper (destination args)\r
++ "Helper for synchronous notmuch invocation commands.\r
++\r
++This wraps `call-process'. DESTINATION has the same meaning as\r
++for `call-process'. ARGS is as described for\r
++`notmuch-call-notmuch-process'."\r
++\r
++ (let (stdin-string)\r
++ (while (keywordp (car args))\r
++ (case (car args)\r
++ (:stdin-string (setq stdin-string (cadr args)\r
++ args (cddr args)))\r
++ (otherwise\r
++ (error "Unknown keyword argument: %s" (car args)))))\r
++ (if (null stdin-string)\r
++ (apply #'call-process notmuch-command nil destination nil args)\r
++ (insert stdin-string)\r
++ (apply #'call-process-region (point-min) (point-max)\r
++ notmuch-command t destination nil args))))\r
++\r
+ (defun notmuch-call-notmuch-process (&rest args)\r
+- "Synchronously invoke \"notmuch\" with the given list of arguments.\r
++ "Synchronously invoke `notmuch-command' with ARGS.\r
++\r
++The caller may provide keyword arguments before ARGS. Currently\r
++supported keyword arguments are:\r
++\r
++ :stdin-string STRING - Write STRING to stdin\r
+ \r
+ If notmuch exits with a non-zero status, output from the process\r
+ will appear in a buffer named \"*Notmuch errors*\" and an error\r
+ will be signaled."\r
+ (with-temp-buffer\r
+- (let ((status (apply #'call-process notmuch-command nil t nil args)))\r
++ (let ((status (notmuch-call-notmuch--helper t args)))\r
+ (notmuch-check-exit-status status (cons notmuch-command args)\r
+ (buffer-string)))))\r
+ \r
+ (defun notmuch-call-notmuch-sexp (&rest args)\r
+ "Invoke `notmuch-command' with ARGS and return the parsed S-exp output.\r
+ \r
+-If notmuch exits with a non-zero status, this will pop up a\r
+-buffer containing notmuch's output and signal an error."\r
++This is equivalent to `notmuch-call-notmuch-process', but parses\r
++notmuch's output as an S-expression and returns the parsed value.\r
++Like `notmuch-call-notmuch-process', if notmuch exits with a\r
++non-zero status, this will report its output and signal an\r
++error."\r
+ \r
+ (with-temp-buffer\r
+ (let ((err-file (make-temp-file "nmerr")))\r
+ (unwind-protect\r
+- (let ((status (apply #'call-process\r
+- notmuch-command nil (list t err-file) nil args)))\r
++ (let ((status (notmuch-call-notmuch--helper (list t err-file) args)))\r
+ (notmuch-check-exit-status status (cons notmuch-command args)\r
+ (buffer-string) err-file)\r
+ (goto-char (point-min))\r
+-- \r
+1.8.4.rc3\r
+\r