From: Dmitry Kurochkin Date: Mon, 5 Mar 2012 02:21:52 +0000 (+0400) Subject: Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=79191928d6af3d249b29cba713443188e2d46c88;p=notmuch-archives.git Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function --- diff --git a/77/fee9aee758059f3bc2f947fe62a7ddf164a845 b/77/fee9aee758059f3bc2f947fe62a7ddf164a845 new file mode 100644 index 000000000..31af3cdeb --- /dev/null +++ b/77/fee9aee758059f3bc2f947fe62a7ddf164a845 @@ -0,0 +1,122 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 4AE2E431FAF + for ; Sun, 4 Mar 2012 18:23:24 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id paNqH1081TRY for ; + Sun, 4 Mar 2012 18:23:23 -0800 (PST) +Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com + [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 58D91431FAE + for ; Sun, 4 Mar 2012 18:23:23 -0800 (PST) +Received: by bkwj4 with SMTP id j4so3177411bkw.26 + for ; Sun, 04 Mar 2012 18:23:22 -0800 (PST) +Received-SPF: pass (google.com: domain of dmitry.kurochkin@gmail.com + designates 10.205.137.15 as permitted sender) + client-ip=10.205.137.15; +Authentication-Results: mr.google.com; spf=pass (google.com: domain of + dmitry.kurochkin@gmail.com designates 10.205.137.15 as + permitted sender) smtp.mail=dmitry.kurochkin@gmail.com; + dkim=pass header.i=dmitry.kurochkin@gmail.com +Received: from mr.google.com ([10.205.137.15]) + by 10.205.137.15 with SMTP id im15mr9673084bkc.54.1330914202048 + (num_hops = 1); Sun, 04 Mar 2012 18:23:22 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=FQ9q39l5je6wROyDiS82KQs0Hzz8a3EMiwFuGy+ByWw=; + b=LvXC3hJKBKwZYQUSv90tblDsOXSG1VBewLDbTS/PffaQZxVXdSMs1LcUx4C6SngHIs + 8JkYVwXS5uiAotX/NfbAg28o3TJqlTPILlITRAA9gByBGHD0PZRZt9s8Tix2iTCROoQ3 + qnSejNVldBMGRB+xXMQFUpD1cGmlFgftX7QoUSMgX4n5G7faPuK2pLdlq8KjqGERi0FH + iJSE/aVRZQ2ykdZcU23bh8GO3GtEfhQHTrwm7YH6IICBlPQj+i6sRNw9roitWQD/NhHU + HSa1Ru8RJhg1BCHvnHuRI+SpVUKV1vneAxgArtBx5cu4kfhNdOwcp4Bl7BL7dQpFQipe + cOWQ== +Received: by 10.205.137.15 with SMTP id im15mr7652289bkc.54.1330914201950; + Sun, 04 Mar 2012 18:23:21 -0800 (PST) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id u14sm10256664bkp.2.2012.03.04.18.23.19 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 04 Mar 2012 18:23:21 -0800 (PST) +From: Dmitry Kurochkin +To: Daniel Schoepe , notmuch@notmuchmail.org +Subject: Re: [PATCH v2] emacs: Pass a copy to + notmuch-saved-search-sort-function +In-Reply-To: <1330633478-1974-2-git-send-email-daniel@schoepe.org> +References: <1330613059-5130-1-git-send-email-daniel@schoepe.org> + <1330633478-1974-1-git-send-email-daniel@schoepe.org> + <1330633478-1974-2-git-send-email-daniel@schoepe.org> +User-Agent: Notmuch/0.11.1+288~g4b3af0e (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Mon, 05 Mar 2012 06:21:52 +0400 +Message-ID: <87booblrcv.fsf@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 05 Mar 2012 02:23:24 -0000 + +On Thu, 1 Mar 2012 21:24:38 +0100, Daniel Schoepe 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@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch