From c880033e717da7bcee3272a6509101e7affd7961 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Mon, 19 May 2014 22:55:53 +0100 Subject: [PATCH] Re: [PATCH v1] emacs: `notmuch-search-find-stable-query-region' should never return an empty query. --- 46/f6f39b85508e08f575c378cc145d364007f05d | 140 ++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 46/f6f39b85508e08f575c378cc145d364007f05d diff --git a/46/f6f39b85508e08f575c378cc145d364007f05d b/46/f6f39b85508e08f575c378cc145d364007f05d new file mode 100644 index 000000000..8e1577948 --- /dev/null +++ b/46/f6f39b85508e08f575c378cc145d364007f05d @@ -0,0 +1,140 @@ +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 0F229431FAF + for ; Mon, 19 May 2014 14:56:11 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.502 +X-Spam-Level: +X-Spam-Status: No, score=0.502 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, 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 JiNI5Uvj6Xrn for ; + Mon, 19 May 2014 14:56:03 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 01830431FBC + for ; Mon, 19 May 2014 14:56:02 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1WmVXH-00026X-W4; Mon, 19 May 2014 22:55:58 +0100 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1WmVXH-0006Qk-Kd; Mon, 19 May 2014 22:55:55 +0100 +From: Mark Walters +To: David Edmondson , notmuch@notmuchmail.org +Subject: Re: [PATCH v1] emacs: `notmuch-search-find-stable-query-region' + should never return an empty query. +In-Reply-To: <1400515756-31779-1-git-send-email-dme@dme.org> +References: <1400515756-31779-1-git-send-email-dme@dme.org> +User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Mon, 19 May 2014 22:55:53 +0100 +Message-ID: <87lhtxzb4m.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 490e9304c59b23241557a095be86b02d (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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, 19 May 2014 21:56:11 -0000 + + +On Mon, 19 May 2014, David Edmondson wrote: +> `notmuch-search-find-stable-query-region' is expected to examine the +> region between `beg' and `end' to generate a query that can be used to +> include all threads in that region. If the region contains no threads, +> it should throw an error rather than generating an empty query. + +Hi + +This seems a very definite bug (when testing I managed to archive a +whole chunk of random messages!) + +However, I think I would prefer not to signal an error and just do +nothing. How about making notmuch-tag check for a nil query (and do +nothing it's nil). Then rather than an error n.s.f.s.q.r can just return +nil (this still needs to be special cased as otherwise we get "()" as +the query. + +Doing this would also fix a bug I found (when seeing what we did +elsewhere based on the above) in notmuch-tree: trying to change tags at +the end of the buffer gives an error). + +Best wishes + +Mark + + + +> --- +> +> Whilst logging calls to 'notmuch' from the UI, I noticed that it would generate +> notmuch tag -inbox -- () +> if I hit 'a' at the very end of a search buffer. That seems at least +> useless and possibly bad, so flag an error in this case instead. +> +> Oh, the first bit is just cleanup. +> +> emacs/notmuch.el | 5 ++++- +> 1 file changed, 4 insertions(+), 1 deletion(-) +> +> diff --git a/emacs/notmuch.el b/emacs/notmuch.el +> index 8aa0104..74103a6 100644 +> --- a/emacs/notmuch.el +> +++ b/emacs/notmuch.el +> @@ -429,12 +429,15 @@ matched and unmatched messages in the current thread." +> +> If ONLY-MATCHED is non-nil, include only matched messages. If it +> is nil, include both matched and unmatched messages." +> - (let ((query-list nil) (all (not only-matched))) +> + (let ((all (not only-matched)) +> + query-list) +> (dolist (queries (notmuch-search-properties-in-region :query beg end)) +> (when (first queries) +> (push (first queries) query-list)) +> (when (and all (second queries)) +> (push (second queries) query-list))) +> + (unless query-list +> + (error "No threads in region.")) +> (concat "(" (mapconcat 'identity query-list ") or (") ")"))) +> +> (defun notmuch-search-find-authors () +> -- +> 2.0.0.rc0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2