Re: Hi all
[notmuch-archives.git] / 28 / 8421db03f24447fb2ec413ae35eb5b469560e5
1 Return-Path: <too@guru-group.fi>\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 6B38B6DE133A\r
6  for <notmuch@notmuchmail.org>; Fri, 13 Nov 2015 15:30:04 -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.127\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.127 tagged_above=-999 required=5 tests=[AWL=0.667, \r
12  RP_MATCHES_RCVD=-0.55, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id ieVRxBwj3y13 for <notmuch@notmuchmail.org>;\r
17  Fri, 13 Nov 2015 15:30:01 -0800 (PST)\r
18 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
19  by arlo.cworth.org (Postfix) with ESMTP id 9A4486DE12F3\r
20  for <notmuch@notmuchmail.org>; Fri, 13 Nov 2015 15:30:00 -0800 (PST)\r
21 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
22  id 717D21000C6; Sat, 14 Nov 2015 01:29:58 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: notmuch@notmuchmail.org\r
25 Cc: tomi.ollila@iki.fi\r
26 Subject: [PATCH v3] devel/emacs: add devel/try-emacs-mua.sh\r
27 Date: Sat, 14 Nov 2015 01:29:57 +0200\r
28 Message-Id: <1447457397-11688-1-git-send-email-tomi.ollila@iki.fi>\r
29 X-Mailer: git-send-email 2.0.0\r
30 X-BeenThere: notmuch@notmuchmail.org\r
31 X-Mailman-Version: 2.1.20\r
32 Precedence: list\r
33 List-Id: "Use and development of the notmuch mail system."\r
34  <notmuch.notmuchmail.org>\r
35 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
36  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
38 List-Post: <mailto:notmuch@notmuchmail.org>\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
40 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
42 X-List-Received-Date: Fri, 13 Nov 2015 23:30:04 -0000\r
43 \r
44 devel/try-emacs-mua.sh provides an easy way to try and experiment with\r
45 the notmuch emacs client provided in emacs subdirectory of notmuch\r
46 source tree.\r
47 \r
48 User is required to choose whether to run emacs with -q, -Q or neither\r
49 -- and experienced ones may add other command line options, like\r
50 '-f notmuch'.\r
51 \r
52 With emaces older than 24.4 it is checked that none of the .elc files\r
53 in notmuch/emacs directory is older than their corresponding .el files\r
54 before running emacs. With newer emaces variable `load-prefer-newer'\r
55 is effective so having old .elcs do not matter.\r
56 \r
57 Last possibility for "error" is when emacs starts and loads notmuch\r
58 (by init file) before there is change to have notmuch/emacs directory\r
59 in load-path. This time the message is written to emacs' *scratch* buffer.\r
60 \r
61 If everything is OK, the *scratch* buffer is filled with some lisp code\r
62 which user can evaluate before running notmuch functions.\r
63 ---\r
64 \r
65 Version 3 (I guess) -- the discovery Mark made in\r
66 id:87si4bwrsu.fsf@qmul.ac.uk has been fixed (originally to perl code,\r
67 but now converted to shell) -- and changed to just recognize that there\r
68 are old .elc files -- and the check is done only for emacses < 24.4.\r
69 Now loading of "notmuch" is wrapped in (let ((load-prefer-newer t)) ...).\r
70 \r
71 I tried tricks to ensure that notmuch*.el files are (always) loaded, but\r
72 it either got too complicated (hacky, potentially fragile defadvices), or\r
73 I saw plenty of *.el.gz uncompressions happening (and recursion loop in\r
74 jka-compr before that)...\r
75 \r
76 There is one notably change to the previous one -- before loading notmuch\r
77 there is check whether it is already loaded; if it is there is no point\r
78 going further here. Thanks for this discovery goes to IRC debugging\r
79 section with (mark and) "pseudomyne".\r
80 \r
81  devel/try-emacs-mua.sh | 117 +++++++++++++++++++++++++++++++++++++++++++++++++\r
82  1 file changed, 117 insertions(+)\r
83  create mode 100755 devel/try-emacs-mua.sh\r
84 \r
85 diff --git a/devel/try-emacs-mua.sh b/devel/try-emacs-mua.sh\r
86 new file mode 100755\r
87 index 000000000000..e8406e3cb143\r
88 --- /dev/null\r
89 +++ b/devel/try-emacs-mua.sh\r
90 @@ -0,0 +1,117 @@\r
91 +#!/bin/sh\r
92 +\r
93 +# This script offers an easy way to try and experiment with the\r
94 +# notmuch emacs client provided in notmuch/emacs directory.\r
95 +\r
96 +set -eu\r
97 +\r
98 +test $# -gt 0 || {\r
99 +       exec >&2\r
100 +       echo\r
101 +       echo "Usage: $0 '' | q | Q [other-emacs-args]"\r
102 +       echo\r
103 +       printf "  $0 %s\n" "'' starts emacs without either -q or -Q option" \\r
104 +               "q  starts emacs with -q" \\r
105 +               "Q  starts emacs with -Q"\r
106 +       echo\r
107 +       exit 1\r
108 +}\r
109 +\r
110 +case $1 in '') opt=\r
111 +       ;; q | -q) opt=-q\r
112 +       ;; Q | -Q) opt=-Q\r
113 +       ;; *) echo "option '$1' not '', 'q' nor 'Q'" >&2; exit 1\r
114 +esac\r
115 +shift\r
116 +\r
117 +case $0 in\r
118 +       *\"*)   echo "'$0' contain one or more '\"'s" >&2; exit 1 ;;\r
119 +       *\\*)   echo "'$0' contain one or more '\\'s" >&2; exit 1 ;;\r
120 +       */*)    d0=${0%/*} ;;\r
121 +       *)      d0=.\r
122 +esac\r
123 +\r
124 +pwd=$PWD\r
125 +cd "$d0"/..\r
126 +nmd=$PWD\r
127 +emd=$PWD/emacs\r
128 +\r
129 +test -f "$emd"/notmuch-lib.el || {\r
130 +       echo "Cannot find notmuch-emacs source directory" >&2\r
131 +       exit 1\r
132 +}\r
133 +\r
134 +case `exec 2>&1 "${EMACS:-emacs}" -Q --batch -eval \\r
135 +       '(message (if (boundp '\''load-prefer-newer) "<-yes->" "<-no->"))'`\r
136 +in (*'<-no->'*)\r
137 +       allnew=true\r
138 +       for elc in "$emd"/*.elc\r
139 +       do\r
140 +               test -f "$elc" || continue\r
141 +               if test "$elc" -ot "${elc%c}"\r
142 +               then\r
143 +                       echo "'$elc' is older than '${elc%c}'" >&2\r
144 +                       allnew=false\r
145 +               fi\r
146 +       done\r
147 +       $allnew || {\r
148 +               exec >&2\r
149 +               echo\r
150 +               echo "In directory '$emd' there are .elc files that are"\r
151 +               echo "older than their corresponding .el files."\r
152 +               echo "Please remove (or recompile) these older files and try again."\r
153 +               echo\r
154 +               exit 1\r
155 +       }\r
156 +       unset allnew\r
157 +esac\r
158 +\r
159 +if test -x "$nmd"/notmuch\r
160 +then\r
161 +       nmin='\r
162 +To use accompanied notmuch binary from the same source, evaluate\r
163 +(setq exec-path (cons \"'"$nmd"'\" exec-path))\r
164 +Note: Evaluating the above may be followed by unintended database\r
165 +upgrade and getting back to old version may require dump & restore.\r
166 +'\r
167 +else\r
168 +       nmin=\r
169 +fi\r
170 +\r
171 +if test "$opt" = '-q' || test "$opt" = '-Q'\r
172 +then\r
173 +       qin='\r
174 +If you want to load your .emacs startup file now, evaluate\r
175 +(load \"~/.emacs\")\r
176 +\r
177 +If you want to use packages (e.g. company from elpa) evaluate\r
178 +(progn (require '\''package) (package-initialize))\r
179 +'\r
180 +else\r
181 +       qin='\r
182 +To view initialization time messages, evaluate\r
183 +(pop-to-buffer \"*Messages*\")\r
184 +'\r
185 +fi\r
186 +\r
187 +cd "$pwd"\r
188 +\r
189 +exec "${EMACS:-emacs}" $opt --debug-init -L "$emd" --eval '\r
190 +(with-current-buffer "*scratch*"\r
191 +  (if (featurep '\''notmuch)\r
192 +      (insert "\r
193 +Notmuch has been loaded to this emacs (during processing of the init file)\r
194 +which means it is (most probably) loaded from different source than expected.\r
195 +\r
196 +Please rerun \"'"$0"'\" with '"'q'"' to disable\r
197 +processing of the init file -- you can load it after emacs has started.\n\n")\r
198 +    (let ((load-prefer-newer t)) (load "notmuch" t))\r
199 +    (insert "\r
200 +Go to the end of the following lines and type C-x C-e to evaluate\r
201 +(or C-j which is shorter but inserts evaluation results into buffer)\r
202 +\r
203 +To \"disable\" mail sending, evaluate\r
204 +(setq message-send-mail-function (lambda () t))\r
205 +'"$nmin$qin"'\r
206 +To start notmuch (hello) screen, evaluate\r
207 +(notmuch-hello)")) (set-buffer-modified-p nil))' "$@"\r
208 -- \r
209 2.0.0\r
210 \r