[PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Sun Mar 4 18:21:52 PST 2012


On Thu,  1 Mar 2012 21:24:38 +0100, Daniel Schoepe <daniel at schoepe.org> wrote:
> notmuch-saved-search-sort-function might destructively modify its
> input (`sort' does that, for instance), so it should not be given
> notmuch-saved-searches directly.
> ---

-1

I think we should require `notmuch-saved-search-sort-function' not to
have side effects.  Current documentation should be more clear about
this.  We need to fix `notmuch-sort-saved-searches' to copy the list
before calling `sort'.  But we should not do it in
`notmuch-hello-insert-saved-searches' for any sorting function (which
may not need this copying).

Regards,
  Dmitry

>  emacs/notmuch-hello.el |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index aad373d..e089290 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -575,7 +575,10 @@ Complete list of currently available key bindings:
>    (let ((searches (notmuch-hello-query-counts
>  		   (if notmuch-saved-search-sort-function
>  		       (funcall notmuch-saved-search-sort-function
> -				notmuch-saved-searches)
> +				;; Use a copy, since the sorting
> +				;; function may have side effects,
> +				;; e.g. if it just `sort's the input.
> +				(copy-sequence notmuch-saved-searches))
>  		     notmuch-saved-searches)
>  		   :show-empty-searches notmuch-show-empty-saved-searches))
>  	found-target-pos)
> -- 
> 1.7.9.1
> 
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list