[PATCH] Added --initial-index and --last-index to search/show

2011-08-20 Thread Patrick Totzke


Hi!
A very good idea indeed! This could become quite handy speeding up my interface.
One question: What do you (intend to) do to ensure that accumulated results
'add up well'? 
Consider the following: you query some 10 threads, the user tags one of them
so that it doesn't macht anymore and afterwards you list the next 100 threads.
After the tagging, the number of hits decreases, so if you query
from hit number 101 to 200, you will not return the 100th (now 99th) thread at 
all.

Ok, one could always list all threads up to the one one is interested in but 
that
would make refreshing the list slower and slower when you keep scrolling down..
best,
/p


[PATCH] Added --initial-index and --last-index to search/show

2011-08-20 Thread James Vasile
On Sat, 20 Aug 2011 12:21:26 +0100, Patrick Totzke  wrote:
Non-text part: multipart/mixed
> 
> 
> Hi!
> A very good idea indeed! This could become quite handy speeding up my 
> interface.
> One question: What do you (intend to) do to ensure that accumulated results
> 'add up well'? 

I intend to do nothing.  It's up to the interface to handle this, if it
needs handling at all.

> Consider the following: you query some 10 threads, the user tags one of them
> so that it doesn't macht anymore and afterwards you list the next 100 threads.
> After the tagging, the number of hits decreases, so if you query
> from hit number 101 to 200, you will not return the 100th (now 99th)
> thread at all.

The interface could keep track of threads deleted/untagged and adjust
accordingly.

Or I suppose one could also implement --initial-msgid, --last-msgid,
--num-threads, etc.  Set --initial-msgid to the last message in your
current view.  Set --num-threads to 100.  That should do it.

> 
> Ok, one could always list all threads up to the one one is interested in but 
> that
> would make refreshing the list slower and slower when you keep
> scrolling down..

Personally, I think users should be discouraged from scrolling and
scrolling.  Notmuch is a *search* tool.  If the mail you want isn't in
the first page or so, you're using the tool wrong.  

-J


Re: [PATCH] Added --initial-index and --last-index to search/show

2011-08-20 Thread James Vasile
On Sat, 20 Aug 2011 12:21:26 +0100, Patrick Totzke 
 wrote:
Non-text part: multipart/mixed
> 
> 
> Hi!
> A very good idea indeed! This could become quite handy speeding up my 
> interface.
> One question: What do you (intend to) do to ensure that accumulated results
> 'add up well'? 

I intend to do nothing.  It's up to the interface to handle this, if it
needs handling at all.

> Consider the following: you query some 10 threads, the user tags one of them
> so that it doesn't macht anymore and afterwards you list the next 100 threads.
> After the tagging, the number of hits decreases, so if you query
> from hit number 101 to 200, you will not return the 100th (now 99th)
> thread at all.

The interface could keep track of threads deleted/untagged and adjust
accordingly.

Or I suppose one could also implement --initial-msgid, --last-msgid,
--num-threads, etc.  Set --initial-msgid to the last message in your
current view.  Set --num-threads to 100.  That should do it.

> 
> Ok, one could always list all threads up to the one one is interested in but 
> that
> would make refreshing the list slower and slower when you keep
> scrolling down..

Personally, I think users should be discouraged from scrolling and
scrolling.  Notmuch is a *search* tool.  If the mail you want isn't in
the first page or so, you're using the tool wrong.  

-J
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Added --initial-index and --last-index to search/show

2011-08-20 Thread Patrick Totzke


Hi!
A very good idea indeed! This could become quite handy speeding up my interface.
One question: What do you (intend to) do to ensure that accumulated results
'add up well'? 
Consider the following: you query some 10 threads, the user tags one of them
so that it doesn't macht anymore and afterwards you list the next 100 threads.
After the tagging, the number of hits decreases, so if you query
from hit number 101 to 200, you will not return the 100th (now 99th) thread at 
all.

Ok, one could always list all threads up to the one one is interested in but 
that
would make refreshing the list slower and slower when you keep scrolling down..
best,
/p
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Added --initial-index and --last-index to search/show

