]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-lib.el
emacs: add a function to heuristically test if the CLI is configured OK.
[notmuch] / emacs / notmuch-lib.el
index 2be409b39a1abe1fee91b514ce9f96347eb15644..140d7603ce2d191613911ac4e7e96bbdd0685a0c 100644 (file)
@@ -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