--- /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 8B8A26DE100D\r
+ for <notmuch@notmuchmail.org>; Wed, 6 Jan 2016 11:04:04 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.072\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.072 tagged_above=-999 required=5 tests=[AWL=0.612, \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 NO-4DxUCzC1z for <notmuch@notmuchmail.org>;\r
+ Wed, 6 Jan 2016 11:04:01 -0800 (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 EF7936DE100C\r
+ for <notmuch@notmuchmail.org>; Wed, 6 Jan 2016 11:04:00 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 09F591000DF; Wed, 6 Jan 2016 21:04:05 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org,\r
+ sojkam1@fel.cvut.cz\r
+Cc: tomi.ollila@iki.fi\r
+Subject: [PATCH v6] devel/emacs: add devel/try-emacs-mua\r
+Date: Wed, 6 Jan 2016 21:04:03 +0200\r
+Message-Id: <1452107043-14408-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.6.4\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: Wed, 06 Jan 2016 19:04:04 -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
+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
+less talk, more diff, since v5\r
+( id:1451946112-23573-1-git-send-email-tomi.ollila@iki.fi )\r
+\r
+(line numbers missing, as I did this by diffing patches...)\r
+\r
+= thinko\r
+\r
+/// -;; Try the notmuch emacs client located in ../notmuch/emacs directory\r
+*** +;; Try the notmuch emacs client located in ../emacs/ directory\r
+\r
+= the change\r
+\r
+/// -(setq initial-buffer-choice t) ;; *scratch* buffer\r
+*** +(setq initial-buffer-choice nil\r
+*** + inhibit-startup-screen t)\r
+\r
+= combined setq (verified with (setq a 1 b a) ... => b = 1)\r
+\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
+*** + (setq try-notmuch-source-directory (directory-file-name pdir)\r
+*** + try-notmuch-emacs-directory (concat pdir "emacs/")\r
+*** + load-path (cons try-notmuch-emacs-directory load-path)))\r
+\r
+= how did I miss this change in v5?\r
+\r
+/// - (insert "Notmuch cli executable "\r
+*** + (insert "Notmuch CLI executable "\r
+\r
+= clearer (it is effectively the same)\r
+\r
+/// - (set-buffer "*scratch*")\r
+/// - (lisp-interaction-mode)\r
+/// - (goto-char (point-min))\r
+/// - (forward-line 2)\r
+/// - (set-buffer-modified-p nil)))\r
+*** + (with-current-buffer "*scratch*"\r
+*** + (lisp-interaction-mode)\r
+*** + (goto-char (point-min))\r
+*** + (forward-line 2)\r
+*** + (set-buffer-modified-p nil))))\r
+\r
+\r
+ devel/try-emacs-mua | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 file changed, 157 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..b0a62c25b28f\r
+--- /dev/null\r
++++ b/devel/try-emacs-mua\r
+@@ -0,0 +1,157 @@\r
++#!/bin/sh\r
++:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit\r
++;;\r
++;; Try the notmuch emacs client located in ../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 nil\r
++ inhibit-startup-screen t)\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
++ try-notmuch-emacs-directory (concat pdir "emacs/")\r
++ 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
++ (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
++ (with-current-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
+\r