--- /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 BDDA86DE0A9A\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Nov 2015 07:16:36 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.143\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.143 tagged_above=-999 required=5 tests=[AWL=0.683, \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 fkwjljcjUJzU for <notmuch@notmuchmail.org>;\r
+ Sun, 1 Nov 2015 07:16:33 -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 6902B6DE0A94\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Nov 2015 07:16:33 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id AB9F71000B3; Sun, 1 Nov 2015 17:16:26 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Cc: tomi.ollila@iki.fi\r
+Subject: [PATCH] devel/emacs: add devel/try-emacs-mua.sh\r
+Date: Sun, 1 Nov 2015 17:16:25 +0200\r
+Message-Id: <1446390985-20989-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, 01 Nov 2015 15:16:36 -0000\r
+\r
+devel/try-emacs-mua.sh provides an easy way to try and experiment with\r
+the notmuch emacs client provided in emacs subdirectory of notmuch\r
+source tree.\r
+\r
+User is required to choose whether to run emacs with -q, -Q or neither\r
+-- and experienced ones may add other command line options, like\r
+'-f notmuch'.\r
+\r
+This script ensures that no .el files are newer than corresponding .elc\r
+files so that user (/developer!) does not accidentally experiment with\r
+outdated elisp files. The emacs variable to have the same effect,\r
+`load-prefer-newer' is not available until emacs 24.4.\r
+\r
+The *scratch* buffer is filled with some code user can execute before\r
+running notmuch code.\r
+---\r
+\r
+Addressed David's comments in id:87d1xdtim1.fsf@maritornes.cs.unb.ca\r
+with 2 updates:\r
+ 1) removed "address completion insinuate"\r
+ 2) added code to initialize package system when using -q or -Q\r
+\r
+ devel/try-emacs-mua.sh | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 file changed, 92 insertions(+)\r
+ create mode 100755 devel/try-emacs-mua.sh\r
+\r
+diff --git a/devel/try-emacs-mua.sh b/devel/try-emacs-mua.sh\r
+new file mode 100755\r
+index 000000000000..71be152c2346\r
+--- /dev/null\r
++++ b/devel/try-emacs-mua.sh\r
+@@ -0,0 +1,92 @@\r
++#!/bin/sh\r
++\r
++# This script provides an easy way to try and experiment with the\r
++# notmuch emacs client provided in notmuch/emacs directory.\r
++\r
++set -eu\r
++\r
++test $# -gt 0 || {\r
++ exec >&2\r
++ echo\r
++ echo "Usage: $0 '' | q | Q [other-emacs-args]"\r
++ echo\r
++ printf " $0 %s\n" "'' starts emacs without either -q or -Q option" \\r
++ "q starts emacs with -q" \\r
++ "Q starts emacs with -Q"\r
++ echo\r
++ echo Note that if there are notmuch-emacs .elc files that are older than\r
++ echo their corresponding .el files those older .elcs will be removed.\r
++ echo\r
++ exit 1\r
++}\r
++\r
++case $1 in '') opt=\r
++ ;; q | -q) opt=-q\r
++ ;; Q | -Q) opt=-Q\r
++ ;; *) echo "option '$1' not '', 'q' nor 'Q'" >&2; exit 1\r
++esac\r
++shift\r
++\r
++case $0 in\r
++ *\"*) echo "'$0' contain one or more '\"'s" >&2; exit 1 ;;\r
++ */*) d0=${0%/*} ;;\r
++ *) d0=.\r
++esac\r
++\r
++pwd=$PWD\r
++cd "$d0/.."\r
++nmd=$PWD\r
++emd=$PWD/emacs\r
++\r
++test -f "$nmd"/emacs/notmuch-lib.el || {\r
++ echo "Cannot find notmuch-emacs source directory"\r
++ exit 1\r
++}\r
++\r
++if test -x "$nmd"/notmuch\r
++then\r
++ nmin='\r
++To use accompanied notmuch binary from the same source, evaluate\r
++(setq exec-path (cons \"'"$nmd"'\" 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
++else\r
++ nmin=\r
++fi\r
++\r
++if test "$opt" = '-q' || test "$opt" = '-Q'\r
++then\r
++ pkgin='\r
++If you want to use packages (like company from elpa) evaluate\r
++(progn (require '\''package) (package-initialize))\r
++'\r
++else\r
++ pkgin=\r
++fi\r
++\r
++# ensure we don't load .elc files that are older than corresponding .el file\r
++# the emacs variable `load-prefer-newer' is not available until emacs 24.4\r
++perl -e 'use strict; use warnings;\r
++while (<*.elc>) {\r
++ my $elc = $_; s/elc$/el/;\r
++ if (-M $_ < -M $elc) {\r
++ warn "$_ is newer than $elc. Removing $elc\n";\r
++ unlink $elc or die "Failed to remove '\''$elc'\'': $!\n";\r
++ }\r
++}'\r
++\r
++cd "$pwd"\r
++\r
++# note: whitespace in $EMACS splits to command and args\r
++exec ${EMACS:-emacs} $opt -L "$emd" -l "$emd"/notmuch.el "$@" --eval '\r
++(with-current-buffer "*scratch*"\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
++'"$nmin$pkgin"'\r
++To start notmuch (hello) screen, evaluate\r
++(notmuch-hello)") (set-buffer-modified-p nil))'\r
+-- \r
+2.0.0\r
+\r