2011-08-19 Thread James Vasile
On Fri, 19 Aug 2011 11:55:11 -0700, Jameson Graef Rollins  wrote:
Non-text part: multipart/signed
> On Thu, 18 Aug 2011 23:09:54 -0400, James Vasile  
> wrote:
> > This patch implements --initial-index and --last-index as options to
> > search and show.  It lets you select the xth through the yth message
> > and receive results that pertain only to those messages.
> 
> Hi, James.  Thanks for working on this feature.  I don't have time to
> review this at the moment, but I just wanted to mention that the idea
> behind this feature has come up in the past as a way to significantly
> increase usability and performance of the VIM interface.  Since VIM does
> not support asynchronous file loading, this feature could be used to
> efficiently process large search results by only loading one page of
> results at a time.  I highly recommend that the VIM interface developers
> take this and run with it.  I'm sure this could be used to actually get
> the VIM interface over the hump to being fully functional.

As a former vim user, this makes me quite happy.  Thanks!



Re: [PATCH] Added --initial-index and --last-index to search/show

2011-08-19 Thread James Vasile
On Fri, 19 Aug 2011 11:55:11 -0700, Jameson Graef Rollins 
 wrote:
Non-text part: multipart/signed
> On Thu, 18 Aug 2011 23:09:54 -0400, James Vasile  
> wrote:
> > This patch implements --initial-index and --last-index as options to
> > search and show.  It lets you select the xth through the yth message
> > and receive results that pertain only to those messages.
> 
> Hi, James.  Thanks for working on this feature.  I don't have time to
> review this at the moment, but I just wanted to mention that the idea
> behind this feature has come up in the past as a way to significantly
> increase usability and performance of the VIM interface.  Since VIM does
> not support asynchronous file loading, this feature could be used to
> efficiently process large search results by only loading one page of
> results at a time.  I highly recommend that the VIM interface developers
> take this and run with it.  I'm sure this could be used to actually get
> the VIM interface over the hump to being fully functional.

As a former vim user, this makes me quite happy.  Thanks!

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Added --initial-index and --last-index to search/show

2011-08-19 Thread Jameson Graef Rollins
On Thu, 18 Aug 2011 23:09:54 -0400, James Vasile  
wrote:
> This patch implements --initial-index and --last-index as options to
> search and show.  It lets you select the xth through the yth message
> and receive results that pertain only to those messages.

Hi, James.  Thanks for working on this feature.  I don't have time to
review this at the moment, but I just wanted to mention that the idea
behind this feature has come up in the past as a way to significantly
increase usability and performance of the VIM interface.  Since VIM does
not support asynchronous file loading, this feature could be used to
efficiently process large search results by only loading one page of
results at a time.  I highly recommend that the VIM interface developers
take this and run with it.  I'm sure this could be used to actually get
the VIM interface over the hump to being fully functional.

jamie.


pgpjXIeHRx9Qb.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Added --initial-index and --last-index to search/show

2011-08-19 Thread Jameson Graef Rollins
On Thu, 18 Aug 2011 23:09:54 -0400, James Vasile  
wrote:
> This patch implements --initial-index and --last-index as options to
> search and show.  It lets you select the xth through the yth message
> and receive results that pertain only to those messages.

Hi, James.  Thanks for working on this feature.  I don't have time to
review this at the moment, but I just wanted to mention that the idea
behind this feature has come up in the past as a way to significantly
increase usability and performance of the VIM interface.  Since VIM does
not support asynchronous file loading, this feature could be used to
efficiently process large search results by only loading one page of
results at a time.  I highly recommend that the VIM interface developers
take this and run with it.  I'm sure this could be used to actually get
the VIM interface over the hump to being fully functional.

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



[PATCH] Added --initial-index and --last-index to search/show

2011-08-18 Thread James Vasile
Sometimes you need to ask notmuch for just a few messages, and notmuch
supports that with date range options.  Date ranges, however, are not
sufficient for an application that is paging and just wants message x
through y, then x+d through y+d, etc.  And if you're sending the json
results of a search to a client for rendering, it makes sense to just
send the small ranges the client actually wants.

This patch implements --initial-index and --last-index as options to
search and show.  It lets you select the xth through the yth message
and receive results that pertain only to those messages.

