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 60A28431FC0 for ; Tue, 20 May 2014 04:22:07 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 HrKPNm774EmW for ; Tue, 20 May 2014 04:22:01 -0700 (PDT) Received: from mail-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id F2417431FBC for ; Tue, 20 May 2014 04:22:00 -0700 (PDT) Received: by mail-we0-f172.google.com with SMTP id k48so354251wev.3 for ; Tue, 20 May 2014 04:21:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:in-reply-to:references:user-agent :from:date:message-id:mime-version:content-type; bh=i0FMV2f+LNfXUALeZAVfhA/t/dSBQudtOYiu2o3TFqU=; b=KSoDpRKUq9oCDWAJ7yK08WDfi1+18kQwoozsUHnGGydHM8QTxImlJ62bWLJ/CUwReQ nVsdT0cujRS1RP0dGs9oESbvpjwkDU8XrHESmgC7JPGHyOUa+Lb9W8SVQjmuaqGy29kE CeKDlt3lMM7Uoy6Ee7F3HzTiyf//EVT7ILnsrcPQgLZQn87JtG31y+iZsGhD9BP7TFjg It6Ld3ybUkJT/qWKsmXYfgMwW1axkwoXTgi/YTsbBPhWPnmwFA1WJjIr1RE92SigF9L9 mlUF9Num/QKhQSfkRdvOybxHNTHvdaKkZ6B/A+z7fmbtUTF6ZXJaQL8Sg3X3qDTwZiBN 4T3Q== X-Gm-Message-State: ALoCoQmGHYN8bOP107MfbtXHscRkhBPZv4a/QG+xa6aWgpNsjvu5MFix4KHGFxHqoRLd3xSSNSoS X-Received: by 10.180.228.7 with SMTP id se7mr3510402wic.2.1400584917435; Tue, 20 May 2014 04:21:57 -0700 (PDT) Received: from localhost ([2a01:348:1a2:1:a288:b4ff:fe8a:77d8]) by mx.google.com with ESMTPSA id ph8sm17971114wjb.32.2014.05.20.04.21.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 May 2014 04:21:56 -0700 (PDT) To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH v1] emacs: `notmuch-search-find-stable-query-region' should never return an empty query. In-Reply-To: <87lhtxzb4m.fsf@qmul.ac.uk> References: <1400515756-31779-1-git-send-email-dme@dme.org> <87lhtxzb4m.fsf@qmul.ac.uk> User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) From: David Edmondson Date: Tue, 20 May 2014 12:21:49 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" 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: Tue, 20 May 2014 11:22:07 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, May 19 2014, Mark Walters wrote: > 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!)=20 Do you understand why? I couldn't see a path from this problem to that failure mode. > 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. Looking around for similar issues (like `notmuch-show-get-message-properties'), it seems that we would have to add checks in a lot of places for functions such as this returning `nil' when they cannot find some state or context. Throwing an error makes it clear to the user that nothing is going to happen - it's not just silent failure. (If it's not clear - that was all "I like that it calls `error' :-). > 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 g= enerate >> 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 thre= ad." >>=20=20 >> 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 en= d)) >> (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 (") ")"))) >>=20=20 >> (defun notmuch-search-find-authors () >> --=20 >> 2.0.0.rc0 >> >> _______________________________________________ >> notmuch mailing list >> notmuch@notmuchmail.org >> http://notmuchmail.org/mailman/listinfo/notmuch --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iKYEARECAGYFAlN7Os1fFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl bnBncC5maWZ0aGhvcnNlbWFuLm5ldDc1M0Y5NDJDMEExNjc3MDE4OURGMUYyMDY5 RUNEMEFCRjA0OTY1MTYACgkQaezQq/BJZRbdUwCfRxbYZfm+srB8U1LadEZw+Oui 3tgAn2MKz81KbhE9yyfUmJcbv/fG5tDv =UI6X -----END PGP SIGNATURE----- --=-=-=--