1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 97DD2431FAE
\r
6 for <notmuch@notmuchmail.org>; Mon, 7 Oct 2013 15:33:42 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 7YlJxRDa1r1O for <notmuch@notmuchmail.org>;
\r
16 Mon, 7 Oct 2013 15:33:37 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id 46E55431FBD
\r
20 for <notmuch@notmuchmail.org>; Mon, 7 Oct 2013 15:33:30 -0700 (PDT)
\r
21 X-AuditID: 12074422-b7f5a8e000000a34-81-525336b75904
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 9B.F6.02612.7B633525; Mon, 7 Oct 2013 18:33:28 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r97MXP5f024575;
\r
27 Mon, 7 Oct 2013 18:33:26 -0400
\r
28 Received: from drake.dyndns.org (26-4-172.dynamic.csail.mit.edu [18.26.4.172])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r97MXNXF028509
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Mon, 7 Oct 2013 18:33:25 -0400
\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1VTJMh-0006bw-Lx; Mon, 07 Oct 2013 18:33:23 -0400
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH 06/11] emacs: Support passing input via
\r
40 `notmuch-call-notmuch-*'
\r
41 Date: Mon, 7 Oct 2013 18:33:16 -0400
\r
42 Message-Id: <1381185201-25197-7-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.8.4.rc3
\r
44 In-Reply-To: <1381185201-25197-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1381185201-25197-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrbvDLDjI4IqVxfWbM5kdGD2erbrF
\r
48 HMAYxWWTkpqTWZZapG+XwJVxbN1K1oIFEhVv+7ewNTDeFO5i5OSQEDCRuLrsLjOELSZx4d56
\r
49 ti5GLg4hgX2MEqvf7odyNjBKPJ97iRXCOcwk8f30GiaQFiGBuYwSMxvAbDYBDYlt+5czgtgi
\r
50 AtISO+/OBmrg4GAWUJP406UCEhYWCJA4Ofk0WDmLgKrEu2W/WEBsXgEHiec7H0JdoSSx8NQ2
\r
51 VhCbU8BRYsnGi2wQqxwk5u5fxDqBkX8BI8MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXVO93MwS
\r
52 vdSU0k2MoJBhd1HawfjzoNIhRgEORiUe3oyjQUFCrIllxZW5hxglOZiURHnPmAYHCfEl5adU
\r
53 ZiQWZ8QXleakFh9ilOBgVhLhFTACyvGmJFZWpRblw6SkOViUxHlvcdgHCQmkJ5akZqemFqQW
\r
54 wWRlODiUJHjDQIYKFqWmp1akZeaUIKSZODhBhvMADb8FUsNbXJCYW5yZDpE/xagoJc57ByQh
\r
55 AJLIKM2D64XF9CtGcaBXhHk/g1TxANMBXPcroMFMQIN12QNBBpckIqSkGhjVZ3XJHDnznvfx
\r
56 zj1vE/9M6jMMmB9u6fvp6spuzvYe/e2tyy5xffnJEdxtxPA86mzYH/14LxdNu4W74xyOPfp5
\r
57 2GjRlbKc8MslArlsjhYBZ1XDJ/06MX2n7ryLG/8LX766xF5zlVxn6qqUa4w9yXVt1/evtEyR
\r
58 iVm6TTv70sNmDpn5JmGbtt9RYinOSDTUYi4qTgQAAOVSrMQCAAA=
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Mon, 07 Oct 2013 22:33:43 -0000
\r
73 This adds support for passing a string to write to notmuch's stdin to
\r
74 `notmuch-call-notmuch-process' and `notmuch-call-notmuch-sexp'. Since
\r
75 this makes both interfaces a little more complicated, it also unifies
\r
76 their documentation better.
\r
78 emacs/notmuch-lib.el | 39 +++++++++++++++++++++++++++++++++------
\r
79 1 file changed, 33 insertions(+), 6 deletions(-)
\r
81 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
82 index 4e0604e..22156f1 100644
\r
83 --- a/emacs/notmuch-lib.el
\r
84 +++ b/emacs/notmuch-lib.el
\r
85 @@ -534,28 +534,55 @@ You may need to restart Emacs or upgrade your notmuch package."))
\r
86 ;; `notmuch-logged-error' does not return.
\r
89 +(defun notmuch-call-notmuch--helper (destination args)
\r
90 + "Helper for synchronous notmuch invocation commands.
\r
92 +This wraps `call-process'. DESTINATION has the same meaning as
\r
93 +for `call-process'. ARGS is as described for
\r
94 +`notmuch-call-notmuch-process'."
\r
96 + (let (stdin-string)
\r
97 + (while (keywordp (car args))
\r
99 + (:stdin-string (setq stdin-string (cadr args)
\r
100 + args (cddr args)))
\r
102 + (error "Unknown keyword argument: %s" (car args)))))
\r
103 + (if (null stdin-string)
\r
104 + (apply #'call-process notmuch-command nil destination nil args)
\r
105 + (insert stdin-string)
\r
106 + (apply #'call-process-region (point-min) (point-max)
\r
107 + notmuch-command t destination nil args))))
\r
109 (defun notmuch-call-notmuch-process (&rest args)
\r
110 - "Synchronously invoke \"notmuch\" with the given list of arguments.
\r
111 + "Synchronously invoke `notmuch-command' with ARGS.
\r
113 +The caller may provide keyword arguments before ARGS. Currently
\r
114 +supported keyword arguments are:
\r
116 + :stdin-string STRING - Write STRING to stdin
\r
118 If notmuch exits with a non-zero status, output from the process
\r
119 will appear in a buffer named \"*Notmuch errors*\" and an error
\r
122 - (let ((status (apply #'call-process notmuch-command nil t nil args)))
\r
123 + (let ((status (notmuch-call-notmuch--helper t args)))
\r
124 (notmuch-check-exit-status status (cons notmuch-command args)
\r
125 (buffer-string)))))
\r
127 (defun notmuch-call-notmuch-sexp (&rest args)
\r
128 "Invoke `notmuch-command' with ARGS and return the parsed S-exp output.
\r
130 -If notmuch exits with a non-zero status, this will pop up a
\r
131 -buffer containing notmuch's output and signal an error."
\r
132 +This is equivalent to `notmuch-call-notmuch-process', but parses
\r
133 +notmuch's output as an S-expression and returns the parsed value.
\r
134 +Like `notmuch-call-notmuch-process', if notmuch exits with a
\r
135 +non-zero status, this will report its output and signal an
\r
139 (let ((err-file (make-temp-file "nmerr")))
\r
141 - (let ((status (apply #'call-process
\r
142 - notmuch-command nil (list t err-file) nil args)))
\r
143 + (let ((status (notmuch-call-notmuch--helper (list t err-file) args)))
\r
144 (notmuch-check-exit-status status (cons notmuch-command args)
\r
145 (buffer-string) err-file)
\r
146 (goto-char (point-min))
\r