I did not enable this option for results specifying --output=tags
since the output of a tag search isn't much data.
---
 notmuch-search.c |   48 ++--
 notmuch-show.c   |   30 ++
 notmuch.1|   32 
 notmuch.c|   18 +-
 4 files changed, 117 insertions(+), 11 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index faccaf7..f7deb4a 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -194,7 +194,9 @@ static int
 do_search_threads (const search_format_t *format,
   notmuch_query_t *query,
   notmuch_sort_t sort,
-  output_t output)
+  output_t output,
+  int initial_thread,
+  int last_thread)
 {
 notmuch_thread_t *thread;
 notmuch_threads_t *threads;
@@ -208,8 +210,15 @@ do_search_threads (const search_format_t *format,

 fputs (format->results_start, stdout);

+last_thread -= initial_thread;
+
+for (;
+initial_thread > 0 && notmuch_threads_valid (threads);
+notmuch_threads_move_to_next (threads))
+   initial_thread--;
+
 for (;
-notmuch_threads_valid (threads);
+last_thread != 0 && notmuch_threads_valid (threads);
 notmuch_threads_move_to_next (threads))
 {
int first_tag = 1;
@@ -258,6 +267,7 @@ do_search_threads (const search_format_t *format,
first_thread = 0;

notmuch_thread_destroy (thread);
+   last_thread--;
 }

 if (first_thread)
@@ -271,7 +281,9 @@ do_search_threads (const search_format_t *format,
 static int
 do_search_messages (const search_format_t *format,
notmuch_query_t *query,
-   output_t output)
+   output_t output,
+   int initial_message,
+   int last_message)
 {
 notmuch_message_t *message;
 notmuch_messages_t *messages;
@@ -284,8 +296,15 @@ do_search_messages (const search_format_t *format,

 fputs (format->results_start, stdout);

+last_message -= initial_message;
+
+for (;
+initial_message > 0 && notmuch_messages_valid (messages);   
+notmuch_messages_move_to_next (messages))
+   initial_message--;
+
 for (;
-notmuch_messages_valid (messages);
+last_message != 0 && notmuch_messages_valid (messages); 
 notmuch_messages_move_to_next (messages))
 {
message = notmuch_messages_get (messages);
@@ -318,6 +337,7 @@ do_search_messages (const search_format_t *format,
}

notmuch_message_destroy (message);
+   last_message--;
 }

 notmuch_messages_destroy (messages);
@@ -394,6 +414,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 const search_format_t *format = &format_text;
 int i, ret;
 output_t output = OUTPUT_SUMMARY;
+int initial_index = 0;
+int last_index = -1;

 for (i = 0; i < argc && argv[i][0] == '-'; i++) {
if (strcmp (argv[i], "--") == 0) {
@@ -420,6 +442,16 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
fprintf (stderr, "Invalid value for --format: %s\n", opt);
return 1;
}
+   } else if (STRNCMP_LITERAL (argv[i], "--last-index=") == 0) {
+   opt = argv[i] + sizeof ("--last-index=") - 1;
+   last_index = atoi(opt);
+   if (last_index == 0) {
+   fprintf (stderr, "Last index set to 0.\n");
+   return 1;
+   }
+   } else if (STRNCMP_LITERAL (argv[i], "--initial-index=") == 0) {
+   opt = argv[i] + sizeof ("--initial-index=") - 1;
+   initial_index = atoi(opt);
} else if (STRNCMP_LITERAL (argv[i], "--output=") == 0) {
opt = argv[i] + sizeof ("--output=") - 1;
if (strcmp (opt, "summary") == 0) {
@@ -476,13 +508,17 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 default:
 case OUTPUT_SUMMARY:
 case OUTPUT_THREADS:
-   ret = do_search_threads (format, query, sort, output);
+   ret = do_search_threads (format, query, sort, output, initial_index, 
last_index);
break;
 case OUTPUT_MESSAGES:
 case OUTPUT_FILES:
-   ret = do_search_messages (format, query, output);
+   ret = do_search_messag

[PATCH] Added --initial-index and --last-index to search/show

2011-08-18 Thread James Vasile
Sometimes you need to ask notmuch for just a few messages, and notmuch
supports that with date range options.  Date ranges, however, are not
sufficient for an application that is paging and just wants message x
through y, then x+d through y+d, etc.  And if you're sending the json
results of a search to a client for rendering, it makes sense to just
send the small ranges the client actually wants.

This patch implements --initial-index and --last-index as options to
search and show.  It lets you select the xth through the yth message
and receive results that pertain only to those messages.

I did not enable this option for results specifying --output=tags
since the output of a tag search isn't much data.
---
 notmuch-search.c |   48 ++--
 notmuch-show.c   |   30 ++
 notmuch.1|   32 
 notmuch.c|   18 +-
 4 files changed, 117 insertions(+), 11 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index faccaf7..f7deb4a 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -194,7 +194,9 @@ static int
 do_search_threads (const search_format_t *format,
   notmuch_query_t *query,
   notmuch_sort_t sort,
-  output_t output)
+  output_t output,
+  int initial_thread,
+  int last_thread)
 {
 notmuch_thread_t *thread;
 notmuch_threads_t *threads;
@@ -208,8 +210,15 @@ do_search_threads (const search_format_t *format,
 
 fputs (format->results_start, stdout);
 
+last_thread -= initial_thread;
+
+for (;
+initial_thread > 0 && notmuch_threads_valid (threads);
+notmuch_threads_move_to_next (threads))
+   initial_thread--;
+
 for (;
-notmuch_threads_valid (threads);
+last_thread != 0 && notmuch_threads_valid (threads);
 notmuch_threads_move_to_next (threads))
 {
int first_tag = 1;
@@ -258,6 +267,7 @@ do_search_threads (const search_format_t *format,
first_thread = 0;
 
notmuch_thread_destroy (thread);
+   last_thread--;
 }
 
 if (first_thread)
@@ -271,7 +281,9 @@ do_search_threads (const search_format_t *format,
 static int
 do_search_messages (const search_format_t *format,
notmuch_query_t *query,
-   output_t output)
+   output_t output,
+   int initial_message,
+   int last_message)
 {
 notmuch_message_t *message;
 notmuch_messages_t *messages;
@@ -284,8 +296,15 @@ do_search_messages (const search_format_t *format,
 
 fputs (format->results_start, stdout);
 
+last_message -= initial_message;
+
+for (;
+initial_message > 0 && notmuch_messages_valid (messages);   
+notmuch_messages_move_to_next (messages))
+   initial_message--;
+
 for (;
-notmuch_messages_valid (messages);
+last_message != 0 && notmuch_messages_valid (messages); 
 notmuch_messages_move_to_next (messages))
 {
message = notmuch_messages_get (messages);
@@ -318,6 +337,7 @@ do_search_messages (const search_format_t *format,
}
 
notmuch_message_destroy (message);
+   last_message--;
 }
 
 notmuch_messages_destroy (messages);
@@ -394,6 +414,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 const search_format_t *format = &format_text;
 int i, ret;
 output_t output = OUTPUT_SUMMARY;
+int initial_index = 0;
+int last_index = -1;
 
 for (i = 0; i < argc && argv[i][0] == '-'; i++) {
if (strcmp (argv[i], "--") == 0) {
@@ -420,6 +442,16 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
fprintf (stderr, "Invalid value for --format: %s\n", opt);
return 1;
}
+   } else if (STRNCMP_LITERAL (argv[i], "--last-index=") == 0) {
+   opt = argv[i] + sizeof ("--last-index=") - 1;
+   last_index = atoi(opt);
+   if (last_index == 0) {
+   fprintf (stderr, "Last index set to 0.\n");
+   return 1;
+   }
+   } else if (STRNCMP_LITERAL (argv[i], "--initial-index=") == 0) {
+   opt = argv[i] + sizeof ("--initial-index=") - 1;
+   initial_index = atoi(opt);
} else if (STRNCMP_LITERAL (argv[i], "--output=") == 0) {
opt = argv[i] + sizeof ("--output=") - 1;
if (strcmp (opt, "summary") == 0) {
@@ -476,13 +508,17 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 default:
 case OUTPUT_SUMMARY:
 case OUTPUT_THREADS:
-   ret = do_search_threads (format, query, sort, output);
+   ret = do_search_threads (format, query, sort, output, initial_index, 
last_index);
break;
 case OUTPUT_MESSAGES:
 case OUTPUT_FILES:
-   ret = do_search_messages (format, query, output);
+   ret = do_sear