--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 28A056DE1413\r
+ for <notmuch@notmuchmail.org>; Sun, 20 Dec 2015 03:22:38 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.092\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.092 tagged_above=-999 required=5 tests=[AWL=0.632, \r
+ RP_MATCHES_RCVD=-0.55, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id qHQna_fIo4zG for <notmuch@notmuchmail.org>;\r
+ Sun, 20 Dec 2015 03:22:35 -0800 (PST)\r
+X-Greylist: delayed 537 seconds by postgrey-1.35 at arlo;\r
+ Sun, 20 Dec 2015 03:22:34 PST\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id CC0666DE025F\r
+ for <notmuch@notmuchmail.org>; Sun, 20 Dec 2015 03:22:34 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id E0E301000DE; Sun, 20 Dec 2015 13:13:53 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Cc: tomi.ollila@iki.fi\r
+Subject: [PATCH v4] devel/emacs: add devel/try-emacs-mua\r
+Date: Sun, 20 Dec 2015 13:13:52 +0200\r
+Message-Id: <1450610032-23776-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.0.0\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 20 Dec 2015 11:22:38 -0000\r
+\r
+devel/try-emacs-mua provides an easy way to try and experiment\r
+with the notmuch emacs client distributed in emacs subdirectory of\r
+the notmuch source tree.\r
+\r
+try-emacs-mua starts a new emacs process and if initial checks pass\r
+*scratch* buffer is filled with information of how to begin.\r
+\r
+User can add normal emacs flags, like -q, -Q and e.g. -f notmuch. Any\r
+given plain filename arguments are filtered out (with message).\r
+\r
+If the emacs version in use is smaller than 24.4, special care is taken\r
+to ensure that notmuch*.elc files older than corresponding .el files\r
+are not loaded. Since emacs 24.4, setting `load-prefer-newer' variable\r
+takes care of this.\r
+---\r
+\r
+Now all-elisp, vs v3: id:1447457397-11688-1-git-send-email-tomi.ollila@iki.fi\r
+\r
+In id:87si4bwrsu.fsf@qmul.ac.uk Mark had some thoughts if something from this\r
+could perhaps be used as some idea how to improve test testing. We'll have\r
+to think more of that later. Rest of the review is pretty much irrelevant\r
+for this (But I fixed that particular bug before turning to this ;).\r
+\r
+ devel/try-emacs-mua | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 file changed, 153 insertions(+)\r
+ create mode 100755 devel/try-emacs-mua\r
+\r
+diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua\r
+new file mode 100755\r
+index 000000000000..1f916d2806f9\r
+--- /dev/null\r
++++ b/devel/try-emacs-mua\r
+@@ -0,0 +1,153 @@\r
++#!/bin/sh\r
++:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit\r
++;;\r
++;; Try the notmuch emacs client located in ../notmuch/emacs directory\r
++;;\r
++;; Run this without arguments; emacs window opens with some usage information\r
++;;\r
++;; Authors: Tomi Ollila <tomi.ollila@iki.fi>\r
++;;\r
++;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point...\r
++;;\r
++;; Licence: GPLv3+\r
++;;\r
++\r
++(message "Starting '%s'" load-file-name)\r
++\r
++(set-buffer "*scratch*")\r
++\r
++(setq initial-buffer-choice t) ;; *scratch* buffer\r
++\r
++(when (featurep 'notmuch)\r
++ (insert "\r
++Notmuch has been loaded to this emacs (during processing of the init file)\r
++which means it is (most probably) loaded from different source than expected.\r
++\r
++Please run \"" (file-name-nondirectory load-file-name)\r
++"\" with '-q' (or '-Q') as an argument, to disable\r
++processing of the init file -- you can load it after emacs has started\n\r
++exit emacs (y or n)? ")\r
++ (if (y-or-n-p "exit emacs")\r
++ (kill-emacs)\r
++ (error "Stopped reading %s" load-file-name)))\r
++\r
++(let ((pdir (file-name-directory\r
++ (directory-file-name (file-name-directory load-file-name)))))\r
++ (unless (file-exists-p (concat pdir "emacs/notmuch-lib.el"))\r
++ (insert "Cannot find notmuch-emacs source directory\r
++while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")\r
++ (if (y-or-n-p "exit emacs")\r
++ (kill-emacs)\r
++ (error "Stopped reading %s" load-file-name)))\r
++ (setq try-notmuch-source-directory (directory-file-name pdir))\r
++ (setq try-notmuch-emacs-directory (concat pdir "emacs/"))\r
++ (setq load-path (cons try-notmuch-emacs-directory load-path)))\r
++\r
++;; for logging, debugging and load tracing (broke on emacs 24.5.1 :O)\r
++;;(defadvice file-truename (before before-file-truename activate)\r
++;;;; (message "file-truename: '%s' '%s' '%s'" filename counter prev-dirs))\r
++;; (unless counter\r
++;; (message "file-truename: %s" filename)))\r
++\r
++;; they say advice doesn't work for primitives (functions from c source)\r
++;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)\r
++;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)\r
++;; note also that the old, "obsolete" defadvice mechanism was used, but that\r
++;; is the only one available for emacs 23 and 24 up to 24.3.\r
++\r
++(if (boundp 'load-prefer-newer)\r
++ (defadvice require (before before-require activate)\r
++ (unless (featurep feature)\r
++ (message "require: %s" feature)))\r
++ ;; else: special require "short-circuit"; after load feature is provided...\r
++ ;; ... in notmuch sources we always use require and there are no loops\r
++ (defadvice require (before before-require activate)\r
++ (unless (featurep feature)\r
++ (message "require: %s" feature)\r
++ (let ((name (symbol-name feature)))\r
++ (if (and (string-match "^notmuch" name)\r
++ (file-newer-than-file-p\r
++ (concat try-notmuch-emacs-directory name ".el")\r
++ (concat try-notmuch-emacs-directory name ".elc")))\r
++ (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)\r
++ )))))\r
++\r
++(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")\r
++\r
++(condition-case err\r
++;; "opportunistic" load-prefer-newer -- will be effective since emacs 24.4\r
++ (let ((load-prefer-newer t)\r
++ (force-load-messages t))\r
++ (require 'notmuch))\r
++ ;; specifying `debug' here lets the debugger run\r
++ ;; if `debug-on-error' is non-nil.\r
++ ((debug error)\r
++ (progn\r
++ (insert "\nLoading notmuch failed: " (error-message-string err) "\n")\r
++ (insert "See *Messages* buffer for more information.\n")\r
++ (error "Stopped reading %s" load-file-name))))\r
++\r
++(insert "\r
++Go to the end of the following lines and type C-x C-e to evaluate\r
++(or C-j which is shorter but inserts evaluation results into buffer)\r
++\r
++To \"disable\" mail sending, evaluate\r
++* (setq message-send-mail-function (lambda () t))\r
++")\r
++\r
++(if (file-exists-p (concat try-notmuch-source-directory "/notmuch"))\r
++ (insert "\r
++To use accompanied notmuch binary from the same source, evaluate\r
++* (setq exec-path (cons \"" try-notmuch-source-directory "\" exec-path))\r
++Note: Evaluating the above may be followed by unintended database\r
++upgrade and getting back to old version may require dump & restore.\r
++"))\r
++\r
++(if init-file-user ;; nil, if '-q' or '-Q' is given, but no '-u' 'USER'\r
++ (insert "\r
++Your init file was processed during emacs startup. If you want to test\r
++notmuch emacs mail client without your emacs init file interfering, Run\n\""\r
++(file-name-nondirectory load-file-name) "\" with '-q' (or '-Q') as an argument.\r
++")\r
++ (let ((init-file-name))\r
++ ;; determining init file name in startup.el/command-line is too complicated\r
++ ;; to be duplicated here; these 3 file names covers most of the users\r
++ (mapc (lambda (fn) (if (file-exists-p fn) (setq init-file-name fn)))\r
++ '("~/.emacs.d/init.el" "~/.emacs" "~/.emacs.el"))\r
++ (if init-file-name\r
++ (insert "\r
++If you want to load your emacs init file now, evaluate\r
++* (load \"" init-file-name "\")\r
++")))\r
++ (insert "\r
++If you want to use packages (e.g. company from elpa) evaluate\r
++* (progn (require 'package) (package-initialize))\r
++"))\r
++\r
++(insert "\r
++To start notmuch (hello) screen, evaluate\r
++* (notmuch-hello)")\r
++\r
++(setq try-emacs-pop-messages-buffers nil)\r
++\r
++(add-hook 'command-line-functions\r
++ (lambda ()\r
++ (unless try-emacs-pop-messages-buffers (message "%s" ""))\r
++ (message "*** Ignoring arg '%s'" argi)\r
++ (setq try-emacs-pop-messages-buffers t)))\r
++\r
++(add-hook 'emacs-startup-hook\r
++ (lambda ()\r
++ (when try-emacs-pop-messages-buffers\r
++ (message "%s" "")\r
++ (message "Press 'q' to hide this window")\r
++ (pop-to-buffer "*Messages*"))\r
++ (set-buffer "*scratch*")\r
++ (lisp-interaction-mode)\r
++ (goto-char (point-min))\r
++ (forward-line)\r
++ (set-buffer-modified-p nil)))\r
++\r
++;; Local Variables:\r
++;; mode: emacs-lisp\r
++;; End:\r
+-- \r
+2.0.0\r
+\r