From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id AE4956DE0944 for ; Thu, 28 Nov 2019 08:25:08 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.271 X-Spam-Level: X-Spam-Status: No, score=0.271 tagged_above=-999 required=5 tests=[AWL=-0.381, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8dbJLCK_Gj65 for ; Thu, 28 Nov 2019 08:25:07 -0800 (PST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by arlo.cworth.org (Postfix) with ESMTPS id 83F996DE00CC for ; Thu, 28 Nov 2019 08:25:07 -0800 (PST) Received: by mail-wr1-f65.google.com with SMTP id i12so31769180wrn.11 for ; Thu, 28 Nov 2019 08:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:subject:in-reply-to:references:from:date:message-id:mime-version; bh=sbsbyEatTA5/OEAHPn+YEmLH/zwXpLPIQWTOycLwdpM=; b=EVoO+yGHGOGETorPeSrb/qrVqE2D+KhbU9q+rXilUew/IMSb+gUZ2t2N0UPpGV+9X0 Vd/ECEGYsrbqaggxiF3iU38cGpchQd/ph1rC2DGDPnHgOYr6wipo1qNHTa3+tEvTLIf9 U3CkgkKWnrNkXXqAhFXFlhBSFSDlhDvz8YRDSsU9+h51YZiv9tTRqktp3Kn7/u+5Og7E LmXJ9G9YFOtmgpbyFkiPOzgmMoilPW+jTbFU0W5FcY4Ouly2tSJ+fwPa2VwRRK3ZI73M DIVH9LAbIb4G7q6miNTC77yRiC6G/+DTi+GfLi50LppzzJeWLOrr2HQmz0kwhLVxUBSf IDng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:subject:in-reply-to:references:from:date :message-id:mime-version; bh=sbsbyEatTA5/OEAHPn+YEmLH/zwXpLPIQWTOycLwdpM=; b=dulOrSbUO6tv2GFTh1dkz6MoZAAjfmHmhZreQAaLQiA4HZBrrPFzz+uA0arIBfCUAr t4IypITnTu68YDGZ2oGwcYkTN7uMRsu7dE3LHkFYqs8GYukmYCZExKSZjCqmqnOHRpUp X2pMaGZHxTwJswT56hsbSsq8p+zm8oqQEfJGLu50hC0KRcxVNWtdpeR5JlB2Jsaf1VjX u8CFoQphicP7gt7RmMygAEJ/TiGNhj75VU1I47pYLcFdR4hJBFnHOGOwmCb1vOyMbHnc 7MJjSz200W8mdU3AVLWhlad3Qc8yDbo1Xxaa2Wkk2LJkl5ab3OVx+bLvFn2UwGZBpBWD gQlA== X-Gm-Message-State: APjAAAUqssC2vchU6Hjyu9VjWKBJZsoh+JFsQOzR2EC8c4960fnCRCM4 vY2xNNlYbbX6dU0nepHf/+jSjw== X-Google-Smtp-Source: APXvYqwqRZ+FWhfwiYA4eA+zuQF8St1alVZUVGaDtRtN/loOcrPAczF3F7VP2fNDhgAJlrucFJygtg== X-Received: by 2002:a5d:55c5:: with SMTP id i5mr52287321wrw.385.1574958306113; Thu, 28 Nov 2019 08:25:06 -0800 (PST) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id r63sm10266921wma.2.2019.11.28.08.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 08:25:05 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 5ae08ebe; Thu, 28 Nov 2019 16:25:04 +0000 (UTC) To: William Casarin , notmuch@notmuchmail.org Subject: Re: [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message In-Reply-To: <20191128161401.28844-3-jb55@jb55.com> References: <20191128161401.28844-1-jb55@jb55.com> <20191128161401.28844-3-jb55@jb55.com> X-HGTTG: heart-of-gold From: David Edmondson Date: Thu, 28 Nov 2019 16:25:04 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 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: Thu, 28 Nov 2019 16:25:08 -0000 On Thursday, 2019-11-28 at 08:13:55 -08, William Casarin wrote: > This function captures some common logic when jumping to matching > messages in notmuch-tree mode. > > We also add a new return value (t or nil), that indicates if there was > a next matching message in the thread to show. > > Signed-off-by: William Casarin > --- > emacs/notmuch-tree.el | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el > index 4bc05160..9f2d87b5 100644 > --- a/emacs/notmuch-tree.el > +++ b/emacs/notmuch-tree.el > @@ -577,12 +577,22 @@ message will be \"unarchived\", i.e. the tag changes in > (when (window-live-p notmuch-tree-message-window) > (notmuch-tree-show-message-in))) > > +(defun notmuch-tree-goto-matching-message (&optional prev) > + "Move to the next or previous matching message. > + > +Returns t if there was a next matching message in the thread to show, > +nil otherwise." > + (let (last) > + (while (and (not (setq last (if prev (bobp) (eobp)))) > + (not (notmuch-tree-get-match))) > + (forward-line (if prev -1 nil))) A function scope variable to store the direction would save testing `prev' every time around the loop. Same question about the local variable as for the last patch. > + (not last))) > + > (defun notmuch-tree-prev-matching-message () > "Move to previous matching message." > (interactive) > (forward-line -1) > - (while (and (not (bobp)) (not (notmuch-tree-get-match))) > - (forward-line -1)) > + (notmuch-tree-goto-matching-message t) > (when (window-live-p notmuch-tree-message-window) > (notmuch-tree-show-message-in))) > > @@ -590,8 +600,7 @@ message will be \"unarchived\", i.e. the tag changes in > "Move to next matching message." > (interactive) > (forward-line) > - (while (and (not (eobp)) (not (notmuch-tree-get-match))) > - (forward-line)) > + (notmuch-tree-goto-matching-message) > (when (window-live-p notmuch-tree-message-window) > (notmuch-tree-show-message-in))) > > -- > 2.23.0 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch dme. -- Oh by the way, which one's Pink?