unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Return maximum of 150 results
@ 2011-08-19  3:15 James Vasile
  2011-08-19 15:00 ` Michal Sojka
  0 siblings, 1 reply; 8+ messages in thread
From: James Vasile @ 2011-08-19  3:15 UTC (permalink / raw)
  To: notmuch

Display a maximum of 150 results when searching for messages.  This
prevents client lag when searches return thousands of results you'll
never look at (use the Filter command to cut down results that exceed
150).

Number of results can be changed by setting notmuch-max-results.

This patch depends on notmuch supporting the --last-index option, a
patch for which I emailed to the list earlier this evening.
---
 emacs/notmuch.el |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2f36bbd..b928680 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1944,6 +1944,7 @@ characters as well as `_.+-'.
     (apply 'notmuch-enqueue-asynch "tag"
 	   (append action-split (list notmuch-search-query-string) nil))))
 
+(defvar notmuch-max-results 150)
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -1975,6 +1976,7 @@ The optional parameters are used as follows:
 	(let ((proc (start-process
 		     "notmuch-search" buffer
 		     notmuch-command "search"
+		     (concat "--last-index=" (number-to-string notmuch-max-results))
 		     (if oldest-first
 			 "--sort=oldest-first"
 		       "--sort=newest-first")
-- 
1.7.5.4

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

* Re: [PATCH] Return maximum of 150 results
  2011-08-19  3:15 [PATCH] Return maximum of 150 results James Vasile
@ 2011-08-19 15:00 ` Michal Sojka
  2011-08-19 15:37   ` James Vasile
  2011-08-20 19:11   ` James Vasile
  0 siblings, 2 replies; 8+ messages in thread
From: Michal Sojka @ 2011-08-19 15:00 UTC (permalink / raw)
  To: James Vasile, notmuch

Hi James,

On Fri, 19 Aug 2011, James Vasile wrote:
> Display a maximum of 150 results when searching for messages.  This
> prevents client lag when searches return thousands of results you'll
> never look at

I would not like this feature. If I search for something I really want
to see everything. For example, if I want to remove inbox from many
messages, I would search for them and press "-inbox<ret>". With your
patch I'd not be sure whether there are some more messages or not.

> (use the Filter command to cut down results that exceed 150).

You can start filtering while the previous search is still running, so I
do not see problem with having bug number of results.
> 
> Number of results can be changed by setting notmuch-max-results.

If you really want this behavior, I propose to make the default value
of notmuch-max-results infinity.

-Michal

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

* Re: [PATCH] Return maximum of 150 results
  2011-08-19 15:00 ` Michal Sojka
@ 2011-08-19 15:37   ` James Vasile
  2011-08-19 16:00     ` Michal Sojka
  2011-08-20 19:11   ` James Vasile
  1 sibling, 1 reply; 8+ messages in thread
From: James Vasile @ 2011-08-19 15:37 UTC (permalink / raw)
  To: Michal Sojka, notmuch

On Fri, 19 Aug 2011 17:00:23 +0200, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
> Hi James,
> 
> On Fri, 19 Aug 2011, James Vasile wrote:
> > Display a maximum of 150 results when searching for messages.  This
> > prevents client lag when searches return thousands of results you'll
> > never look at
> 
> I would not like this feature. If I search for something I really want
> to see everything. For example, if I want to remove inbox from many
> messages, I would search for them and press "-inbox<ret>". With your
> patch I'd not be sure whether there are some more messages or not.

Ah, I do such things from the commandline, but you are right that there
is a good use for such.

> 
> > (use the Filter command to cut down results that exceed 150).
> 
> You can start filtering while the previous search is still running, so I
> do not see problem with having bug number of results.

Yes, you can filter while the search runs, but that's not the only
problem with huge search results.  On my system, I routinely do searches
that return 15000+ messages when I'm only interested in the first
several.  When I hit Q, Emacs annoyingly asks me for permission to kill
the buffer because it has a running process.  And emacs lags as it
processes all that data.

> > 
> > Number of results can be changed by setting notmuch-max-results.
> 
> If you really want this behavior, I propose to make the default value
> of notmuch-max-results infinity.

Yes, that's probably the right answer.  I'll rework the patch to do that.

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

* Re: [PATCH] Return maximum of 150 results
  2011-08-19 15:37   ` James Vasile
@ 2011-08-19 16:00     ` Michal Sojka
  2011-08-19 16:30       ` James Vasile
  2011-08-19 18:30       ` Jameson Graef Rollins
  0 siblings, 2 replies; 8+ messages in thread
From: Michal Sojka @ 2011-08-19 16:00 UTC (permalink / raw)
  To: James Vasile, notmuch

On Fri, 19 Aug 2011, James Vasile wrote:
> On Fri, 19 Aug 2011 17:00:23 +0200, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
> > Hi James,
> > 
> > On Fri, 19 Aug 2011, James Vasile wrote:
> > > Display a maximum of 150 results when searching for messages.  This
> > > prevents client lag when searches return thousands of results you'll
> > > never look at
> > 
> > I would not like this feature. If I search for something I really want
> > to see everything. For example, if I want to remove inbox from many
> > messages, I would search for them and press "-inbox<ret>". With your
> > patch I'd not be sure whether there are some more messages or not.
> 
> Ah, I do such things from the commandline, but you are right that there
> is a good use for such.
> 
> > 
> > > (use the Filter command to cut down results that exceed 150).
> > 
> > You can start filtering while the previous search is still running, so I
> > do not see problem with having bug number of results.
> 
> Yes, you can filter while the search runs, but that's not the only
> problem with huge search results.  On my system, I routinely do searches
> that return 15000+ messages when I'm only interested in the first
> several.  When I hit Q, Emacs annoyingly asks me for permission to kill
> the buffer because it has a running process.  And emacs lags as it
> processes all that data.

Ahh, I almost forget about this. I use this patch to disable this.

-Michal

--8<---------------cut here---------------start------------->8---
From 0e0ae662026f4a17b882bb33140e0bb62e8da995 Mon Sep 17 00:00:00 2001
From: Michal Sojka <sojkam1@fel.cvut.cz>
Date: Fri, 19 Aug 2011 17:58:40 +0200
Subject: [PATCH] Do not query on notmuch-search exit

Emacs 23.2 queries by default about killing existing processes. Disable
this behavior for notmuch. I'm not sure whether this works with earlier
versions.
---
 emacs/notmuch.el |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3d82f0d..8858f3e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -858,7 +858,9 @@ The optional parameters are used as follows:
 		       "--sort=newest-first")
 		     query)))
 	  (set-process-sentinel proc 'notmuch-search-process-sentinel)
-	  (set-process-filter proc 'notmuch-search-process-filter))))
+	  (set-process-filter proc 'notmuch-search-process-filter)
+	  (set-process-query-on-exit-flag proc nil)))
+      )
     (run-hooks 'notmuch-search-hook)))
 
 (defun notmuch-search-refresh-view ()
-- 
1.7.5.4

--8<---------------cut here---------------end--------------->8---

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

* Re: [PATCH] Return maximum of 150 results
  2011-08-19 16:00     ` Michal Sojka
@ 2011-08-19 16:30       ` James Vasile
  2011-08-19 18:30       ` Jameson Graef Rollins
  1 sibling, 0 replies; 8+ messages in thread
From: James Vasile @ 2011-08-19 16:30 UTC (permalink / raw)
  To: Michal Sojka, notmuch

On Fri, 19 Aug 2011 18:00:36 +0200, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
> > On my system, I routinely do searches that return 15000+ messages
> > when I'm only interested in the first several.  When I hit Q, Emacs
> > annoyingly asks me for permission to kill the buffer because it has
> > a running process.  And emacs lags as it processes all that data.
> 
> Ahh, I almost forget about this. I use this patch to disable this.

Nice.  That's a good solution.

> 
> -Michal
> 
> --8<---------------cut here---------------start------------->8---
> >From 0e0ae662026f4a17b882bb33140e0bb62e8da995 Mon Sep 17 00:00:00 2001
> From: Michal Sojka <sojkam1@fel.cvut.cz>
> Date: Fri, 19 Aug 2011 17:58:40 +0200
> Subject: [PATCH] Do not query on notmuch-search exit
> 
> Emacs 23.2 queries by default about killing existing processes. Disable
> this behavior for notmuch. I'm not sure whether this works with earlier
> versions.
> ---
>  emacs/notmuch.el |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 3d82f0d..8858f3e 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -858,7 +858,9 @@ The optional parameters are used as follows:
>  		       "--sort=newest-first")
>  		     query)))
>  	  (set-process-sentinel proc 'notmuch-search-process-sentinel)
> -	  (set-process-filter proc 'notmuch-search-process-filter))))
> +	  (set-process-filter proc 'notmuch-search-process-filter)
> +	  (set-process-query-on-exit-flag proc nil)))
> +      )
>      (run-hooks 'notmuch-search-hook)))
>  
>  (defun notmuch-search-refresh-view ()
> -- 
> 1.7.5.4
> 
> --8<---------------cut here---------------end--------------->8---

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

* Re: [PATCH] Return maximum of 150 results
  2011-08-19 16:00     ` Michal Sojka
  2011-08-19 16:30       ` James Vasile
@ 2011-08-19 18:30       ` Jameson Graef Rollins
  1 sibling, 0 replies; 8+ messages in thread
From: Jameson Graef Rollins @ 2011-08-19 18:30 UTC (permalink / raw)
  To: Michal Sojka, James Vasile, notmuch

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

On Fri, 19 Aug 2011 18:00:36 +0200, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
> Ahh, I almost forget about this. I use this patch to disable this.

Hey, Michal.  I think this is a very useful patch.  Would you mind
forwarding a properly-formatted patch for this to the list?

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* Re: [PATCH] Return maximum of 150 results
  2011-08-19 15:00 ` Michal Sojka
  2011-08-19 15:37   ` James Vasile
@ 2011-08-20 19:11   ` James Vasile
  2011-08-22 23:46     ` Daniel Schoepe
  1 sibling, 1 reply; 8+ messages in thread
From: James Vasile @ 2011-08-20 19:11 UTC (permalink / raw)
  To: Michal Sojka, notmuch

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

On Fri, 19 Aug 2011 17:00:23 +0200, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
> If you really want this behavior, I propose to make the default value
> of notmuch-max-results infinity.

I'm attaching a revised patch that does as you suggest.  Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Limit-number-of-threads-returned-by-search-in-emacs.patch --]
[-- Type: text/x-diff, Size: 1508 bytes --]

From d0421e4308473347b31f5537eaec93b137084060 Mon Sep 17 00:00:00 2001
From: James Vasile <james@hackervisions.org>
Date: Sat, 20 Aug 2011 14:58:47 -0400
Subject: [PATCH] Limit number of threads returned by search in emacs

Set notmuch-max-results to the maximum number of results the
client should show.  Setting notmuch-max-results to 0 (the
default) does not limit search results (i.e. limits them to
infinity).

This patch requries your version of notmuch to implement the
--last-index parameter.  A patch to implement this parameter was
posted to the notmuch mailing list as
id:8739gyw0zh.fsf@opensourcematters.org.
---
 emacs/notmuch.el |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f11ec24..887d696 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -882,6 +882,7 @@ characters as well as `_.+-'.
 	   (concat "*notmuch-search-" query "*"))
 	  )))
 
