[PATCH] Have notmuch count default to showing the total.

2010-04-10 Thread Anthony Towns
On Fri, Apr 9, 2010 at 23:01, Sebastian Spaeth  wrote:
> On 2010-04-08, Mike Kelly wrote:
>> If no parameters are given to notmuch-count, or just '' or '*' are
>> given, return the total number of messages in the database.
> I know that cworth was concerned about this syntax on IRC as that would
> mean that "notmuch show" would have to spew out all your emails in order
> to remain consistent with the search term (he rather wanted to output a
> help text if no search term was given).

What's wrong with having them inconsistent in this one respect? [0]

$ notmuch count
96632
$ notmuch search
Error: notmuch search requires at least one search term.

...seems pretty logical behaviour to me?

Cheers,
aj

[0] Not much, afaics! [1]
[1] Man, what are the chances that will ever get old? [0]

-- 
Anthony Towns 


[PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Carl Worth
On Thu,  8 Apr 2010 15:39:38 -0400, Mike Kelly  wrote:
> If no parameters are given to notmuch-count, or just '' or '*' are
> given, return the total number of messages in the database.

How much syntax should count require to print all messages? [*]

I've pushed this out now, along with some followups to provide support
for all commands to accept "*" as a special case that matches all
messages.

Thanks,

-Carl

[*] id:h2x87b3a4191004091228nae33f127le9754973709de659 at mail.gmail.com [0]
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Carl Worth
On Fri, 09 Apr 2010 10:19:47 -0700, Dirk Hohndel  
wrote:
> On Fri, 09 Apr 2010 15:01:35 +0200, "Sebastian Spaeth"  SSpaeth.de> wrote:

> > 1) I often want to know how many mails are in my db. "notmuch count" or
> > "notmuch count *" is the intuitive syntax I would use for that. Right
> > now there is no way as far as I can see.
> 
> I use "notmuch count To" - not very intuitive, though.

Unfortunately, this doesn't give the desired result.

Think Shakespearean and you can get an accurate count though:

  notmuch count to be or not to be

-Carl

OK, we need a simpler search syntax than that...
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Mike Kelly
On Sat, Apr 10, 2010 at 05:28:32AM +1000, Anthony Towns wrote:
> What's wrong with having them inconsistent in this one respect?
> 
> $ notmuch count
> 96632
> $ notmuch search
> Error: notmuch search requires at least one search term.
> 
> ...seems pretty logical behaviour to me?

My thoughts exactly :)

-- 
Mike Kelly


[PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Jameson Rollins
On Sat, 10 Apr 2010 05:28:32 +1000, Anthony Towns  wrote:
> What's wrong with having them inconsistent in this one respect? [0]
> 
> $ notmuch count
> 96632
> $ notmuch search
> Error: notmuch search requires at least one search term.

This seems very logical and intuitive behavior in my opinion.  I would
*not* expect them to show help messages in these cases.  "notmuch help
foo" is much more intuitive.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



[PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Sebastian Spaeth
On 2010-04-08, Mike Kelly wrote:
> If no parameters are given to notmuch-count, or just '' or '*' are
> given, return the total number of messages in the database.

I know that cworth was concerned about this syntax on IRC as that would
mean that "notmuch show" would have to spew out all your emails in order
to remain consistent with the search term (he rather wanted to output a
help text if no search term was given).

But let me express support (It's notmuch worth, I know (haha)) for this
patch. I think it makes lots of sense:

1) I often want to know how many mails are in my db. "notmuch count" or
"notmuch count *" is the intuitive syntax I would use for that. Right
now there is no way as far as I can see.

2) Search terms filter out things. The empty search term stands
therefore for all my mails. It is consistent to have the search term ''
represent all my mail.

3) I don't expect a help text for "notmuch count" just as I don't expect
a help text for "notmuch log", we are very explicit about "notmuch help"
and "notmuch help count" in many parts of our documentation.

I'm using this and find it very handy.

Sebastian


[PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Mark Anderson
On Fri, 9 Apr 2010 14:28:32 -0500, Anthony Towns  wrote:
> [0] Not much, afaics! [1]
> [1] Man, what are the chances that will ever get old? [0]

Thanks AJ, I like it!

-Mark



[PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Dirk Hohndel
On Fri, 09 Apr 2010 15:01:35 +0200, "Sebastian Spaeth"  wrote:
> On 2010-04-08, Mike Kelly wrote:
> > If no parameters are given to notmuch-count, or just '' or '*' are
> > given, return the total number of messages in the database.
> 
> I know that cworth was concerned about this syntax on IRC as that would
> mean that "notmuch show" would have to spew out all your emails in order
> to remain consistent with the search term (he rather wanted to output a
> help text if no search term was given).
> 
> But let me express support (It's notmuch worth, I know (haha)) for this
> patch. I think it makes lots of sense:
>
> 1) I often want to know how many mails are in my db. "notmuch count" or
> "notmuch count *" is the intuitive syntax I would use for that. Right
> now there is no way as far as I can see.

I use "notmuch count To" - not very intuitive, though.

> 2) Search terms filter out things. The empty search term stands
> therefore for all my mails. It is consistent to have the search term ''
> represent all my mail.

Actually, I'd like to disagree. A search argument of '' should get you a
help text. A search argument of '*' should give you all email.

> 3) I don't expect a help text for "notmuch count" just as I don't expect
> a help text for "notmuch log", we are very explicit about "notmuch help"
> and "notmuch help count" in many parts of our documentation.

My main concern here is that once you have a gazzillion emails, typing
notmuch search with no argument over a slow link (or using it from
within a gui by mistake) could really cause a lot of unnecessary compute
/ data transfer. So I'd rather have a special character be the one that
triggers that behavior.

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center


Re: [PATCH] Have notmuch count default to showing the total.

2010-04-09 Thread Dirk Hohndel
On Fri, 09 Apr 2010 15:01:35 +0200, Sebastian Spaeth sebast...@sspaeth.de 
wrote:
 On 2010-04-08, Mike Kelly wrote:
  If no parameters are given to notmuch-count, or just '' or '*' are
  given, return the total number of messages in the database.
 
 I know that cworth was concerned about this syntax on IRC as that would
 mean that notmuch show would have to spew out all your emails in order
 to remain consistent with the search term (he rather wanted to output a
 help text if no search term was given).
 
 But let me express support (It's notmuch worth, I know (haha)) for this
 patch. I think it makes lots of sense:

 1) I often want to know how many mails are in my db. notmuch count or
 notmuch count * is the intuitive syntax I would use for that. Right
 now there is no way as far as I can see.

I use notmuch count To - not very intuitive, though.
 
 2) Search terms filter out things. The empty search term stands
 therefore for all my mails. It is consistent to have the search term ''
 represent all my mail.

Actually, I'd like to disagree. A search argument of '' should get you a
help text. A search argument of '*' should give you all email.
 
 3) I don't expect a help text for notmuch count just as I don't expect
 a help text for notmuch log, we are very explicit about notmuch help
 and notmuch help count in many parts of our documentation.

My main concern here is that once you have a gazzillion emails, typing
notmuch search with no argument over a slow link (or using it from
within a gui by mistake) could really cause a lot of unnecessary compute
/ data transfer. So I'd rather have a special character be the one that
triggers that behavior.

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Have notmuch count default to showing the total.

2010-04-08 Thread Mike Kelly
If no parameters are given to notmuch-count, or just '' or '*' are
given, return the total number of messages in the database.

update notmuch count help
---
 notmuch-count.c |5 ++---
 notmuch.c   |4 
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/notmuch-count.c b/notmuch-count.c
index 77aa433..97242ab 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -90,9 +90,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
fprintf (stderr, "Out of memory.\n");
return 1;
 }
-if (*query_str == '\0') {
-   fprintf (stderr, "Error: notmuch count requires at least one count 
term.\n");
-   return 1;
+if (*query_str == '\0' || (*query_str == '*' && *(query_str+1) == '\0')) {
+   query_str = talloc_strdup (ctx, "");
 }

 query = notmuch_query_create (notmuch, query_str);
diff --git a/notmuch.c b/notmuch.c
index f5669fc..8650951 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -220,6 +220,10 @@ command_t commands[] = {
   "\tof messages matching both a specific tag and either inbox\n"
   "\tor unread\n"
   "\n"
+  "\tIf no parameters are given, or the special search terms '' or\n"
+  "\t'*' are given, it will display the total number of messages in\n"
+  "\tthe database.\n"
+  "\n"
   "\tSee \"notmuch help search-terms\" for details of the search\n"
   "\t\tterms syntax." },
 { "reply", notmuch_reply_command,
-- 
1.7.0.4