1 Return-Path: <tomi.ollila@iki.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 191D46DE13DB
\r
6 for <notmuch@notmuchmail.org>; Tue, 5 Jan 2016 12:36:43 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.671 tagged_above=-999 required=5 tests=[AWL=0.019,
\r
12 SPF_NEUTRAL=0.652] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id FeVT0yV_0emg for <notmuch@notmuchmail.org>;
\r
16 Tue, 5 Jan 2016 12:36:40 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by arlo.cworth.org (Postfix) with ESMTP id 96EA86DE13AF
\r
19 for <notmuch@notmuchmail.org>; Tue, 5 Jan 2016 12:36:39 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id 19AF01000CD;
\r
22 Tue, 5 Jan 2016 22:36:55 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: Michal Sojka <sojkam1@fel.cvut.cz>, notmuch@notmuchmail.org
\r
25 Subject: Re: [PATCH v5] devel/emacs: add devel/try-emacs-mua
\r
26 In-Reply-To: <87egdxx78z.fsf@steelpick.2x.cz>
\r
27 References: <1451946112-23573-1-git-send-email-tomi.ollila@iki.fi>
\r
28 <87egdxx78z.fsf@steelpick.2x.cz>
\r
29 User-Agent: Notmuch/0.21+32~g73439f8 (http://notmuchmail.org) Emacs/24.3.1
\r
30 (x86_64-unknown-linux-gnu)
\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
32 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
33 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
34 Date: Tue, 05 Jan 2016 22:36:54 +0200
\r
35 Message-ID: <m2r3hvu5jt.fsf@guru.guru-group.fi>
\r
37 Content-Type: text/plain
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.20
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Tue, 05 Jan 2016 20:36:43 -0000
\r
52 On Tue, Jan 05 2016, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
\r
56 > this looks almost good. A few minor comments below.
\r
58 > On Mon, Jan 04 2016, Tomi Ollila wrote:
\r
59 >> devel/try-emacs-mua provides an easy way to try and experiment
\r
60 >> with the notmuch emacs client distributed in emacs subdirectory of
\r
61 >> the notmuch source tree.
\r
63 >> try-emacs-mua starts a new emacs process and if initial checks pass
\r
64 >> *scratch* buffer is filled with information of how to begin.
\r
66 >> Normal emacs command line arguments can be used, like -q or -Q.
\r
67 >> These arguments are appended verbatim to the starting emacs process.
\r
69 >> If the emacs version in use is smaller than 24.4, special care is taken
\r
70 >> to ensure that notmuch*.elc files older than corresponding .el files
\r
71 >> are not loaded. Since emacs 24.4, setting `load-prefer-newer' variable
\r
72 >> takes care of this.
\r
75 >> Thanks to Michal for review of v4
\r
76 >> id:1450610032-23776-1-git-send-email-tomi.ollila@iki.fi
\r
77 >> in id:87vb7aco77.fsf@steelpick.2x.cz
\r
79 >> This should address the issues:
\r
81 >> 1) no more command line filtering
\r
82 >> 2) dropped (outcommented) file-truename advising
\r
83 >> 3) added information which notmuch binary is used
\r
84 >> 4) dropped popping messages buffer (fixing 2 issues)
\r
87 >> * code to load ~/.emacs.d/notmuch-config.el if exists and not loaded already
\r
88 >> * pop messages buffer if (require 'notmuch) fails
\r
89 >> * don't suggest package-initialize if emacs version is 23
\r
92 >> devel/try-emacs-mua | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
93 >> 1 file changed, 156 insertions(+)
\r
94 >> create mode 100755 devel/try-emacs-mua
\r
96 >> diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua
\r
97 >> new file mode 100755
\r
98 >> index 000000000000..0236b438c30a
\r
100 >> +++ b/devel/try-emacs-mua
\r
101 >> @@ -0,0 +1,156 @@
\r
103 >> +:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit
\r
105 >> +;; Try the notmuch emacs client located in ../notmuch/emacs directory
\r
107 >> +;; Run this without arguments; emacs window opens with some usage information
\r
109 >> +;; Authors: Tomi Ollila <tomi.ollila@iki.fi>
\r
111 >> +;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point...
\r
113 >> +;; Licence: GPLv3+
\r
116 >> +(message "Starting '%s'" load-file-name)
\r
118 >> +(set-buffer "*scratch*")
\r
120 >> +(setq initial-buffer-choice t) ;; *scratch* buffer
\r
122 > After initial tuning of emacs configuration according to the hints in
\r
123 > the scratch buffer, people might want to automate things. For example
\r
126 > devel/try-emacs-mua -q -f notmuch-hello
\r
128 > This does not work as one would expect, because the notmuch-hello buffer
\r
129 > is buried under the *scratch* buffer. To get the hello screen after the
\r
130 > start one has to run:
\r
132 > devel/try-emacs-mua -q -f notmuch-hello --eval '(setq initial-buffer-choice nil)'
\r
134 Simpler is to change the above code line to:
\r
136 (setq initial-buffer-choice nil
\r
137 inhibit-startup-screen t)
\r
139 Now the visible buffer is *scratch* by default -- and works more closely
\r
140 how emacs works normally.
\r
142 > This could be also documented in the scratch buffer. Or it might be
\r
143 > easier, in this case, to run emacs without this script at all. There
\r
144 > will be no logging, but this might be OK for some people.
\r
146 > Actually I don't know who are you writing this script for? For notmuch
\r
147 > developers or for users who want to debug or test development version?
\r
149 First of all, for me & other notmuch developers. After a few months break
\r
150 when I do some notmuch elisp coding and try to test it I hope I don't have
\r
151 to remember so much setup things and if something initially goes wrong I
\r
152 might get visible hints to the screen.
\r
154 And also to users to test development version -- or any other version by
\r
155 copying this file to notmuch/devel *OR* notmuch/emacs directory (works
\r
156 from both locations). And when they run and get into problems, posting
\r
157 the contents of *Messages* buffer may provide useful information.
\r
160 >> +(when (featurep 'notmuch)
\r
162 >> +Notmuch has been loaded to this emacs (during processing of the init file)
\r
163 >> +which means it is (most probably) loaded from different source than expected.
\r
165 >> +Please run \"" (file-name-nondirectory load-file-name)
\r
166 >> +"\" with '-q' (or '-Q') as an argument, to disable
\r
167 >> +processing of the init file -- you can load it after emacs has started\n
\r
168 >> +exit emacs (y or n)? ")
\r
169 >> + (if (y-or-n-p "exit emacs")
\r
171 >> + (error "Stopped reading %s" load-file-name)))
\r
173 >> +(let ((pdir (file-name-directory
\r
174 >> + (directory-file-name (file-name-directory load-file-name)))))
\r
175 >> + (unless (file-exists-p (concat pdir "emacs/notmuch-lib.el"))
\r
176 >> + (insert "Cannot find notmuch-emacs source directory
\r
177 >> +while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")
\r
178 >> + (if (y-or-n-p "exit emacs")
\r
180 >> + (error "Stopped reading %s" load-file-name)))
\r
181 >> + (setq try-notmuch-source-directory (directory-file-name pdir))
\r
182 >> + (setq try-notmuch-emacs-directory (concat pdir "emacs/"))
\r
183 >> + (setq load-path (cons try-notmuch-emacs-directory load-path)))
\r
185 >> +;; they say advice doesn't work for primitives (functions from c source)
\r
186 >> +;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)
\r
187 >> +;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)
\r
188 >> +;; note also that the old, "obsolete" defadvice mechanism was used, but that
\r
189 >> +;; is the only one available for emacs 23 and 24 up to 24.3.
\r
191 >> +(if (boundp 'load-prefer-newer)
\r
192 >> + (defadvice require (before before-require activate)
\r
193 >> + (unless (featurep feature)
\r
194 >> + (message "require: %s" feature)))
\r
195 >> + ;; else: special require "short-circuit"; after load feature is provided...
\r
196 >> + ;; ... in notmuch sources we always use require and there are no loops
\r
197 >> + (defadvice require (before before-require activate)
\r
198 >> + (unless (featurep feature)
\r
199 >> + (message "require: %s" feature)
\r
200 >> + (let ((name (symbol-name feature)))
\r
201 >> + (if (and (string-match "^notmuch" name)
\r
202 >> + (file-newer-than-file-p
\r
203 >> + (concat try-notmuch-emacs-directory name ".el")
\r
204 >> + (concat try-notmuch-emacs-directory name ".elc")))
\r
205 >> + (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)
\r
208 >> +(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")
\r
210 >> +(let ((notmuch-path (executable-find "notmuch")))
\r
211 >> + (insert "Notmuch cli executable "
\r
213 > Nitpick: I'd prefer CLI in all caps.
\r
215 That looks better to me, too.
\r
221 Thanks for the review,
\r