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