Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 34 / 4f5c6cc8a86ebe19c2702432c148d59d26d635
1 Return-Path: <wsh@2x.cz>\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 931DA6DE177E\r
6  for <notmuch@notmuchmail.org>; Sun,  3 Jan 2016 14:13:13 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.475\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.475 tagged_above=-999 required=5 tests=[AWL=0.805,\r
12   RCVD_IN_DNSWL_MED=-2.3, T_FRT_BELOW2=0.01,\r
13  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 UlX7We7heU3T for <notmuch@notmuchmail.org>;\r
17  Sun,  3 Jan 2016 14:13:09 -0800 (PST)\r
18 X-Greylist: delayed 370 seconds by postgrey-1.35 at arlo;\r
19  Sun, 03 Jan 2016 14:13:09 PST\r
20 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
21  by arlo.cworth.org (Postfix) with ESMTP id A64A46DE1769\r
22  for <notmuch@notmuchmail.org>; Sun,  3 Jan 2016 14:13:09 -0800 (PST)\r
23 Received: from localhost (unknown [192.168.200.7])\r
24  by max.feld.cvut.cz (Postfix) with ESMTP id 209D319F49A7;\r
25  Sun,  3 Jan 2016 23:06:56 +0100 (CET)\r
26 X-Virus-Scanned: IMAP STYX AMAVIS\r
27 Received: from max.feld.cvut.cz ([192.168.200.1])\r
28  by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, port 10044)\r
29  with ESMTP id ba4F7ygdfeRn; Sun,  3 Jan 2016 23:06:53 +0100 (CET)\r
30 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
31  by max.feld.cvut.cz (Postfix) with ESMTP id C2F7B19F46FB;\r
32  Sun,  3 Jan 2016 23:06:53 +0100 (CET)\r
33 Received: from wsh by steelpick.2x.cz with local (Exim 4.86)\r
34  (envelope-from <wsh@2x.cz>)\r
35  id 1aFqnc-0006lY-SA; Sun, 03 Jan 2016 23:06:52 +0100\r
36 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
37 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
38 Subject: Re: [PATCH v4] devel/emacs: add devel/try-emacs-mua\r
39 In-Reply-To: <1450610032-23776-1-git-send-email-tomi.ollila@iki.fi>\r
40 References: <1450610032-23776-1-git-send-email-tomi.ollila@iki.fi>\r
41 User-Agent: Notmuch/0.21+30~g55c056a (http://notmuchmail.org) Emacs/24.5.1\r
42  (x86_64-pc-linux-gnu)\r
43 Date: Sun, 03 Jan 2016 23:06:52 +0100\r
44 Message-ID: <87vb7aco77.fsf@steelpick.2x.cz>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.20\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51  <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
53  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
58  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Sun, 03 Jan 2016 22:13:13 -0000\r
60 \r
61 Hi Tomi,\r
62 \r
63 On Sun, Dec 20 2015, Tomi Ollila wrote:\r
64 > devel/try-emacs-mua provides an easy way to try and experiment\r
65 > with the notmuch emacs client distributed in emacs subdirectory of\r
66 > the notmuch source tree.\r
67 >\r
68 > try-emacs-mua starts a new emacs process and if initial checks pass\r
69 > *scratch* buffer is filled with information of how to begin.\r
70 >\r
71 > User can add normal emacs flags, like -q, -Q and e.g. -f notmuch. Any\r
72 > given plain filename arguments are filtered out (with message).\r
73 \r
74 Why are plain files filtered? Yesterday, when I experimented with\r
75 jl-encrypt.el, I started emacs like:\r
76 \r
77   emacs -Q --directory ... --load notmuch.el /tmp/jl-encrypt.el\r
78 \r
79 This allowed me to experiment with it (edebug), modify it and restart\r
80 emacs sessions easily without the need to type C-x C-f and the file name\r
81 in every session.\r
82 \r
83 > If the emacs version in use is smaller than 24.4, special care is taken\r
84 > to ensure that notmuch*.elc files older than corresponding .el files\r
85 > are not loaded. Since emacs 24.4, setting `load-prefer-newer' variable\r
86 > takes care of this.\r
87 > ---\r
88 >\r
89 > Now all-elisp, vs v3: id:1447457397-11688-1-git-send-email-tomi.ollila@iki.fi\r
90 >\r
91 > In id:87si4bwrsu.fsf@qmul.ac.uk Mark had some thoughts if something from this\r
92 > could perhaps be used as some idea how to improve test testing. We'll have\r
93 > to think more of that later. Rest of the review is pretty much irrelevant\r
94 > for this (But I fixed that particular bug before turning to this ;).\r
95 >\r
96 >  devel/try-emacs-mua | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
97 >  1 file changed, 153 insertions(+)\r
98 >  create mode 100755 devel/try-emacs-mua\r
99 >\r
100 > diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua\r
101 > new file mode 100755\r
102 > index 000000000000..1f916d2806f9\r
103 > --- /dev/null\r
104 > +++ b/devel/try-emacs-mua\r
105 > @@ -0,0 +1,153 @@\r
106 > +#!/bin/sh\r
107 > +:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit\r
108 \r
109 Huh! Nice trick, especially the ":;" :)\r
110 \r
111 > +;;\r
112 > +;; Try the notmuch emacs client located in ../notmuch/emacs directory\r
113 > +;;\r
114 > +;; Run this without arguments; emacs window opens with some usage information\r
115 > +;;\r
116 > +;; Authors: Tomi Ollila <tomi.ollila@iki.fi>\r
117 > +;;\r
118 > +;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point...\r
119 > +;;\r
120 > +;; Licence: GPLv3+\r
121 > +;;\r
122 > +\r
123 > +(message "Starting '%s'" load-file-name)\r
124 > +\r
125 > +(set-buffer "*scratch*")\r
126 > +\r
127 > +(setq initial-buffer-choice t) ;; *scratch* buffer\r
128 > +\r
129 > +(when (featurep 'notmuch)\r
130 > +  (insert "\r
131 > +Notmuch has been loaded to this emacs (during processing of the init file)\r
132 > +which means it is (most probably) loaded from different source than expected.\r
133 > +\r
134 > +Please run \"" (file-name-nondirectory load-file-name)\r
135 > +"\" with '-q' (or '-Q') as an argument, to disable\r
136 > +processing of the init file -- you can load it after emacs has started\n\r
137 > +exit emacs (y or n)? ")\r
138 > +  (if (y-or-n-p "exit emacs")\r
139 > +      (kill-emacs)\r
140 > +    (error "Stopped reading %s" load-file-name)))\r
141 > +\r
142 > +(let ((pdir (file-name-directory\r
143 > +          (directory-file-name (file-name-directory load-file-name)))))\r
144 > +  (unless (file-exists-p (concat pdir "emacs/notmuch-lib.el"))\r
145 > +    (insert "Cannot find notmuch-emacs source directory\r
146 > +while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")\r
147 > +    (if (y-or-n-p "exit emacs")\r
148 > +     (kill-emacs)\r
149 > +      (error "Stopped reading %s" load-file-name)))\r
150 > +  (setq try-notmuch-source-directory (directory-file-name pdir))\r
151 > +  (setq try-notmuch-emacs-directory (concat pdir "emacs/"))\r
152 > +  (setq load-path (cons try-notmuch-emacs-directory load-path)))\r
153 > +\r
154 > +;; for logging, debugging and load tracing (broke on emacs 24.5.1 :O)\r
155 > +;;(defadvice file-truename (before before-file-truename activate)\r
156 > +;;;;  (message "file-truename: '%s' '%s' '%s'" filename counter prev-dirs))\r
157 > +;;  (unless counter\r
158 > +;;    (message "file-truename: %s" filename)))\r
159 \r
160 What is the benefit of advising file-truename? Especially when you do\r
161 other type of logging below. I'd prefer to have this as a comment in the\r
162 file. Or is this some leftover from your experiments?\r
163 \r
164 > +\r
165 > +;; they say advice doesn't work for primitives (functions from c source)\r
166 > +;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)\r
167 > +;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)\r
168 > +;; note also that the old, "obsolete" defadvice mechanism was used, but that\r
169 > +;; is the only one available for emacs 23 and 24 up to 24.3.\r
170 > +\r
171 > +(if (boundp 'load-prefer-newer)\r
172 > +    (defadvice require (before before-require activate)\r
173 > +      (unless (featurep feature)\r
174 > +     (message "require: %s" feature)))\r
175 > +  ;; else: special require "short-circuit"; after load feature is provided...\r
176 > +  ;; ... in notmuch sources we always use require and there are no loops\r
177 > +  (defadvice require (before before-require activate)\r
178 > +    (unless (featurep feature)\r
179 > +      (message "require: %s" feature)\r
180 > +      (let ((name (symbol-name feature)))\r
181 > +     (if (and (string-match "^notmuch" name)\r
182 > +              (file-newer-than-file-p\r
183 > +               (concat try-notmuch-emacs-directory name ".el")\r
184 > +               (concat try-notmuch-emacs-directory name ".elc")))\r
185 > +         (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)\r
186 > +       )))))\r
187 > +\r
188 > +(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")\r
189 > +\r
190 > +(condition-case err\r
191 > +;; "opportunistic" load-prefer-newer -- will be effective since emacs 24.4\r
192 > +    (let ((load-prefer-newer t)\r
193 > +       (force-load-messages t))\r
194 > +      (require 'notmuch))\r
195 > +  ;; specifying `debug' here lets the debugger run\r
196 > +  ;; if `debug-on-error' is non-nil.\r
197 > +  ((debug error)\r
198 > +   (progn\r
199 > +     (insert "\nLoading notmuch failed: " (error-message-string err) "\n")\r
200 > +     (insert "See *Messages* buffer for more information.\n")\r
201 > +     (error "Stopped reading %s" load-file-name))))\r
202 > +\r
203 > +(insert "\r
204 > +Go to the end of the following lines and type C-x C-e to evaluate\r
205 > +(or C-j which is shorter but inserts evaluation results into buffer)\r
206 > +\r
207 > +To \"disable\" mail sending, evaluate\r
208 > +* (setq message-send-mail-function (lambda () t))\r
209 > +")\r
210 > +\r
211 > +(if (file-exists-p (concat try-notmuch-source-directory "/notmuch"))\r
212 > +    (insert "\r
213 > +To use accompanied notmuch binary from the same source, evaluate\r
214 > +* (setq exec-path (cons \"" try-notmuch-source-directory  "\" exec-path))\r
215 > +Note: Evaluating the above may be followed by unintended database\r
216 > +upgrade and getting back to old version may require dump & restore.\r
217 > +"))\r
218 \r
219 You can also inform the user which notmuch binary will be used without\r
220 the above setq.\r
221 \r
222 > +\r
223 > +(if init-file-user ;; nil, if '-q' or '-Q' is given, but no '-u' 'USER'\r
224 > +    (insert "\r
225 > +Your init file was processed during emacs startup. If you want to test\r
226 > +notmuch emacs mail client without your emacs init file interfering, Run\n\""\r
227 > +(file-name-nondirectory load-file-name) "\" with '-q' (or '-Q') as an argument.\r
228 > +")\r
229 > +  (let ((init-file-name))\r
230 > +    ;; determining init file name in startup.el/command-line is too complicated\r
231 > +    ;; to be duplicated here; these 3 file names covers most of the users\r
232 > +    (mapc (lambda (fn) (if (file-exists-p fn) (setq init-file-name fn)))\r
233 > +       '("~/.emacs.d/init.el" "~/.emacs" "~/.emacs.el"))\r
234 > +    (if init-file-name\r
235 > +     (insert "\r
236 > +If you want to load your emacs init file now, evaluate\r
237 > +* (load \"" init-file-name "\")\r
238 > +")))\r
239 > +  (insert "\r
240 > +If you want to use packages (e.g. company from elpa) evaluate\r
241 > +* (progn (require 'package) (package-initialize))\r
242 > +"))\r
243 > +\r
244 > +(insert "\r
245 > +To start notmuch (hello) screen, evaluate\r
246 > +* (notmuch-hello)")\r
247 > +\r
248 > +(setq try-emacs-pop-messages-buffers nil)\r
249 \r
250 If this variable was named something like arg-ignored, the code bellow\r
251 would be easier to understand.\r
252 \r
253 > +(add-hook 'command-line-functions\r
254 > +       (lambda ()\r
255 > +         (unless try-emacs-pop-messages-buffers (message "%s" ""))\r
256 > +         (message "*** Ignoring arg '%s'" argi)\r
257 > +         (setq try-emacs-pop-messages-buffers t)))\r
258 > +\r
259 > +(add-hook 'emacs-startup-hook\r
260 > +       (lambda ()\r
261 > +         (when try-emacs-pop-messages-buffers\r
262 > +           (message "%s" "")\r
263 > +           (message "Press 'q' to hide this window")\r
264 \r
265 Pressing 'q' doesn't work under Emacs 23.\r
266 \r
267 > +           (pop-to-buffer "*Messages*"))\r
268 > +         (set-buffer "*scratch*")\r
269 > +         (lisp-interaction-mode)\r
270 > +         (goto-char (point-min))\r
271 > +         (forward-line)\r
272 > +         (set-buffer-modified-p nil)))\r
273 > +\r
274 > +;; Local Variables:\r
275 > +;; mode: emacs-lisp\r
276 > +;; End:\r
277 \r
278 -Michal\r