--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1299F431FBD\r
+ for <notmuch@notmuchmail.org>; Sun, 26 Jan 2014 11:13:51 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id emC1wI773qPg for <notmuch@notmuchmail.org>;\r
+ Sun, 26 Jan 2014 11:13:46 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 57377431FBC\r
+ for <notmuch@notmuchmail.org>; Sun, 26 Jan 2014 11:13:46 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1W7V9N-0001w9-Sc; Sun, 26 Jan 2014 15:13:45 -0400\r
+Received: (nullmailer pid 24630 invoked by uid 1000); Sun, 26 Jan 2014\r
+ 19:13:42 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: add a function to heuristically test if the CLI is\r
+ configured OK.\r
+Date: Sun, 26 Jan 2014 15:13:35 -0400\r
+Message-Id: <1390763615-24477-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.5.2\r
+In-Reply-To: <1390762444-18793-1-git-send-email-david@tethera.net>\r
+References: <1390762444-18793-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 26 Jan 2014 19:13:51 -0000\r
+\r
+We cache the result so that we can call the function many places\r
+without worrying about the cost.\r
+---\r
+thanks to Tomi for catching the typos (uncommitted changes on my end).\r
+\r
+ emacs/notmuch-lib.el | 11 +++++++++++\r
+ 1 file changed, 11 insertions(+)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 2be409b..140d760 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -168,6 +168,17 @@ Otherwise the output will be returned"\r
+ (notmuch-check-exit-status status (cons notmuch-command args) output)\r
+ output)))\r
+ \r
++(defvar notmuch--cli-sane-p nil\r
++ "Cache whether the CLI seems to be configured sanely.")\r
++\r
++(defun notmuch-cli-sane-p ()\r
++ "Return t if the cli seems to be configured sanely."\r
++ (unless notmuch--cli-sane-p\r
++ (let ((status (call-process notmuch-command nil nil nil\r
++ "config" "get" "user.primary_email")))\r
++ (setq notmuch--cli-sane-p (= status 0))))\r
++ notmuch--cli-sane-p)\r
++\r
+ (defun notmuch-version ()\r
+ "Return a string with the notmuch version number."\r
+ (let ((long-string\r
+-- \r
+1.8.5.2\r
+\r