unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: William Casarin <jb55@jb55.com>
To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message
Date: Wed, 04 Dec 2019 11:15:23 -0800	[thread overview]
Message-ID: <87k17brjg4.fsf@jb55.com> (raw)
In-Reply-To: <m2wobk3r4v.fsf@dme.org>

David Edmondson <dme@dme.org> writes:

> 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 <jb55@jb55.com>
>> ---
>>  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.

yup I believe this makes sense, I send out a new version in a bit.

>
>> +    (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?

  reply	other threads:[~2019-12-04 19:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
2019-11-28 16:13 ` [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread William Casarin
2019-11-28 16:24   ` David Edmondson
2019-12-04 19:14     ` William Casarin
2019-11-28 16:13 ` [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
2019-11-28 16:25   ` David Edmondson
2019-12-04 19:15     ` William Casarin [this message]
2019-11-28 16:13 ` [PATCH v2 3/8] emacs/tree: add notmuch-tree-matching-message William Casarin
2019-11-28 16:13 ` [PATCH v2 4/8] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
2019-11-28 16:13 ` [PATCH v2 5/8] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
2019-11-28 16:13 ` [PATCH v2 6/8] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
2019-11-28 16:14 ` [PATCH v2 7/8] emacs/tree: add x/X bindings William Casarin
2019-11-28 16:14 ` [PATCH v2 8/8] emacs: bind M-RET to notmuch-tree-from-search-thread William Casarin
2019-12-04 17:01 ` [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree Teemu Likonen
2019-12-04 19:18   ` William Casarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k17brjg4.fsf@jb55.com \
    --to=jb55@jb55.com \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).