Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 15 / 5013af03c40c915a2d55b8f3d7de5ff333306d
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 9BE786DE1579\r
6  for <notmuch@notmuchmail.org>; Mon,  4 Jan 2016 14:21:50 -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.078\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.078 tagged_above=-999 required=5 tests=[AWL=0.618, \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 VAuSkg1EGLbz for <notmuch@notmuchmail.org>;\r
17  Mon,  4 Jan 2016 14:21:47 -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 7B8DB6DE14A8\r
20  for <notmuch@notmuchmail.org>; Mon,  4 Jan 2016 14:21:46 -0800 (PST)\r
21 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
22  id 0BC261000DF; Tue,  5 Jan 2016 00:22:02 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: notmuch@notmuchmail.org,\r
25         sojkam1@fel.cvut.cz\r
26 Cc: tomi.ollila@iki.fi\r
27 Subject: [PATCH v5] devel/emacs: add devel/try-emacs-mua\r
28 Date: Tue,  5 Jan 2016 00:21:52 +0200\r
29 Message-Id: <1451946112-23573-1-git-send-email-tomi.ollila@iki.fi>\r
30 X-Mailer: git-send-email 2.6.4\r
31 X-BeenThere: notmuch@notmuchmail.org\r
32 X-Mailman-Version: 2.1.20\r
33 Precedence: list\r
34 List-Id: "Use and development of the notmuch mail system."\r
35  <notmuch.notmuchmail.org>\r
36 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
37  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
39 List-Post: <mailto:notmuch@notmuchmail.org>\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
41 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
42  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
43 X-List-Received-Date: Mon, 04 Jan 2016 22:21:50 -0000\r
44 \r
45 devel/try-emacs-mua provides an easy way to try and experiment\r
46 with the notmuch emacs client distributed in emacs subdirectory of\r
47 the notmuch source tree.\r
48 \r
49 try-emacs-mua starts a new emacs process and if initial checks pass\r
50 *scratch* buffer is filled with information of how to begin.\r
51 \r
52 Normal emacs command line arguments can be used, like -q or -Q.\r
53 These arguments are appended verbatim to the starting emacs process.\r
54 \r
55 If the emacs version in use is smaller than 24.4, special care is taken\r
56 to ensure that notmuch*.elc files older than corresponding .el files\r
57 are not loaded. Since emacs 24.4, setting `load-prefer-newer' variable\r
58 takes care of this.\r
59 ---\r
60 \r
61 Thanks to Michal for review of v4\r
62 id:1450610032-23776-1-git-send-email-tomi.ollila@iki.fi\r
63 in id:87vb7aco77.fsf@steelpick.2x.cz\r
64 \r
65 This should address the issues:\r
66 \r
67 1) no more command line filtering\r
68 2) dropped (outcommented) file-truename advising\r
69 3) added information which notmuch binary is used\r
70 4) dropped popping messages buffer (fixing 2 issues)\r
71 \r
72 Added:\r
73 * code to load ~/.emacs.d/notmuch-config.el if exists and not loaded already\r
74 * pop messages buffer if (require 'notmuch) fails\r
75 * don't suggest package-initialize if emacs version is 23\r
76 \r
77 \r
78  devel/try-emacs-mua | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
79  1 file changed, 156 insertions(+)\r
80  create mode 100755 devel/try-emacs-mua\r
81 \r
82 diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua\r
83 new file mode 100755\r
84 index 000000000000..0236b438c30a\r
85 --- /dev/null\r
86 +++ b/devel/try-emacs-mua\r
87 @@ -0,0 +1,156 @@\r
88 +#!/bin/sh\r
89 +:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit\r
90 +;;\r
91 +;; Try the notmuch emacs client located in ../notmuch/emacs directory\r
92 +;;\r
93 +;; Run this without arguments; emacs window opens with some usage information\r
94 +;;\r
95 +;; Authors: Tomi Ollila <tomi.ollila@iki.fi>\r
96 +;;\r
97 +;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point...\r
98 +;;\r
99 +;; Licence: GPLv3+\r
100 +;;\r
101 +\r
102 +(message "Starting '%s'" load-file-name)\r
103 +\r
104 +(set-buffer "*scratch*")\r
105 +\r
106 +(setq initial-buffer-choice t) ;; *scratch* buffer\r
107 +\r
108 +(when (featurep 'notmuch)\r
109 +  (insert "\r
110 +Notmuch has been loaded to this emacs (during processing of the init file)\r
111 +which means it is (most probably) loaded from different source than expected.\r
112 +\r
113 +Please run \"" (file-name-nondirectory load-file-name)\r
114 +"\" with '-q' (or '-Q') as an argument, to disable\r
115 +processing of the init file -- you can load it after emacs has started\n\r
116 +exit 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 +\r
121 +(let ((pdir (file-name-directory\r
122 +            (directory-file-name (file-name-directory load-file-name)))))\r
123 +  (unless (file-exists-p (concat pdir "emacs/notmuch-lib.el"))\r
124 +    (insert "Cannot find notmuch-emacs source directory\r
125 +while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")\r
126 +    (if (y-or-n-p "exit emacs")\r
127 +       (kill-emacs)\r
128 +      (error "Stopped reading %s" load-file-name)))\r
129 +  (setq try-notmuch-source-directory (directory-file-name pdir))\r
130 +  (setq try-notmuch-emacs-directory (concat pdir "emacs/"))\r
131 +  (setq load-path (cons try-notmuch-emacs-directory load-path)))\r
132 +\r
133 +;; they say advice doesn't work for primitives (functions from c source)\r
134 +;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)\r
135 +;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)\r
136 +;; note also that the old, "obsolete" defadvice mechanism was used, but that\r
137 +;; is the only one available for emacs 23 and 24 up to 24.3.\r
138 +\r
139 +(if (boundp 'load-prefer-newer)\r
140 +    (defadvice require (before before-require activate)\r
141 +      (unless (featurep feature)\r
142 +       (message "require: %s" feature)))\r
143 +  ;; else: special require "short-circuit"; after load feature is provided...\r
144 +  ;; ... in notmuch sources we always use require and there are no loops\r
145 +  (defadvice require (before before-require activate)\r
146 +    (unless (featurep feature)\r
147 +      (message "require: %s" feature)\r
148 +      (let ((name (symbol-name feature)))\r
149 +       (if (and (string-match "^notmuch" name)\r
150 +                (file-newer-than-file-p\r
151 +                 (concat try-notmuch-emacs-directory name ".el")\r
152 +                 (concat try-notmuch-emacs-directory name ".elc")))\r
153 +           (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)\r
154 +         )))))\r
155 +\r
156 +(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")\r
157 +\r
158 +(let ((notmuch-path (executable-find "notmuch")))\r
159 +  (insert "Notmuch cli executable "\r
160 +         (if notmuch-path (concat "is " notmuch-path) "not found!") "\n"))\r
161 +\r
162 +(condition-case err\r
163 +;; "opportunistic" load-prefer-newer -- will be effective since emacs 24.4\r
164 +    (let ((load-prefer-newer t)\r
165 +         (force-load-messages t))\r
166 +      (require 'notmuch))\r
167 +  ;; specifying `debug' here lets the debugger run\r
168 +  ;; if `debug-on-error' is non-nil.\r
169 +  ((debug error)\r
170 +   (let ((error-message-string (error-message-string err)))\r
171 +     (insert "\nLoading notmuch failed: " error-message-string "\n")\r
172 +     (message "Loading notmuch failed: %s" error-message-string)\r
173 +     (insert "See *Messages* buffer for more information.\n")\r
174 +     (if init-file-user\r
175 +        (message "Hint: %s -q (or -Q) may help" load-file-name))\r
176 +     (pop-to-buffer "*Messages*")\r
177 +     (error "Stopped reading %s" load-file-name))))\r
178 +\r
179 +(insert "\r
180 +Go to the end of the following lines and type C-x C-e to evaluate\r
181 +(or C-j which is shorter but inserts evaluation results into buffer)\r
182 +\r
183 +To \"disable\" mail sending, evaluate\r
184 +* (setq message-send-mail-function (lambda () t))\r
185 +")\r
186 +\r
187 +(if (file-exists-p (concat try-notmuch-source-directory "/notmuch"))\r
188 +    (insert "\r
189 +To use accompanied notmuch binary from the same source, evaluate\r
190 +* (setq exec-path (cons \"" try-notmuch-source-directory  "\" exec-path))\r
191 +Note: Evaluating the above may be followed by unintended database\r
192 +upgrade and getting back to old version may require dump & restore.\r
193 +"))\r
194 +\r
195 +(if init-file-user ;; nil, if '-q' or '-Q' is given, but no '-u' 'USER'\r
196 +    (insert "\r
197 +Your init file was processed during emacs startup. If you want to test\r
198 +notmuch emacs mail client without your emacs init file interfering, Run\n\""\r
199 +(file-name-nondirectory load-file-name) "\" with '-q' (or '-Q') as an argument.\r
200 +")\r
201 +  (let ((emacs-init-file-name) (notmuch-init-file-name))\r
202 +    ;; determining init file name in startup.el/command-line is too complicated\r
203 +    ;; to be duplicated here; these 3 file names covers most of the users\r
204 +    (mapc (lambda (fn) (if (file-exists-p fn) (setq emacs-init-file-name fn)))\r
205 +         '("~/.emacs.d/init.el" "~/.emacs" "~/.emacs.el"))\r
206 +    (setq notmuch-init-file-name "~/.emacs.d/notmuch-config.el")\r
207 +    (unless (file-exists-p notmuch-init-file-name)\r
208 +       (setq notmuch-init-file-name nil))\r
209 +    (if (and emacs-init-file-name notmuch-init-file-name)\r
210 +       (insert "\r
211 +If you want to load your initialization files now, evaluate\n* (progn")\r
212 +      (if (or emacs-init-file-name notmuch-init-file-name)\r
213 +         (insert "\r
214 +If you want to load your initialization file now, evaluate\n*")))\r
215 +    (if emacs-init-file-name\r
216 +       (insert " (load \"" emacs-init-file-name "\")"))\r
217 +    (if notmuch-init-file-name\r
218 +       (insert " (load \"" notmuch-init-file-name "\")"))\r
219 +    (if (and emacs-init-file-name notmuch-init-file-name)\r
220 +       (insert ")"))\r
221 +    (if (or emacs-init-file-name notmuch-init-file-name)\r
222 +       (insert "\n")))\r
223 +  (if (>= emacs-major-version 24)\r
224 +      (insert "\r
225 +If you want to use packages (e.g. company from elpa) evaluate\r
226 +* (progn (require 'package) (package-initialize))\r
227 +")))\r
228 +\r
229 +(insert "\r
230 +To start notmuch (hello) screen, evaluate\r
231 +* (notmuch-hello)")\r
232 +\r
233 +(add-hook 'emacs-startup-hook\r
234 +         (lambda ()\r
235 +           (set-buffer "*scratch*")\r
236 +           (lisp-interaction-mode)\r
237 +           (goto-char (point-min))\r
238 +           (forward-line 2)\r
239 +           (set-buffer-modified-p nil)))\r
240 +\r
241 +;; Local Variables:\r
242 +;; mode: emacs-lisp\r
243 +;; End:\r
244 -- \r
245 2.6.4\r
246 \r