Re: A systematic way of handling Xapian lock errors?
[notmuch-archives.git] / 50 / adc8b3986735ad32b5352bc1b1919b43cdd5bc
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 28A056DE1413\r
6  for <notmuch@notmuchmail.org>; Sun, 20 Dec 2015 03:22:38 -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.092\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.092 tagged_above=-999 required=5 tests=[AWL=0.632, \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 qHQna_fIo4zG for <notmuch@notmuchmail.org>;\r
17  Sun, 20 Dec 2015 03:22:35 -0800 (PST)\r
18 X-Greylist: delayed 537 seconds by postgrey-1.35 at arlo;\r
19  Sun, 20 Dec 2015 03:22:34 PST\r
20 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
21  by arlo.cworth.org (Postfix) with ESMTP id CC0666DE025F\r
22  for <notmuch@notmuchmail.org>; Sun, 20 Dec 2015 03:22:34 -0800 (PST)\r
23 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
24  id E0E301000DE; Sun, 20 Dec 2015 13:13:53 +0200 (EET)\r
25 From: Tomi Ollila <tomi.ollila@iki.fi>\r
26 To: notmuch@notmuchmail.org\r
27 Cc: tomi.ollila@iki.fi\r
28 Subject: [PATCH v4] devel/emacs: add devel/try-emacs-mua\r
29 Date: Sun, 20 Dec 2015 13:13:52 +0200\r
30 Message-Id: <1450610032-23776-1-git-send-email-tomi.ollila@iki.fi>\r
31 X-Mailer: git-send-email 2.0.0\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.20\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36  <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
38  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
43  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Sun, 20 Dec 2015 11:22:38 -0000\r
45 \r
46 devel/try-emacs-mua provides an easy way to try and experiment\r
47 with the notmuch emacs client distributed in emacs subdirectory of\r
48 the notmuch source tree.\r
49 \r
50 try-emacs-mua starts a new emacs process and if initial checks pass\r
51 *scratch* buffer is filled with information of how to begin.\r
52 \r
53 User can add normal emacs flags, like -q, -Q and e.g. -f notmuch. Any\r
54 given plain filename arguments are filtered out (with message).\r
55 \r
56 If the emacs version in use is smaller than 24.4, special care is taken\r
57 to ensure that notmuch*.elc files older than corresponding .el files\r
58 are not loaded. Since emacs 24.4, setting `load-prefer-newer' variable\r
59 takes care of this.\r
60 ---\r
61 \r
62 Now all-elisp, vs v3: id:1447457397-11688-1-git-send-email-tomi.ollila@iki.fi\r
63 \r
64 In id:87si4bwrsu.fsf@qmul.ac.uk Mark had some thoughts if something from this\r
65 could perhaps be used as some idea how to improve test testing. We'll have\r
66 to think more of that later. Rest of the review is pretty much irrelevant\r
67 for this (But I fixed that particular bug before turning to this ;).\r
68 \r
69  devel/try-emacs-mua | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
70  1 file changed, 153 insertions(+)\r
71  create mode 100755 devel/try-emacs-mua\r
72 \r
73 diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua\r
74 new file mode 100755\r
75 index 000000000000..1f916d2806f9\r
76 --- /dev/null\r
77 +++ b/devel/try-emacs-mua\r
78 @@ -0,0 +1,153 @@\r
79 +#!/bin/sh\r
80 +:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit\r
81 +;;\r
82 +;; Try the notmuch emacs client located in ../notmuch/emacs directory\r
83 +;;\r
84 +;; Run this without arguments; emacs window opens with some usage information\r
85 +;;\r
86 +;; Authors: Tomi Ollila <tomi.ollila@iki.fi>\r
87 +;;\r
88 +;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point...\r
89 +;;\r
90 +;; Licence: GPLv3+\r
91 +;;\r
92 +\r
93 +(message "Starting '%s'" load-file-name)\r
94 +\r
95 +(set-buffer "*scratch*")\r
96 +\r
97 +(setq initial-buffer-choice t) ;; *scratch* buffer\r
98 +\r
99 +(when (featurep 'notmuch)\r
100 +  (insert "\r
101 +Notmuch has been loaded to this emacs (during processing of the init file)\r
102 +which means it is (most probably) loaded from different source than expected.\r
103 +\r
104 +Please run \"" (file-name-nondirectory load-file-name)\r
105 +"\" with '-q' (or '-Q') as an argument, to disable\r
106 +processing of the init file -- you can load it after emacs has started\n\r
107 +exit emacs (y or n)? ")\r
108 +  (if (y-or-n-p "exit emacs")\r
109 +      (kill-emacs)\r
110 +    (error "Stopped reading %s" load-file-name)))\r
111 +\r
112 +(let ((pdir (file-name-directory\r
113 +            (directory-file-name (file-name-directory load-file-name)))))\r
114 +  (unless (file-exists-p (concat pdir "emacs/notmuch-lib.el"))\r
115 +    (insert "Cannot find notmuch-emacs source directory\r
116 +while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")\r
117 +    (if (y-or-n-p "exit emacs")\r
118 +       (kill-emacs)\r
119 +      (error "Stopped reading %s" load-file-name)))\r
120 +  (setq try-notmuch-source-directory (directory-file-name pdir))\r
121 +  (setq try-notmuch-emacs-directory (concat pdir "emacs/"))\r
122 +  (setq load-path (cons try-notmuch-emacs-directory load-path)))\r
123 +\r
124 +;; for logging, debugging and load tracing (broke on emacs 24.5.1 :O)\r
125 +;;(defadvice file-truename (before before-file-truename activate)\r
126 +;;;;  (message "file-truename: '%s' '%s' '%s'" filename counter prev-dirs))\r
127 +;;  (unless counter\r
128 +;;    (message "file-truename: %s" filename)))\r
129 +\r
130 +;; they say advice doesn't work for primitives (functions from c source)\r
131 +;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)\r
132 +;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)\r
133 +;; note also that the old, "obsolete" defadvice mechanism was used, but that\r
134 +;; is the only one available for emacs 23 and 24 up to 24.3.\r
135 +\r
136 +(if (boundp 'load-prefer-newer)\r
137 +    (defadvice require (before before-require activate)\r
138 +      (unless (featurep feature)\r
139 +       (message "require: %s" feature)))\r
140 +  ;; else: special require "short-circuit"; after load feature is provided...\r
141 +  ;; ... in notmuch sources we always use require and there are no loops\r
142 +  (defadvice require (before before-require activate)\r
143 +    (unless (featurep feature)\r
144 +      (message "require: %s" feature)\r
145 +      (let ((name (symbol-name feature)))\r
146 +       (if (and (string-match "^notmuch" name)\r
147 +                (file-newer-than-file-p\r
148 +                 (concat try-notmuch-emacs-directory name ".el")\r
149 +                 (concat try-notmuch-emacs-directory name ".elc")))\r
150 +           (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)\r
151 +         )))))\r
152 +\r
153 +(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")\r
154 +\r
155 +(condition-case err\r
156 +;; "opportunistic" load-prefer-newer -- will be effective since emacs 24.4\r
157 +    (let ((load-prefer-newer t)\r
158 +         (force-load-messages t))\r
159 +      (require 'notmuch))\r
160 +  ;; specifying `debug' here lets the debugger run\r
161 +  ;; if `debug-on-error' is non-nil.\r
162 +  ((debug error)\r
163 +   (progn\r
164 +     (insert "\nLoading notmuch failed: " (error-message-string err) "\n")\r
165 +     (insert "See *Messages* buffer for more information.\n")\r
166 +     (error "Stopped reading %s" load-file-name))))\r
167 +\r
168 +(insert "\r
169 +Go to the end of the following lines and type C-x C-e to evaluate\r
170 +(or C-j which is shorter but inserts evaluation results into buffer)\r
171 +\r
172 +To \"disable\" mail sending, evaluate\r
173 +* (setq message-send-mail-function (lambda () t))\r
174 +")\r
175 +\r
176 +(if (file-exists-p (concat try-notmuch-source-directory "/notmuch"))\r
177 +    (insert "\r
178 +To use accompanied notmuch binary from the same source, evaluate\r
179 +* (setq exec-path (cons \"" try-notmuch-source-directory  "\" exec-path))\r
180 +Note: Evaluating the above may be followed by unintended database\r
181 +upgrade and getting back to old version may require dump & restore.\r
182 +"))\r
183 +\r
184 +(if init-file-user ;; nil, if '-q' or '-Q' is given, but no '-u' 'USER'\r
185 +    (insert "\r
186 +Your init file was processed during emacs startup. If you want to test\r
187 +notmuch emacs mail client without your emacs init file interfering, Run\n\""\r
188 +(file-name-nondirectory load-file-name) "\" with '-q' (or '-Q') as an argument.\r
189 +")\r
190 +  (let ((init-file-name))\r
191 +    ;; determining init file name in startup.el/command-line is too complicated\r
192 +    ;; to be duplicated here; these 3 file names covers most of the users\r
193 +    (mapc (lambda (fn) (if (file-exists-p fn) (setq init-file-name fn)))\r
194 +         '("~/.emacs.d/init.el" "~/.emacs" "~/.emacs.el"))\r
195 +    (if init-file-name\r
196 +       (insert "\r
197 +If you want to load your emacs init file now, evaluate\r
198 +* (load \"" init-file-name "\")\r
199 +")))\r
200 +  (insert "\r
201 +If you want to use packages (e.g. company from elpa) evaluate\r
202 +* (progn (require 'package) (package-initialize))\r
203 +"))\r
204 +\r
205 +(insert "\r
206 +To start notmuch (hello) screen, evaluate\r
207 +* (notmuch-hello)")\r
208 +\r
209 +(setq try-emacs-pop-messages-buffers nil)\r
210 +\r
211 +(add-hook 'command-line-functions\r
212 +         (lambda ()\r
213 +           (unless try-emacs-pop-messages-buffers (message "%s" ""))\r
214 +           (message "*** Ignoring arg '%s'" argi)\r
215 +           (setq try-emacs-pop-messages-buffers t)))\r
216 +\r
217 +(add-hook 'emacs-startup-hook\r
218 +         (lambda ()\r
219 +           (when try-emacs-pop-messages-buffers\r
220 +             (message "%s" "")\r
221 +             (message "Press 'q' to hide this window")\r
222 +             (pop-to-buffer "*Messages*"))\r
223 +           (set-buffer "*scratch*")\r
224 +           (lisp-interaction-mode)\r
225 +           (goto-char (point-min))\r
226 +           (forward-line)\r
227 +           (set-buffer-modified-p nil)))\r
228 +\r
229 +;; Local Variables:\r
230 +;; mode: emacs-lisp\r
231 +;; End:\r
232 -- \r
233 2.0.0\r
234 \r