Re: notmuch and "mute" -- useful to anyone?
[notmuch-archives.git] / 06 / d25c36517eee383525f277c7c4913a53819729
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 3F319429E32\r
6         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 20:49:49 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 H9sKoM6wuG+a for <notmuch@notmuchmail.org>;\r
16         Mon, 27 Jun 2011 20:49:48 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
18         [18.7.68.37])\r
19         by olra.theworths.org (Postfix) with ESMTP id B73C9429E25\r
20         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 20:49:48 -0700 (PDT)\r
21 X-AuditID: 12074425-b7b82ae000000a2a-77-4e094f3739a9\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 71.1C.02602.73F490E4; Mon, 27 Jun 2011 23:49:11 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id p5S3nlQ0024916; \r
27         Mon, 27 Jun 2011 23:49:48 -0400\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p5S3nk9C004457\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Mon, 27 Jun 2011 23:49:47 -0400 (EDT)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1QbPIv-0001u9-Ra; Mon, 27 Jun 2011 23:49:37 -0400\r
37 Date: Mon, 27 Jun 2011 23:49:37 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
40 Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests\r
41 Message-ID: <20110628034937.GB4120@mit.edu>\r
42 References: <1309132379-24089-1-git-send-email-dmitry.kurochkin@gmail.com>\r
43         <1309146846-30991-1-git-send-email-dmitry.kurochkin@gmail.com>\r
44         <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com>\r
45         <BANLkTi=nwHRndz367K5oh4=tPaU-KNeZ8Q@mail.gmail.com>\r
46         <87hb7byqge.fsf@gmail.com> <87d3hyzs1c.fsf@gmail.com>\r
47 MIME-Version: 1.0\r
48 Content-Type: text/plain; charset=us-ascii\r
49 Content-Disposition: inline\r
50 In-Reply-To: <87d3hyzs1c.fsf@gmail.com>\r
51 User-Agent: Mutt/1.5.20 (2009-06-14)\r
52 X-Brightmail-Tracker:\r
53  H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42IRYrdT0TX35/Qz6NplZnF1az+7xfWbM5kd\r
54         mDx2zrrL7vFs1S3mAKYoLpuU1JzMstQifbsEroyXmztYCs4IVWy90sDewNjC18XIySEhYCLx\r
55         ae1qNghbTOLCvfVANheHkMA+RolVM5dAORsYJV7vmsYO4Zxkkjj87gVUZgmjxO2et4xdjBwc\r
56         LAKqEtfWB4CMYhPQkNi2fzkjiC0iYChx6+IrZhCbWUBa4tvvZiaQcmEBR4nrp1lAwrwC2hLX\r
57         FrZCzd/LJHHz7DJmiISgxMmZT1ggerUkbvx7CdYLMmf5Pw6QMKeAusTFrT/APhAVUJG4tr+d\r
58         bQKj0Cwk3bOQdM9C6F7AyLyKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI10IvN7NELzWldBMjOKxd\r
59         VHcwTjikdIhRgINRiYeXaSWHnxBrYllxZe4hRkkOJiVR3n/enH5CfEn5KZUZicUZ8UWlOanF\r
60         hxglOJiVRHinGgHleFMSK6tSi/JhUtIcLErivCHe/32FBNITS1KzU1MLUotgsjIcHEoSvLF+\r
61         QI2CRanpqRVpmTklCGkmDk6Q4TxAw4NBaniLCxJzizPTIfKnGHU57j1aeZhRiCUvPy9VSpz3\r
62         OkiRAEhRRmke3BxYOnrFKA70ljDveZAqHmAqg5v0CmgJE9ASHVMOkCUliQgpqQZGp+u//82+\r
63         tlFPd5/Dk5Le3vh1iV1zyjeGcnouD2tN/xf76+yhQgVB/awvIpHTikx9Fae2cIpcN2h7Oum8\r
64         yW6PLzIHnvFfs1DMC7n358OKh+XaufPDb88qetkwL0jJunNpe0X39oPO+UF3zi3ImBUeVMR4\r
65         uzvtxekzPAv2N7YclfxVpVxx9yCDEktxRqKhFnNRcSIAL0LWLiIDAAA=\r
66 Cc: notmuch@notmuchmail.org\r
67 X-BeenThere: notmuch@notmuchmail.org\r
68 X-Mailman-Version: 2.1.13\r
69 Precedence: list\r
70 List-Id: "Use and development of the notmuch mail system."\r
71         <notmuch.notmuchmail.org>\r
72 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
75 List-Post: <mailto:notmuch@notmuchmail.org>\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
77 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
78         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
79 X-List-Received-Date: Tue, 28 Jun 2011 03:49:49 -0000\r
80 \r
81 Quoth Dmitry Kurochkin on Jun 28 at  5:03 am:\r
82 > > >  The only way I know to\r
83 > > > reliably kill a child process is to open a pipe to it and have it exit\r
84 > > > on its own when it reads EOF.  Unfortunately, I couldn't find a way to\r
85 > > > do this with an emacs daemon (it appears daemon mode aggressively\r
86 > > > cleans up things like pipes), but here's a different approach:\r
87 > > > \r
88 > > >     coproc emacs --batch --eval "(while t (eval (read)))"\r
89 > > >     EMACSFD=${COPROC[1]}\r
90 > > >     trap "echo '(kill-emacs)' >&$EMACSFD" EXIT\r
91 > > > \r
92 > > >     echo '(message "Hi")' >&$EMACSFD\r
93 > > >     # ...\r
94 > > > \r
95 > > > This is, basically, a poor man's emacs server, but the coprocess pipe\r
96 > > > binds it tightly to the shell.  If the shell exits for *any* reason,\r
97 > > > the pipe will be closed by the kernel, emacs will read an EOF, and\r
98 > > > exit.\r
99 > > \r
100 > > I like this idea.\r
101 > > \r
102 > > >  The trap is there just to cleanly shut down in case of a normal\r
103 > > > exit [1].\r
104 > > \r
105 > > For normal exit we should just put this into test_done.  Otherwise it is\r
106 > > not a normal exit and we do not care about Emacs error message.  No?\r
107 > > \r
108 > > >  This also has the advantage that read-from-minibuffer still\r
109 > > > works:\r
110 > > > \r
111 > > >     echo '(message (read-from-minibuffer ""))' >&$EMACSFD\r
112 > > >     echo 'Test' >&$EMACSFD\r
113 > > > \r
114 > > > Thoughts?\r
115 > > > \r
116 > > \r
117 > > I like it and I will implement it.  Thanks for the idea.\r
118 > > \r
119\r
120 > While implementing the idea, I stumbled upon a problem: we need to know\r
121 > when Emacs finished what we echoed or failed with an error.  At the\r
122 > moment tests fail because they check for OUTPUT before Emacs creates it.\r
123\r
124 > We can tell Emacs to print some special marker and wait for it.  But\r
125 > there may be exceptions and errors which may make it difficult.  I did\r
126 > not found a good solution yet.  Would love to hear your thoughts :)\r
127 \r
128 Oof, yes, of course.  How about making the one-line poor man's emacs\r
129 server slightly less poor?  Use a FIFO to communicate completion.\r
130 Something like,\r
131 \r
132 EMACSDONE=$TEST_DIRECTORY/emacsdone\r
133 mkfifo $EMACSDONE\r
134 coproc emacs --batch --eval '(while t (eval (read)) (write-region "\n" nil "'$EMACSDONE'" t 0))'\r
135 EMACSFD=${COPROC[1]}\r
136 \r
137 test_emacs() {\r
138     echo "$1" >&$EMACSFD\r
139     read <$EMACSDONE\r
140 }\r
141 \r
142 test_emacs '(sleep-for 2)'\r
143 test_emacs '(message "Hi")'\r
144 \r
145 echo '(kill-emacs)' >&$EMACSFD\r