+(defvar notmuch-max-results 0)
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -913,6 +914,9 @@ The optional parameters are used as follows:
 	(let ((proc (start-process
 		     "notmuch-search" buffer
 		     notmuch-command "search"
+		     (if (> notmuch-max-results 0)
+			 (format "--last-index=%d" notmuch-max-results)
+			 "")
 		     (if oldest-first
 			 "--sort=oldest-first"
 		       "--sort=newest-first")
-- 
1.7.5.4


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

* Re: [PATCH] Return maximum of 150 results
  2011-08-20 19:11   ` James Vasile
@ 2011-08-22 23:46     ` Daniel Schoepe
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Schoepe @ 2011-08-22 23:46 UTC (permalink / raw)
  To: James Vasile, Michal Sojka, notmuch

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

On Sat, 20 Aug 2011 15:11:00 -0400, James Vasile <james@hackervisions.org> wrote:
> On Fri, 19 Aug 2011 17:00:23 +0200, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
> > If you really want this behavior, I propose to make the default value
> > of notmuch-max-results infinity.
> 
> I'm attaching a revised patch that does as you suggest.  Thanks.

I think this is a nice feature.

> +(defvar notmuch-max-results 0)

This should probably be a defcustom and it also needs a docstring
(saying, along with a general description, that 0 means "show all
messages"). Changing it so that nil means all messages might be a bit
nicer (since nil says "no maximum number of results" more clearly, I
think) though, but that's probably just me nitpicking.

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

end of thread, other threads:[~2011-08-22 23:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-19  3:15 [PATCH] Return maximum of 150 results James Vasile
2011-08-19 15:00 ` Michal Sojka
2011-08-19 15:37   ` James Vasile
2011-08-19 16:00     ` Michal Sojka
2011-08-19 16:30       ` James Vasile
2011-08-19 18:30       ` Jameson Graef Rollins
2011-08-20 19:11   ` James Vasile
2011-08-22 23:46     ` Daniel Schoepe

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