unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: markwalters1009 <markwalters1009@gmail.com>
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	[thread overview]
Message-ID: <1353763256-32336-4-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>

From: Mark Walters <markwalters1009@gmail.com>

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

  parent reply	other threads:[~2012-11-24 13:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-24 13:20 [PATCH v2 0/7] Fix emacs tagging race markwalters1009
2012-11-24 13:20 ` [PATCH v2 1/7] cli: allow query to come from stdin markwalters1009
2012-11-24 13:24   ` Mark Walters
2012-11-24 17:41   ` Austin Clements
2012-11-26 10:15     ` Mark Walters
2012-11-24 22:34   ` Tomi Ollila
2012-11-24 13:20 ` [PATCH v2 2/7] test: for the new query from stdin functionality markwalters1009
2012-11-24 13:20 ` markwalters1009 [this message]
2012-11-24 13:20 ` [PATCH v2 4/7] emacs: make emacs tagging use the stdin query functionality markwalters1009
2012-11-24 22:09   ` Austin Clements
2012-11-24 13:20 ` [PATCH v2 5/7] test: test for race when tagging from emacs search markwalters1009
2012-11-24 13:20 ` [PATCH v2 6/7] cli: allow search mode to include msg-ids with JSON output markwalters1009
2012-11-24 22:30   ` Tomi Ollila
2012-11-25  0:23   ` Austin Clements
2012-11-24 13:20 ` [PATCH v2 7/7] emacs: make emacs use message-ids for tagging markwalters1009
2012-11-25  0:38   ` Austin Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353763256-32336-4-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).