Add support for `--limit=N` to `notmuch show`

Ciprian Dorin Craciun ciprian.craciun at gmail.com
Fri May 1 05:28:27 PDT 2020


In a previous email (about `thread:...` field in JSON output of
`notmuch show`), I described one of my use-cases for notmuch.

Now extending upon that, if one would to implement an email client
that provides the user with search, there are two approaches:

* use `notmuch search -- {query}` and based on that output display a
thread list like GMail does;

* use `notmuch show -- {query}` and based on that display a page with
all emails that matched, grouping them by thread;  (I prefer this
variant, as it gives me a quicker glance if I search for something
specific;)



Now the problem with `notmuch show` is that if I give it a too "broad"
query like `*` it will chew a lot of CPU and RAM (and in my case
eventually crash).

`notmuch search` does have a `--limit=N` argument that limits the
search output only to the first `N` items.  My feature request is to
add such a flag also to `notmuch show` that should:

* limit the number of threads in all cases except `--format=raw`;
* not be allowed in case of `--format=raw` or `--part=P`;



As a work-around I could use `notmuch search --output=threads
--limit={limit} -- {query}`, then take those thread ID's and issue an
`notmuch show -- thread:... thread:...`.  But this has the following
problems:
* it requires two `notmuch` CLI calls;
* and most importantly it renders the `--entire-thread=false` feature
useless;  (as not the entire threads are matched by `notmuch show` as
opposed only to those matched by `notmuch search`;)

Thanks,
Ciprian.


More information about the notmuch mailing list