Re: [PATCH] devel/emacs: add devel/try-emacs-mua.sh
[notmuch-archives.git] / 93 / 3573a91a68eb6cad8febae69c910c9aba4cf82
1 Return-Path: <markwalters1009@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 arlo.cworth.org (Postfix) with ESMTP id 2C5626DE192D\r
6  for <notmuch@notmuchmail.org>; Thu, 12 Nov 2015 00:22:33 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.169\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.169 tagged_above=-999 required=5 tests=[AWL=0.401,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id yktzz5ewBwg6 for <notmuch@notmuchmail.org>;\r
19  Thu, 12 Nov 2015 00:22:30 -0800 (PST)\r
20 Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com\r
21  [74.125.82.41]) by arlo.cworth.org (Postfix) with ESMTPS id 3AC566DE14F2 for\r
22  <notmuch@notmuchmail.org>; Thu, 12 Nov 2015 00:22:30 -0800 (PST)\r
23 Received: by wmec201 with SMTP id c201so20537374wme.0\r
24  for <notmuch@notmuchmail.org>; Thu, 12 Nov 2015 00:22:28 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
27  :message-id:mime-version:content-type;\r
28  bh=JA/Gabfs+zBTurDeA4YmLhx5RVygsTZ4jyyCRJu4ykM=;\r
29  b=bDmWmG1aT76sYdTF4u8u02WtOdE5QALzpK/VoqPetUbORTha7Mz8rV1DRbJWpFPrc/\r
30  v3yLp5a/Ra5RYCWB9GVW03B54Uwlun/imSzP9zQ6Se9zC46VPTfr1Nr54Itu/2b5kgoV\r
31  LldSyhyU3TjgmHmS/1w7BjdhFzorOWgCp31ak7qJETbVqs5V4pFZTWy+1uQy/BBqjIlZ\r
32  PTjxlLgn/UrBFJJjpPHuRLAZn1Xe9Au3CcS6RYwdaP0jDGu62VWrUI/wuYstU9OBUpZi\r
33  /eEiH+dqr6vI+rFhUC6hedcE/ls3OxxGrOsbfMpvNY4wcVy8+q4PejaTyceWnyg3CijG\r
34  cfFg==\r
35 X-Received: by 10.28.47.212 with SMTP id v203mr270743wmv.37.1447316548173;\r
36  Thu, 12 Nov 2015 00:22:28 -0800 (PST)\r
37 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
38  by smtp.gmail.com with ESMTPSA id ej10sm12236481wjd.32.2015.11.12.00.22.26\r
39  (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
40  Thu, 12 Nov 2015 00:22:27 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
43 Cc: tomi.ollila@iki.fi\r
44 Subject: Re: [PATCH] devel/emacs: add devel/try-emacs-mua.sh\r
45 In-Reply-To: <1446390985-20989-1-git-send-email-tomi.ollila@iki.fi>\r
46 References: <1446390985-20989-1-git-send-email-tomi.ollila@iki.fi>\r
47 User-Agent: Notmuch/0.21~rc1+46~gbcd385e (http://notmuchmail.org) Emacs/23.4.1\r
48  (x86_64-pc-linux-gnu)\r
49 Date: Thu, 12 Nov 2015 08:22:25 +0000\r
50 Message-ID: <87si4bwrsu.fsf@qmul.ac.uk>\r
51 MIME-Version: 1.0\r
52 Content-Type: text/plain; charset=us-ascii\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.20\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57  <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
59  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
64  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Thu, 12 Nov 2015 08:22:33 -0000\r
66 \r
67 \r
68 > devel/try-emacs-mua.sh provides an easy way to try and experiment with\r
69 > the notmuch emacs client provided in emacs subdirectory of notmuch\r
70 > source tree.\r
71 >\r
72 > User is required to choose whether to run emacs with -q, -Q or neither\r
73 > -- and experienced ones may add other command line options, like\r
74 > '-f notmuch'.\r
75 >\r
76 > This script ensures that no .el files are newer than corresponding .elc\r
77 > files so that user (/developer!) does not accidentally experiment with\r
78 > outdated elisp files. The emacs variable to have the same effect,\r
79 > `load-prefer-newer' is not available until emacs 24.4.\r
80 >\r
81 > The *scratch* buffer is filled with some code user can execute before\r
82 > running notmuch code.\r
83 \r
84 I like this -- a nice simple way to get to a working but uncustomised\r
85 test environment.\r
86 \r
87 I don't know how easy the following would be but one addition that I\r
88 would find very useful would be a way to make this use the test\r
89 corpus. This would be useful for giving a completely standard\r
90 environment for interactive testing, but also for debugging what is\r
91 going on when tests fail.\r
92 \r
93 Of course that is a feature request and should not delay the feature.\r
94 \r
95 Finally, I think there is a bug: \r
96 \r
97 \r
98 > ---\r
99 >\r
100 > Addressed David's comments in id:87d1xdtim1.fsf@maritornes.cs.unb.ca\r
101 > with 2 updates:\r
102 >      1) removed "address completion insinuate"\r
103 >      2) added code to initialize package system when using -q or -Q\r
104 >\r
105 >  devel/try-emacs-mua.sh | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
106 >  1 file changed, 92 insertions(+)\r
107 >  create mode 100755 devel/try-emacs-mua.sh\r
108 >\r
109 > diff --git a/devel/try-emacs-mua.sh b/devel/try-emacs-mua.sh\r
110 > new file mode 100755\r
111 > index 000000000000..71be152c2346\r
112 > --- /dev/null\r
113 > +++ b/devel/try-emacs-mua.sh\r
114 > @@ -0,0 +1,92 @@\r
115 > +#!/bin/sh\r
116 > +\r
117 > +# This script provides an easy way to try and experiment with the\r
118 > +# notmuch emacs client provided in notmuch/emacs directory.\r
119 > +\r
120 > +set -eu\r
121 > +\r
122 > +test $# -gt 0 || {\r
123 > +     exec >&2\r
124 > +     echo\r
125 > +     echo "Usage: $0 '' | q | Q [other-emacs-args]"\r
126 > +     echo\r
127 > +     printf "  $0 %s\n" "'' starts emacs without either -q or -Q option" \\r
128 > +             "q  starts emacs with -q" \\r
129 > +             "Q  starts emacs with -Q"\r
130 > +     echo\r
131 > +     echo Note that if there are notmuch-emacs .elc files that are older than\r
132 > +     echo their corresponding .el files those older .elcs will be removed.\r
133 > +     echo\r
134 > +     exit 1\r
135 > +}\r
136 > +\r
137 > +case $1 in '') opt=\r
138 > +     ;; q | -q) opt=-q\r
139 > +     ;; Q | -Q) opt=-Q\r
140 > +     ;; *) echo "option '$1' not '', 'q' nor 'Q'" >&2; exit 1\r
141 > +esac\r
142 > +shift\r
143 > +\r
144 > +case $0 in\r
145 > +     *\"*)   echo "'$0' contain one or more '\"'s" >&2; exit 1 ;;\r
146 > +     */*)    d0=${0%/*} ;;\r
147 > +     *)      d0=.\r
148 > +esac\r
149 > +\r
150 > +pwd=$PWD\r
151 > +cd "$d0/.."\r
152 > +nmd=$PWD\r
153 > +emd=$PWD/emacs\r
154 > +\r
155 > +test -f "$nmd"/emacs/notmuch-lib.el || {\r
156 > +     echo "Cannot find notmuch-emacs source directory"\r
157 > +     exit 1\r
158 > +}\r
159 > +\r
160 > +if test -x "$nmd"/notmuch\r
161 > +then\r
162 > +     nmin='\r
163 > +To use accompanied notmuch binary from the same source, evaluate\r
164 > +(setq exec-path (cons \"'"$nmd"'\" exec-path))\r
165 > +Note: Evaluating the above may be followed by unintended database\r
166 > +upgrade and getting back to old version may require dump & restore.\r
167 > +'\r
168 > +else\r
169 > +     nmin=\r
170 > +fi\r
171 > +\r
172 > +if test "$opt" = '-q' || test "$opt" = '-Q'\r
173 > +then\r
174 > +     pkgin='\r
175 > +If you want to use packages (like company from elpa) evaluate\r
176 > +(progn (require '\''package) (package-initialize))\r
177 > +'\r
178 > +else\r
179 > +     pkgin=\r
180 > +fi\r
181 \r
182 As far as I can see at this point we are in $nmd not $emd so the\r
183 following does not delete stale .elc files.\r
184 \r
185 > +\r
186 > +# ensure we don't load .elc files that are older than corresponding .el file\r
187 > +# the emacs variable `load-prefer-newer' is not available until emacs 24.4\r
188 > +perl -e 'use strict; use warnings;\r
189 > +while (<*.elc>) {\r
190 > +     my $elc = $_; s/elc$/el/;\r
191 > +     if (-M $_ < -M $elc) {\r
192 > +             warn "$_ is newer than $elc. Removing $elc\n";\r
193 > +             unlink $elc or die "Failed to remove '\''$elc'\'': $!\n";\r
194 > +     }\r
195 > +}'\r
196 \r
197 \r
198 Best wishes\r
199 \r
200 Mark\r
201 \r
202 > +\r
203 > +cd "$pwd"\r
204 > +\r
205 > +# note: whitespace in $EMACS splits to command and args\r
206 > +exec ${EMACS:-emacs} $opt -L "$emd" -l "$emd"/notmuch.el "$@" --eval '\r
207 > +(with-current-buffer "*scratch*"\r
208 > +  (insert "\r
209 > +Go to the end of the following lines and type C-x C-e to evaluate\r
210 > +(or C-j which is shorter but inserts evaluation results into buffer)\r
211 > +\r
212 > +To \"disable\" mail sending, evaluate\r
213 > +(setq message-send-mail-function (lambda () t))\r
214 > +'"$nmin$pkgin"'\r
215 > +To start notmuch (hello) screen, evaluate\r
216 > +(notmuch-hello)") (set-buffer-modified-p nil))'\r
217 > -- \r
218 > 2.0.0\r
219 >\r
220 > _______________________________________________\r
221 > notmuch mailing list\r
222 > notmuch@notmuchmail.org\r
223 > https://notmuchmail.org/mailman/listinfo/notmuch\r