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