Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / f6 / 2bcba77589bc984abd98db038c53e4d75381dc
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 8B8A26DE100D\r
6  for <notmuch@notmuchmail.org>; Wed,  6 Jan 2016 11:04: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.072\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.072 tagged_above=-999 required=5 tests=[AWL=0.612, \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 NO-4DxUCzC1z for <notmuch@notmuchmail.org>;\r
17  Wed,  6 Jan 2016 11:04: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 EF7936DE100C\r
20  for <notmuch@notmuchmail.org>; Wed,  6 Jan 2016 11:04:00 -0800 (PST)\r
21 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
22  id 09F591000DF; Wed,  6 Jan 2016 21:04:05 +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 v6] devel/emacs: add devel/try-emacs-mua\r
28 Date: Wed,  6 Jan 2016 21:04:03 +0200\r
29 Message-Id: <1452107043-14408-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: Wed, 06 Jan 2016 19:04:04 -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 less talk, more diff, since v5\r
62 ( id:1451946112-23573-1-git-send-email-tomi.ollila@iki.fi )\r
63 \r
64 (line numbers missing, as I did this by diffing patches...)\r
65 \r
66 = thinko\r
67 \r
68 /// -;; Try the notmuch emacs client located in ../notmuch/emacs directory\r
69 *** +;; Try the notmuch emacs client located in ../emacs/ directory\r
70 \r
71 = the change\r
72 \r
73 /// -(setq initial-buffer-choice t) ;; *scratch* buffer\r
74 *** +(setq initial-buffer-choice nil\r
75 *** +      inhibit-startup-screen t)\r
76 \r
77 = combined setq (verified with (setq a 1 b a) ... => b = 1)\r
78 \r
79 /// -  (setq try-notmuch-source-directory (directory-file-name pdir))\r
80 /// -  (setq try-notmuch-emacs-directory (concat pdir "emacs/"))\r
81 /// -  (setq load-path (cons try-notmuch-emacs-directory load-path)))\r
82 *** +  (setq try-notmuch-source-directory (directory-file-name pdir)\r
83 *** +        try-notmuch-emacs-directory (concat pdir "emacs/")\r
84 *** +        load-path (cons try-notmuch-emacs-directory load-path)))\r
85 \r
86 = how did I miss this change in v5?\r
87 \r
88 /// -  (insert "Notmuch cli executable "\r
89 *** +  (insert "Notmuch CLI executable "\r
90 \r
91 = clearer (it is effectively the same)\r
92 \r
93 /// -       (set-buffer "*scratch*")\r
94 /// -       (lisp-interaction-mode)\r
95 /// -       (goto-char (point-min))\r
96 /// -       (forward-line 2)\r
97 /// -       (set-buffer-modified-p nil)))\r
98 *** +       (with-current-buffer "*scratch*"\r
99 *** +         (lisp-interaction-mode)\r
100 *** +         (goto-char (point-min))\r
101 *** +         (forward-line 2)\r
102 *** +         (set-buffer-modified-p nil))))\r
103 \r
104 \r
105  devel/try-emacs-mua | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
106  1 file changed, 157 insertions(+)\r
107  create mode 100755 devel/try-emacs-mua\r
108 \r
109 diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua\r
110 new file mode 100755\r
111 index 000000000000..b0a62c25b28f\r
112 --- /dev/null\r
113 +++ b/devel/try-emacs-mua\r
114 @@ -0,0 +1,157 @@\r
115 +#!/bin/sh\r
116 +:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit\r
117 +;;\r
118 +;; Try the notmuch emacs client located in ../emacs/ directory\r
119 +;;\r
120 +;; Run this without arguments; emacs window opens with some usage information\r
121 +;;\r
122 +;; Authors: Tomi Ollila <tomi.ollila@iki.fi>\r
123 +;;\r
124 +;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point...\r
125 +;;\r
126 +;; Licence: GPLv3+\r
127 +;;\r
128 +\r
129 +(message "Starting '%s'" load-file-name)\r
130 +\r
131 +(set-buffer "*scratch*")\r
132 +\r
133 +(setq initial-buffer-choice nil\r
134 +      inhibit-startup-screen t)\r
135 +\r
136 +(when (featurep 'notmuch)\r
137 +  (insert "\r
138 +Notmuch has been loaded to this emacs (during processing of the init file)\r
139 +which means it is (most probably) loaded from different source than expected.\r
140 +\r
141 +Please run \"" (file-name-nondirectory load-file-name)\r
142 +"\" with '-q' (or '-Q') as an argument, to disable\r
143 +processing of the init file -- you can load it after emacs has started\n\r
144 +exit emacs (y or n)? ")\r
145 +  (if (y-or-n-p "exit emacs")\r
146 +      (kill-emacs)\r
147 +    (error "Stopped reading %s" load-file-name)))\r
148 +\r
149 +(let ((pdir (file-name-directory\r
150 +            (directory-file-name (file-name-directory load-file-name)))))\r
151 +  (unless (file-exists-p (concat pdir "emacs/notmuch-lib.el"))\r
152 +    (insert "Cannot find notmuch-emacs source directory\r
153 +while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")\r
154 +    (if (y-or-n-p "exit emacs")\r
155 +       (kill-emacs)\r
156 +      (error "Stopped reading %s" load-file-name)))\r
157 +  (setq try-notmuch-source-directory (directory-file-name pdir)\r
158 +       try-notmuch-emacs-directory (concat pdir "emacs/")\r
159 +       load-path (cons try-notmuch-emacs-directory load-path)))\r
160 +\r
161 +;; they say advice doesn't work for primitives (functions from c source)\r
162 +;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)\r
163 +;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)\r
164 +;; note also that the old, "obsolete" defadvice mechanism was used, but that\r
165 +;; is the only one available for emacs 23 and 24 up to 24.3.\r
166 +\r
167 +(if (boundp 'load-prefer-newer)\r
168 +    (defadvice require (before before-require activate)\r
169 +      (unless (featurep feature)\r
170 +       (message "require: %s" feature)))\r
171 +  ;; else: special require "short-circuit"; after load feature is provided...\r
172 +  ;; ... in notmuch sources we always use require and there are no loops\r
173 +  (defadvice require (before before-require activate)\r
174 +    (unless (featurep feature)\r
175 +      (message "require: %s" feature)\r
176 +      (let ((name (symbol-name feature)))\r
177 +       (if (and (string-match "^notmuch" name)\r
178 +                (file-newer-than-file-p\r
179 +                 (concat try-notmuch-emacs-directory name ".el")\r
180 +                 (concat try-notmuch-emacs-directory name ".elc")))\r
181 +           (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)\r
182 +         )))))\r
183 +\r
184 +(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")\r
185 +\r
186 +(let ((notmuch-path (executable-find "notmuch")))\r
187 +  (insert "Notmuch CLI executable "\r
188 +         (if notmuch-path (concat "is " notmuch-path) "not found!") "\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 +   (let ((error-message-string (error-message-string err)))\r
199 +     (insert "\nLoading notmuch failed: " error-message-string "\n")\r
200 +     (message "Loading notmuch failed: %s" error-message-string)\r
201 +     (insert "See *Messages* buffer for more information.\n")\r
202 +     (if init-file-user\r
203 +        (message "Hint: %s -q (or -Q) may help" load-file-name))\r
204 +     (pop-to-buffer "*Messages*")\r
205 +     (error "Stopped reading %s" load-file-name))))\r
206 +\r
207 +(insert "\r
208 +Go to the end of the following lines and type C-x C-e to evaluate\r
209 +(or C-j which is shorter but inserts evaluation results into buffer)\r
210 +\r
211 +To \"disable\" mail sending, evaluate\r
212 +* (setq message-send-mail-function (lambda () t))\r
213 +")\r
214 +\r
215 +(if (file-exists-p (concat try-notmuch-source-directory "/notmuch"))\r
216 +    (insert "\r
217 +To use accompanied notmuch binary from the same source, evaluate\r
218 +* (setq exec-path (cons \"" try-notmuch-source-directory  "\" exec-path))\r
219 +Note: Evaluating the above may be followed by unintended database\r
220 +upgrade and getting back to old version may require dump & restore.\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 ((emacs-init-file-name) (notmuch-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 emacs-init-file-name fn)))\r
233 +         '("~/.emacs.d/init.el" "~/.emacs" "~/.emacs.el"))\r
234 +    (setq notmuch-init-file-name "~/.emacs.d/notmuch-config.el")\r
235 +    (unless (file-exists-p notmuch-init-file-name)\r
236 +       (setq notmuch-init-file-name nil))\r
237 +    (if (and emacs-init-file-name notmuch-init-file-name)\r
238 +       (insert "\r
239 +If you want to load your initialization files now, evaluate\n* (progn")\r
240 +      (if (or emacs-init-file-name notmuch-init-file-name)\r
241 +         (insert "\r
242 +If you want to load your initialization file now, evaluate\n*")))\r
243 +    (if emacs-init-file-name\r
244 +       (insert " (load \"" emacs-init-file-name "\")"))\r
245 +    (if notmuch-init-file-name\r
246 +       (insert " (load \"" notmuch-init-file-name "\")"))\r
247 +    (if (and emacs-init-file-name notmuch-init-file-name)\r
248 +       (insert ")"))\r
249 +    (if (or emacs-init-file-name notmuch-init-file-name)\r
250 +       (insert "\n")))\r
251 +  (if (>= emacs-major-version 24)\r
252 +      (insert "\r
253 +If you want to use packages (e.g. company from elpa) evaluate\r
254 +* (progn (require 'package) (package-initialize))\r
255 +")))\r
256 +\r
257 +(insert "\r
258 +To start notmuch (hello) screen, evaluate\r
259 +* (notmuch-hello)")\r
260 +\r
261 +(add-hook 'emacs-startup-hook\r
262 +         (lambda ()\r
263 +           (with-current-buffer "*scratch*"\r
264 +             (lisp-interaction-mode)\r
265 +             (goto-char (point-min))\r
266 +             (forward-line 2)\r
267 +             (set-buffer-modified-p nil))))\r
268 +\r
269 +;; Local Variables:\r
270 +;; mode: emacs-lisp\r
271 +;; End:\r
272 -- \r
273 2.6.4\r
274 \r