Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 01 / 52a5527d9eeddd3982b35931d9f000ffb8afee
1 Return-Path: <dmitry.kurochkin@gmail.com>\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 312A5429E32\r
6         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 20:59:57 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 5FyhbP9H9wPb for <notmuch@notmuchmail.org>;\r
17         Mon, 27 Jun 2011 20:59:55 -0700 (PDT)\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id EBF06429E25\r
22         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 20:59:54 -0700 (PDT)\r
23 Received: by bwg12 with SMTP id 12so4868895bwg.26\r
24         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 20:59:53 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:from:to:cc:subject:in-reply-to:references\r
27         :user-agent:date:message-id:mime-version:content-type;\r
28         bh=dBMjWqA0GT9dWIMiXYogIyv7Q8oas3PoZUNY/cR7Cx8=;\r
29         b=gEiorXNPlho2D4z3SccfdLA3Ac8PaFDl4cfKXcm0hMAq1ygXdNxP0OjLT3P3aD6PH4\r
30         aXt1KiXC3lEdnCU/d4f3xA78CoMysfq1AY3Uurvjo/VqSmQvR8Tg7/04Jlz4/UHahaGa\r
31         GDgIZpdCUKu11Bk1Cjiif3zbr+iHZDG65ypow=\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
33         h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
34         :message-id:mime-version:content-type;\r
35         b=qxjE9hdf0CVz8z/cg11wXJFV2poTFMRhhaI4E6yrk8jdh8RG5JiOXpC2iDrmJDKBSb\r
36         NqGTHS6bpJDnyxX8eVtujwerEHgHvtAgjhXTLvJr+dXRNgwUDg/hkisu0EdjWs4BpzRk\r
37         AG48ugxD84Cy3L+qUFABD21YTUtb9g1LWcsDM=\r
38 Received: by 10.204.128.90 with SMTP id j26mr5070053bks.116.1309233593127;\r
39         Mon, 27 Jun 2011 20:59:53 -0700 (PDT)\r
40 Received: from localhost ([91.144.186.21])\r
41         by mx.google.com with ESMTPS id k5sm2869834bka.5.2011.06.27.20.59.51\r
42         (version=TLSv1/SSLv3 cipher=OTHER);\r
43         Mon, 27 Jun 2011 20:59:52 -0700 (PDT)\r
44 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
45 To: Austin Clements <amdragon@MIT.EDU>\r
46 Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests\r
47 In-Reply-To: <20110628034937.GB4120@mit.edu>\r
48 References: <1309132379-24089-1-git-send-email-dmitry.kurochkin@gmail.com>\r
49         <1309146846-30991-1-git-send-email-dmitry.kurochkin@gmail.com>\r
50         <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com>\r
51         <BANLkTi=nwHRndz367K5oh4=tPaU-KNeZ8Q@mail.gmail.com>\r
52         <87hb7byqge.fsf@gmail.com> <87d3hyzs1c.fsf@gmail.com>\r
53         <20110628034937.GB4120@mit.edu>\r
54 User-Agent: Notmuch/0.5-275-g75c95e5 (http://notmuchmail.org) Emacs/23.3.1\r
55         (x86_64-pc-linux-gnu)\r
56 Date: Tue, 28 Jun 2011 07:59:48 +0400\r
57 Message-ID: <87aad2zjuz.fsf@gmail.com>\r
58 MIME-Version: 1.0\r
59 Content-Type: text/plain; charset=us-ascii\r
60 Cc: notmuch@notmuchmail.org\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.13\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65         <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Tue, 28 Jun 2011 03:59:57 -0000\r
74 \r
75 On Mon, 27 Jun 2011 23:49:37 -0400, Austin Clements <amdragon@MIT.EDU> wrote:\r
76 > Quoth Dmitry Kurochkin on Jun 28 at  5:03 am:\r
77 > > > >  The only way I know to\r
78 > > > > reliably kill a child process is to open a pipe to it and have it exit\r
79 > > > > on its own when it reads EOF.  Unfortunately, I couldn't find a way to\r
80 > > > > do this with an emacs daemon (it appears daemon mode aggressively\r
81 > > > > cleans up things like pipes), but here's a different approach:\r
82 > > > > \r
83 > > > >     coproc emacs --batch --eval "(while t (eval (read)))"\r
84 > > > >     EMACSFD=${COPROC[1]}\r
85 > > > >     trap "echo '(kill-emacs)' >&$EMACSFD" EXIT\r
86 > > > > \r
87 > > > >     echo '(message "Hi")' >&$EMACSFD\r
88 > > > >     # ...\r
89 > > > > \r
90 > > > > This is, basically, a poor man's emacs server, but the coprocess pipe\r
91 > > > > binds it tightly to the shell.  If the shell exits for *any* reason,\r
92 > > > > the pipe will be closed by the kernel, emacs will read an EOF, and\r
93 > > > > exit.\r
94 > > > \r
95 > > > I like this idea.\r
96 > > > \r
97 > > > >  The trap is there just to cleanly shut down in case of a normal\r
98 > > > > exit [1].\r
99 > > > \r
100 > > > For normal exit we should just put this into test_done.  Otherwise it is\r
101 > > > not a normal exit and we do not care about Emacs error message.  No?\r
102 > > > \r
103 > > > >  This also has the advantage that read-from-minibuffer still\r
104 > > > > works:\r
105 > > > > \r
106 > > > >     echo '(message (read-from-minibuffer ""))' >&$EMACSFD\r
107 > > > >     echo 'Test' >&$EMACSFD\r
108 > > > > \r
109 > > > > Thoughts?\r
110 > > > > \r
111 > > > \r
112 > > > I like it and I will implement it.  Thanks for the idea.\r
113 > > > \r
114 > > \r
115 > > While implementing the idea, I stumbled upon a problem: we need to know\r
116 > > when Emacs finished what we echoed or failed with an error.  At the\r
117 > > moment tests fail because they check for OUTPUT before Emacs creates it.\r
118 > > \r
119 > > We can tell Emacs to print some special marker and wait for it.  But\r
120 > > there may be exceptions and errors which may make it difficult.  I did\r
121 > > not found a good solution yet.  Would love to hear your thoughts :)\r
122\r
123 > Oof, yes, of course.  How about making the one-line poor man's emacs\r
124 > server slightly less poor?  Use a FIFO to communicate completion.\r
125 > Something like,\r
126\r
127 > EMACSDONE=$TEST_DIRECTORY/emacsdone\r
128 > mkfifo $EMACSDONE\r
129 > coproc emacs --batch --eval '(while t (eval (read)) (write-region "\n" nil "'$EMACSDONE'" t 0))'\r
130 > EMACSFD=${COPROC[1]}\r
131\r
132 > test_emacs() {\r
133 >     echo "$1" >&$EMACSFD\r
134 >     read <$EMACSDONE\r
135 > }\r
136\r
137 > test_emacs '(sleep-for 2)'\r
138 > test_emacs '(message "Hi")'\r
139\r
140 > echo '(kill-emacs)' >&$EMACSFD\r
141 \r
142 I am sure that would work, but I do not like the complexity.  How about\r
143 getting back to standard emacsclient and running a watchdog in the\r
144 emacs?  Like:\r
145 \r
146 (defun orphan-watchdog (pid)\r
147   "Periodically check that the process with id PID is still\r
148 running, quit if it terminated."\r
149   (if (not (process-attributes pid))\r
150       (kill-emacs)\r
151     (run-at-time "1 min" nil orphan-watchdog pid)))\r
152 \r
153 This function (or my other changes) do not work (by yet unknown reason\r
154 :)), but you get the idea.\r
155 \r
156 Regards,\r
157   Dmitry\r