[RFC PATCH 3/3] emacs: support limiting the number of messages shown in search results

Daniel Schoepe daniel at schoepe.org
Sat Oct 29 10:25:22 PDT 2011


On Fri, 28 Oct 2011 23:59:31 +0300, Jani Nikula <jani at nikula.org> wrote:
> Add support for limiting the maximum number of messages initially displayed
> in search results. When enabled, the search results will contain push
> buttons to double the number of messages displayed or to show unlimited
> messages.

Nice patch, as it not only makes searches with a lot of results easier
to use on slower machines/hard drives, but I also find that seeing only
a few dozen threads in the buffer looks more "orderly" to me, compared
to a buffer with hundreds of lines.

A few comments about the code:

> @@ -373,6 +381,7 @@ Complete list of currently available key bindings:
>    (make-local-variable 'notmuch-search-oldest-first)
>    (make-local-variable 'notmuch-search-target-thread)
>    (make-local-variable 'notmuch-search-target-line)
> +  (make-local-variable 'notmuch-search-maxitems)
>    (set (make-local-variable 'notmuch-search-continuation) nil)
>    (set (make-local-variable 'scroll-preserve-screen-position) t)
>    (add-to-invisibility-spec 'notmuch-search)
> @@ -633,6 +642,8 @@ This function advances the next thread when finished."
>  			(insert "End of search results.")
>  			(if (not (= exit-status 0))
>  			    (insert (format " (process returned %d)" exit-status)))
> +			(if notmuch-search-maxitems
> +			    (notmuch-search-setup-buttons))

As discussed on IRC, this causes `notmuch-search' to fail if the
maxitems argument is nil.

> +(defun notmuch-search-setup-buttons ()
> +  (widget-insert "    ")
> +  (widget-create 'push-button
> +		 :notify (lambda (&rest ignore)
> +			   (set 'notmuch-search-maxitems
> +				(* 2 notmuch-search-maxitems))
> +			   (notmuch-search-refresh-view))
> +		 :help-echo "Double the number of messages shown"
> +		 "Show 2X messages")
> +  (widget-insert "    ")
> +  (widget-create 'push-button
> +		 :notify (lambda (&rest ignore)
> +			   (set 'notmuch-search-maxitems 0)
> +			   (notmuch-search-refresh-view))
> +		 :help-echo "Show all search results"
> +		 "Show unlimited messages")
> +  (widget-setup))

I think these notify-actions should be separate functions to make it
easier to bind them to keys.

> +
>  (defcustom notmuch-poll-script ""
>    "An external script to incorporate new mail into the notmuch database.
>  
> @@ -997,7 +1030,7 @@ current search results AND the additional query string provided."
>  			 query)))
>      (notmuch-search (if (string= notmuch-search-query-string "*")
>  			grouped-query
> -		      (concat notmuch-search-query-string " and " grouped-query)) notmuch-search-oldest-first)))
> +		      (concat notmuch-search-query-string " and "
>  			 grouped-query)) notmuch-search-oldest-first
>  			 notmuch-search-maxitems)))

This causes notmuch-search-filter to fail (repeatedly), since `notmuch-search'
expects a TARGET-THREAD (or nil) as its third parameter, but is given
`notmuch-search-maxitems' instead.

>  
>  (defun notmuch-search-filter-by-tag (tag)
>    "Filter the current search results based on a single tag.
> @@ -1006,7 +1039,7 @@ Runs a new search matching only messages that match both the
>  current search results AND that are tagged with the given tag."
>    (interactive
>     (list (notmuch-select-tag-with-completion "Filter by tag: ")))
> -  (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first))
> +  (notmuch-search (concat notmuch-search-query-string " and tag:"
>    tag) notmuch-search-oldest-first notmuch-search-maxitems))

Same here.

Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20111029/fb564033/attachment.pgp>


More information about the notmuch mailing list