--- /dev/null
+Return-Path: <sojka@merica.cz>\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 DB7476DE1643\r
+ for <notmuch@notmuchmail.org>; Mon, 4 Jan 2016 15:28:14 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.511\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.511 tagged_above=-999 required=5 tests=[AWL=0.799,\r
+ RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 XTHKbz4fm95y for <notmuch@notmuchmail.org>;\r
+ Mon, 4 Jan 2016 15:28:11 -0800 (PST)\r
+X-Greylist: delayed 502 seconds by postgrey-1.35 at arlo;\r
+ Mon, 04 Jan 2016 15:28:08 PST\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+ by arlo.cworth.org (Postfix) with ESMTP id E87576DE1715\r
+ for <notmuch@notmuchmail.org>; Mon, 4 Jan 2016 15:28:08 -0800 (PST)\r
+Received: from localhost (unknown [192.168.200.7])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id DC60A19F47CE;\r
+ Tue, 5 Jan 2016 00:19:42 +0100 (CET)\r
+X-Virus-Scanned: IMAP STYX AMAVIS\r
+Received: from max.feld.cvut.cz ([192.168.200.1])\r
+ by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, port 10044)\r
+ with ESMTP id Ac-80Dfxvxeu; Tue, 5 Jan 2016 00:19:40 +0100 (CET)\r
+Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id D3C8B19F48C3;\r
+ Tue, 5 Jan 2016 00:19:40 +0100 (CET)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.86)\r
+ (envelope-from <sojka@merica.cz>)\r
+ id 1aGEPc-0003oA-5m; Tue, 05 Jan 2016 00:19:40 +0100\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+Cc: tomi.ollila@iki.fi\r
+Subject: Re: [PATCH v5] devel/emacs: add devel/try-emacs-mua\r
+In-Reply-To: <1451946112-23573-1-git-send-email-tomi.ollila@iki.fi>\r
+References: <1451946112-23573-1-git-send-email-tomi.ollila@iki.fi>\r
+User-Agent: Notmuch/0.21+30~g55c056a (http://notmuchmail.org) Emacs/24.5.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Tue, 05 Jan 2016 00:19:40 +0100\r
+Message-ID: <87egdxx78z.fsf@steelpick.2x.cz>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Mon, 04 Jan 2016 23:28:15 -0000\r
+\r
+Hi Tomi,\r
+\r
+this looks almost good. A few minor comments below.\r
+\r
+On Mon, Jan 04 2016, Tomi Ollila wrote:\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
+> Normal emacs command line arguments can be used, like -q or -Q.\r
+> These arguments are appended verbatim to the starting emacs process.\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
+> Thanks to Michal for review of v4\r
+> id:1450610032-23776-1-git-send-email-tomi.ollila@iki.fi\r
+> in id:87vb7aco77.fsf@steelpick.2x.cz\r
+>\r
+> This should address the issues:\r
+>\r
+> 1) no more command line filtering\r
+> 2) dropped (outcommented) file-truename advising\r
+> 3) added information which notmuch binary is used\r
+> 4) dropped popping messages buffer (fixing 2 issues)\r
+>\r
+> Added:\r
+> * code to load ~/.emacs.d/notmuch-config.el if exists and not loaded already\r
+> * pop messages buffer if (require 'notmuch) fails\r
+> * don't suggest package-initialize if emacs version is 23\r
+>\r
+>\r
+> devel/try-emacs-mua | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+> 1 file changed, 156 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..0236b438c30a\r
+> --- /dev/null\r
+> +++ b/devel/try-emacs-mua\r
+> @@ -0,0 +1,156 @@\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
+After initial tuning of emacs configuration according to the hints in\r
+the scratch buffer, people might want to automate things. For example\r
+something like:\r
+\r
+ devel/try-emacs-mua -q -f notmuch-hello\r
+\r
+This does not work as one would expect, because the notmuch-hello buffer\r
+is buried under the *scratch* buffer. To get the hello screen after the\r
+start one has to run:\r
+\r
+ devel/try-emacs-mua -q -f notmuch-hello --eval '(setq initial-buffer-choice nil)'\r
+\r
+This could be also documented in the scratch buffer. Or it might be\r
+easier, in this case, to run emacs without this script at all. There\r
+will be no logging, but this might be OK for some people.\r
+\r
+Actually I don't know who are you writing this script for? For notmuch\r
+developers or for users who want to debug or test development version? \r
+\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
+> +;; 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
+> +(let ((notmuch-path (executable-find "notmuch")))\r
+> + (insert "Notmuch cli executable "\r
+\r
+Nitpick: I'd prefer CLI in all caps.\r
+\r
+Thanks.\r
+-Michal\r
+\r
+> + (if notmuch-path (concat "is " notmuch-path) "not found!") "\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
+> + (let ((error-message-string (error-message-string err)))\r
+> + (insert "\nLoading notmuch failed: " error-message-string "\n")\r
+> + (message "Loading notmuch failed: %s" error-message-string)\r
+> + (insert "See *Messages* buffer for more information.\n")\r
+> + (if init-file-user\r
+> + (message "Hint: %s -q (or -Q) may help" load-file-name))\r
+> + (pop-to-buffer "*Messages*")\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 ((emacs-init-file-name) (notmuch-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 emacs-init-file-name fn)))\r
+> + '("~/.emacs.d/init.el" "~/.emacs" "~/.emacs.el"))\r
+> + (setq notmuch-init-file-name "~/.emacs.d/notmuch-config.el")\r
+> + (unless (file-exists-p notmuch-init-file-name)\r
+> + (setq notmuch-init-file-name nil))\r
+> + (if (and emacs-init-file-name notmuch-init-file-name)\r
+> + (insert "\r
+> +If you want to load your initialization files now, evaluate\n* (progn")\r
+> + (if (or emacs-init-file-name notmuch-init-file-name)\r
+> + (insert "\r
+> +If you want to load your initialization file now, evaluate\n*")))\r
+> + (if emacs-init-file-name\r
+> + (insert " (load \"" emacs-init-file-name "\")"))\r
+> + (if notmuch-init-file-name\r
+> + (insert " (load \"" notmuch-init-file-name "\")"))\r
+> + (if (and emacs-init-file-name notmuch-init-file-name)\r
+> + (insert ")"))\r
+> + (if (or emacs-init-file-name notmuch-init-file-name)\r
+> + (insert "\n")))\r
+> + (if (>= emacs-major-version 24)\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
+> +(add-hook 'emacs-startup-hook\r
+> + (lambda ()\r
+> + (set-buffer "*scratch*")\r
+> + (lisp-interaction-mode)\r
+> + (goto-char (point-min))\r
+> + (forward-line 2)\r
+> + (set-buffer-modified-p nil)))\r
+> +\r
+> +;; Local Variables:\r
+> +;; mode: emacs-lisp\r
+> +;; End:\r
+> --\r
+> 2.6.4\r