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 641EF6DE0A7E for ; Mon, 30 Dec 2019 04:20:31 -0800 (PST) Authentication-Results: arlo.cworth.org; dkim=pass (2048-bit key; unprotected) header.d=dme-org.20150623.gappssmtp.com header.i=@dme-org.20150623.gappssmtp.com header.b="ZR0qXdeU"; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.251 X-Spam-Level: X-Spam-Status: No, score=0.251 tagged_above=-999 required=5 tests=[AWL=-0.401, 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 C4d5ExvUc1ED for ; Mon, 30 Dec 2019 04:20:30 -0800 (PST) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by arlo.cworth.org (Postfix) with ESMTPS id 3FD3D6DE0A6C for ; Mon, 30 Dec 2019 04:20:30 -0800 (PST) Received: by mail-wr1-f66.google.com with SMTP id b6so32543992wrq.0 for ; Mon, 30 Dec 2019 04:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:cc:subject:in-reply-to:references:from:date:message-id :mime-version; bh=tEtSwV1x+KNlS9Mro9UJreKv3z0QyxBflOt876hpQrc=; b=ZR0qXdeU+3kF+RW0muJknez+Qm5g1/o597ddy3HN+v2tvTHTO3Hpg8VNC8MchV5uEY 1LdV2T3VTjnY5i8EWmc2FsJUAe/CiV8Cbkg4WyTOPU3uqm0IrrL84EDCdBplYQntQXSj yjEQBsUB0psQMmSFO4XiCBi7hZLIqG/Q666nbj/jvui2d52S4kn1A6za/tmgceR9puNr pA6nh/c4+vL4YKnTuqfbZm45HFi3CdMxnJTjTpEF/G7NZ6odnyyWrCEEnWiDxLBNsG4D f4FtUj1PV4qIQN1xnFEgvsU3/6oIjPSYuuxNbqgPuszfGEztlFJIPo0U4ZXdfW4hmJgU 66wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:subject:in-reply-to:references:from:date :message-id:mime-version; bh=tEtSwV1x+KNlS9Mro9UJreKv3z0QyxBflOt876hpQrc=; b=TX4Wsgs72R4jtdow3SiVl1NqruXii3wZv6E2nfS1BLjEh+RTGm/b00Y6bfUTwBzG/e g0Xm0Z9XrBl670ghe2q1+HFazXHryVT2euzL2hDqyZ1dmHLDWdWnONv/tCHY4Khnk4+S OdxjvmTJY7I4gEExfaQswC6Sye8j+SD39mAB3+Bin8VlSOK8l0FD8nl09D8Z6SPY533q Jv/VW9WCrsVwWwrbUxPO6vX/QccPGDiYZChboJcofeGgRPlOkq/nz2wYqzbeFUS7H+Xl Ta92qvj1jTcX4XLU9FjXjYN4Kp3fEFeHUXqGxARLEeBi/prDmuzL4QwXt/MSR8iFKtJb w2hw== X-Gm-Message-State: APjAAAVG5TSBYz9YeQfNutDsJmmhrQs+7n2aU/eIJ4StzxFHA5BM8oRR FgHDq8i//mdydqCdPL146frcPU5z4+c= X-Google-Smtp-Source: APXvYqzbb1a/5ITGyQI2w9UVYUCXMOFgzTxpdaOYIsnMmuLoagcQNukUbnuMrZzUAVdFe6PZ7b56ig== X-Received: by 2002:adf:e6d2:: with SMTP id y18mr68936790wrm.262.1577708428343; Mon, 30 Dec 2019 04:20:28 -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 i10sm45811772wru.16.2019.12.30.04.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 04:20:27 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id f0ba7397; Mon, 30 Dec 2019 12:20:26 +0000 (UTC) To: William Casarin , notmuch@notmuchmail.org Subject: Re: [PATCH v3 2/7] emacs/tree: add notmuch-tree-goto-matching-message In-Reply-To: <20191228150124.20630-3-jb55@jb55.com> References: <20191228150124.20630-1-jb55@jb55.com> <20191228150124.20630-3-jb55@jb55.com> X-HGTTG: heart-of-gold From: David Edmondson Date: Mon, 30 Dec 2019 12:20:26 +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: Mon, 30 Dec 2019 12:20:31 -0000 On Saturday, 2019-12-28 at 10:01:19 -05, 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 Reviewed-by: David Edmondson > --- > emacs/notmuch-tree.el | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el > index d262ba26..18fdb1c0 100644 > --- a/emacs/notmuch-tree.el > +++ b/emacs/notmuch-tree.el > @@ -577,12 +577,23 @@ 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 ((dir (if prev -1 nil)) You don't need this final `nil', but it's a real nit ;-) > + (eobfn (if prev #'bobp #'eobp))) > + (while (and (not (funcall eobfn)) > + (not (notmuch-tree-get-match))) > + (forward-line dir)) > + (not (funcall eobfn)))) > + > (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 +601,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.24.0 dme. -- You bring light in.