unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* notmuch emacs mode could be friendlier when the user has never run "notmuch setup"
@ 2013-09-05 14:43 Daniel Kahn Gillmor
  2014-01-26 18:54 ` [PATCH 1/3] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
  2014-01-27 13:11 ` notmuch emacs mode could be friendlier when the user has never run "notmuch setup" David Bremner
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Kahn Gillmor @ 2013-09-05 14:43 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

in testing out notmuch on a new user account, i just noticed that
bringing up notmuch mode in emacs chokes with an unhelpful error for
users who have never run "notmuch setup".  it seems like there ought to
be a way for the emacs mode to detect this error state and prompt the
user to walk through "notmuch setup" directly from within emacs.

my emacs-fu (and my time) is too limited for me to try to implement this
bit of user-friendliness, but i just wanted to put the idea out there
for folks who might want to take it on as a well-scoped project.

At the very least, the error message could say "please run 'notmuch
setup' from a shell".

The current behavior (notmuch and notmuch-emacs 0.16-1 on debian) is to
open a *notmuch-hello* buffer that says :

  Welcome to notmuch. You have

And in the minibuffer, a message says "notmuch exited with status 1"

*Messages* shows:

process-lines: notmuch exited with status 1

	--dkg


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 1027 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] emacs: add a function to heuristically test if the CLI is configured OK.
  2013-09-05 14:43 notmuch emacs mode could be friendlier when the user has never run "notmuch setup" Daniel Kahn Gillmor
@ 2014-01-26 18:54 ` David Bremner
  2014-01-26 18:54   ` [PATCH 2/3] emacs: add function notmuch-assert-cli-sane David Bremner
                     ` (2 more replies)
  2014-01-27 13:11 ` notmuch emacs mode could be friendlier when the user has never run "notmuch setup" David Bremner
  1 sibling, 3 replies; 8+ messages in thread
From: David Bremner @ 2014-01-26 18:54 UTC (permalink / raw)
  To: notmuch

We cache the result so that we can call the function many places
without worrying about the cost.
---
 emacs/notmuch-lib.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2be409b..dcdfbdc 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-setup-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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] emacs: add function notmuch-assert-cli-sane
  2014-01-26 18:54 ` [PATCH 1/3] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
@ 2014-01-26 18:54   ` David Bremner
  2014-01-26 18:54   ` [PATCH 3/3] emacs: add notmuch-assert-cli-sane to notmuch-hello David Bremner
  2014-01-26 19:13   ` [PATCH] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
  2 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2014-01-26 18:54 UTC (permalink / raw)
  To: notmuch

If the CLI seems borked, signal an error, and log a suggestion for the
user about how to recover.
---
 emacs/notmuch-lib.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index dcdfbdc..c195652 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -179,6 +179,13 @@ Otherwise the output will be returned"
       (setq notmuch--cli-setup-p (= status 0))))
   notmuch--cli-sane-p)
 
