--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 0938E431FBF\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:14 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 m0T+I-36IKhS for <notmuch@notmuchmail.org>;\r
+ Sat, 24 Nov 2012 05:21:12 -0800 (PST)\r
+Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com\r
+ [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 0EEB2431FC7\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:08 -0800 (PST)\r
+Received: by mail-wi0-f179.google.com with SMTP id hj6so1746549wib.2\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:07 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=T0cV6BGIHKMheCCH3sdN+zTc6hl2ejG7dayUivgbzaY=;\r
+ b=Cks9utq/nMQ4lhyGGihV4RhSl7qPN7qD9yUnbIKdbkIcIWHezGpZJWI/LT1tlcVTHg\r
+ SbcYM3v+VgKWU3hFlU8JAsYJ4GrQjss2gt/r6NNAZ3XeMD3Yb6loyftCizUXWsWCSsLw\r
+ PX6gU6m6IP3yUxsWI1zNlEsYlyypnCl0thlum3H1/TrFD1js1p7uIuB5YKACeL6S9DsB\r
+ rmXD2lPCZ55yzcVFUUot/ty4C+mni4RdgY/pHTkE38XEJRiu1TTx6/U8M00AofZl739I\r
+ qAJbJieu4bmJo6xi0MPQK+shlOutL/Zi4xweN+F08NzWSn9U1utjQPrTnlfW1j2DUhg7\r
+ kfTw==\r
+Received: by 10.216.209.70 with SMTP id r48mr2657561weo.196.1353763267753;\r
+ Sat, 24 Nov 2012 05:21:07 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPS id bz12sm14251167wib.5.2012.11.24.05.21.06\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 24 Nov 2012 05:21:07 -0800 (PST)\r
+From: markwalters1009 <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/7] emacs: notmuch.el split call-process into\r
+ call-process-region\r
+Date: Sat, 24 Nov 2012 13:20:52 +0000\r
+Message-Id: <1353763256-32336-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>\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: Sat, 24 Nov 2012 13:21:14 -0000\r
+\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+\r
+We add a new function notmuch-call-process-region so that functions\r
+can call notmuch with some region sent to stdin. This is preparation\r
+for using the new query from stdin functionality.\r
+---\r
+ emacs/notmuch.el | 19 ++++++++++++++-----\r
+ 1 files changed, 14 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index f9454d8..64b9474 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -533,15 +533,17 @@ If BARE is set then do not prefix with \"thread:\""\r
+ (let ((message-id (notmuch-search-find-thread-id)))\r
+ (notmuch-mua-new-reply message-id prompt-for-sender nil)))\r
+ \r
+-(defun notmuch-call-notmuch-process (&rest args)\r
+- "Synchronously invoke \"notmuch\" with the given list of arguments.\r
++(defun notmuch-call-notmuch-process-region (beg end &rest args)\r
++ "Synchronously invoke \"notmuch\" with the given list of arguments and pipe region.\r
+ \r
+-Output from the process will be presented to the user as an error\r
+-and will also appear in a buffer named \"*Notmuch errors*\"."\r
++The region from beg to end in the current buffer will be piped to\r
++stdin for the notmuch process. Output from the process will be\r
++presented to the user as an error and will also appear in a\r
++buffer named \"*Notmuch errors*\"."\r
+ (let ((error-buffer (get-buffer-create "*Notmuch errors*")))\r
+ (with-current-buffer error-buffer\r
+ (erase-buffer))\r
+- (if (eq (apply 'call-process notmuch-command nil error-buffer nil args) 0)\r
++ (if (eq (apply 'call-process-region beg end notmuch-command nil error-buffer nil args) 0)\r
+ (point)\r
+ (progn\r
+ (with-current-buffer error-buffer\r
+@@ -550,6 +552,13 @@ and will also appear in a buffer named \"*Notmuch errors*\"."\r
+ (error (buffer-substring beg end))\r
+ ))))))\r
+ \r
++(defun notmuch-call-notmuch-process (&rest args)\r
++ "Synchronously invoke \"notmuch\" with the given list of arguments.\r
++\r
++Output from the process will be presented to the user as an error\r
++and will also appear in a buffer named \"*Notmuch errors*\"."\r
++ (apply 'notmuch-call-notmuch-process-region (point) (point) args))\r
++\r
+ (defun notmuch-search-set-tags (tags &optional pos)\r
+ (let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags)))\r
+ (notmuch-search-update-result new-result pos)))\r
+-- \r
+1.7.9.1\r
+\r