+(defun notmuch-assert-cli-sane ()
+  (unless (notmuch-cli-sane-p)
+    (notmuch-logged-error
+     "notmuch cli seems misconfigured or unconfigured."
+"Perhaps you haven't run \"notmuch setup\" yet? Try running this
+on the command line, and then retry your notmuch command")))
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] emacs: add notmuch-assert-cli-sane to notmuch-hello
  2014-01-26 18:54 ` [PATCH 1/3] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
  2014-01-26 18:54   ` [PATCH 2/3] emacs: add function notmuch-assert-cli-sane David Bremner
@ 2014-01-26 18:54   ` David Bremner
  2014-01-26 19:13   ` [PATCH] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
  2 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2014-01-26 18:54 UTC (permalink / raw)
  To: notmuch

This is meant to be the friendly entrypoint, so let's do something
better than the mangled output described in

       id:5228989D.8030607@fifthhorseman.net
---
 emacs/notmuch-hello.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 55c416a..7b3d76b 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -788,6 +788,7 @@ following:
   "Run notmuch and display saved searches, known tags, etc."
   (interactive)
 
+  (notmuch-assert-cli-sane)
   ;; This may cause a window configuration change, so if the
   ;; auto-refresh hook is already installed, avoid recursive refresh.
   (let ((notmuch-hello-auto-refresh nil))
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] emacs: add a function to heuristically test if the CLI is configured OK.
  2014-01-26 18:54 ` [PATCH 1/3] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
  2014-01-26 18:54   ` [PATCH 2/3] emacs: add function notmuch-assert-cli-sane David Bremner
  2014-01-26 18:54   ` [PATCH 3/3] emacs: add notmuch-assert-cli-sane to notmuch-hello David Bremner
@ 2014-01-26 19:13   ` David Bremner
  2014-01-26 19:41     ` Mark Walters
  2014-01-26 19:54     ` Tomi Ollila
  2 siblings, 2 replies; 8+ messages in thread
From: David Bremner @ 2014-01-26 19:13 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] emacs: add a function to heuristically test if the CLI is configured OK.
  2014-01-26 19:13   ` [PATCH] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
@ 2014-01-26 19:41     ` Mark Walters
  2014-01-26 19:54     ` Tomi Ollila
  1 sibling, 0 replies; 8+ messages in thread
From: Mark Walters @ 2014-01-26 19:41 UTC (permalink / raw)
  To: David Bremner, notmuch


This version LGTM +1.

(Just for the record there was some discussion on irc about switching to
the *notmuch errors* buffer but that is more complex and fragile so
let's go with this simple and effective solution.)

Best wishes

Mark


On Sun, 26 Jan 2014, David Bremner <david@tethera.net> wrote:
> 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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] emacs: add a function to heuristically test if the CLI is configured OK.
  2014-01-26 19:13   ` [PATCH] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
  2014-01-26 19:41     ` Mark Walters
@ 2014-01-26 19:54     ` Tomi Ollila
  1 sibling, 0 replies; 8+ messages in thread
From: Tomi Ollila @ 2014-01-26 19:54 UTC (permalink / raw)
  To: David Bremner, notmuch

On Sun, Jan 26 2014, David Bremner <david@tethera.net> wrote:

> 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).

Series LGTM.

Tomi

>
>  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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: notmuch emacs mode could be friendlier when the user has never run "notmuch setup"
  2013-09-05 14:43 notmuch emacs mode could be friendlier when the user has never run "notmuch setup" Daniel Kahn Gillmor
  2014-01-26 18:54 ` [PATCH 1/3] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
@ 2014-01-27 13:11 ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: David Bremner @ 2014-01-27 13:11 UTC (permalink / raw)
  To: Daniel Kahn Gillmor, notmuch

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:


> At the very least, the error message could say "please run 'notmuch
> setup' from a shell".

This is implimented in git commit 1c2f2c960c (with the patch series in
this thread), and will be part of notmuch 0.18.  So far I only added the
assert to notmuch-hello (also known as M-x notmuch), but it would be
easy to add to other entry-points if people think it's a good idea.

>
> The current behavior (notmuch and notmuch-emacs 0.16-1 on debian) is to
> open a *notmuch-hello* buffer that says :
>
>   Welcome to notmuch. You have
>
> And in the minibuffer, a message says "notmuch exited with status 1"
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-27 13:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-05 14:43 notmuch emacs mode could be friendlier when the user has never run "notmuch setup" Daniel Kahn Gillmor
2014-01-26 18:54 ` [PATCH 1/3] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
2014-01-26 18:54   ` [PATCH 2/3] emacs: add function notmuch-assert-cli-sane David Bremner
2014-01-26 18:54   ` [PATCH 3/3] emacs: add notmuch-assert-cli-sane to notmuch-hello David Bremner
2014-01-26 19:13   ` [PATCH] emacs: add a function to heuristically test if the CLI is configured OK David Bremner
2014-01-26 19:41     ` Mark Walters
2014-01-26 19:54     ` Tomi Ollila
2014-01-27 13:11 ` notmuch emacs mode could be friendlier when the user has never run "notmuch setup" David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).