workflows.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* lore+lei: getting started
@ 2021-11-05 17:07 Konstantin Ryabitsev
  2021-11-08  2:17 ` Randy Dunlap
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Konstantin Ryabitsev @ 2021-11-05 17:07 UTC (permalink / raw)
  To: workflows

Hello, all:

I am going to post a series of articles about public inbox's new lei tool
(stands for "local email interface", but is clearly a "lorelei" joke :)). In
addition to being available here on the workflows list, they will also be
posted on my people.kernel.org blog.

## What's the problem?

One of kernel developers' perennial complaints is that they just get Too Much
Damn Email. Nobody in their right mind subscribes to "the LKML"
(linux-kernel@vger.kernel.org) because it acts as a dumping ground for all
email and the resulting firehose of patches and rants is completely impossible
for a sane human being to follow.

For this reason, actual Linux development tends to happen on separate mailing
lists dedicated to each particular subsystem. In turn, this has several
negative side-effects:

1. Developers working across multiple subsystems end up needing to subscribe
   to many different mailing lists in order to stay aware of what is happening
   in each area of the kernel.

2. Contributors submitting patches find it increasingly difficult to know
   where to send their work, especially if their patches touch many different
   subsystems.

The `get_maintainer.pl` script is an attempt to solve the problem #2, and will
look at the diff contents in order to suggest the list of recipients for each
submitted patch. However, the submitter needs to be both aware of this script
and know how to properly configure it in order to correctly use it with
git-send-email.

Further complicating the matter is the fact that `get_maintainer.pl` relies on
the entries in the `MAINTAINERS` file. Any edits to that file must go through
the regular patch submission and review process and it may take days or weeks
before the updates find their way to individual contributors.

Wouldn't it be nice if contributors could just send their patches to one
place, and developers could just filter out the stuff that is relevant to
their subsystem and ignore the rest?

## lore meets lei

Public-inbox started out as a distributed mailing list archival framework with
powerful search capabilities. We were happy to adopt it for our needs when we
needed a proper home for kernel mailing list archives -- thus, lore.kernel.org
came online.

Even though it started out as merely a list archival service, it quickly
became obvious that lore could be used for a lot more. Many developers ended
up using its search features to quickly locate emails of interest, which in
turn raised a simple question -- what if there was a way to "save a search"
and have it deliver all new incoming mail matching certain parameters straight
to the developers' inbox?

You can now do this with lei.

## lore's search syntax

Public-inbox uses Xapian behind the scenes, which allows to narrowly tailor
the keyword database to very specific needs.

For example, did you know that you can search lore.kernel.org for patches that
touch specific files? Here's every patch that touched the MAINTAINERS file:

* https://lore.kernel.org/all/?q=dfn%3AMAINTAINERS

How about every patch that modifies a function that starts with `floppy_`:

* https://lore.kernel.org/all/?q=dfhh%3Afloppy_*

Say you're the floppy driver maintainer and wanted to find all mail that
touches `drivers/block/floppy.c` and modifies any function that starts with
`floppy_` or has "floppy" in the subject and maybe any other mail that
mentions "floppy" and has the words "bug" or "regression"? And maybe limit the
results to just the past month.

Here's the query:

    (dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy
     OR ((nq:bug OR nq:regression) AND nq:floppy))
    AND rt:1.month.ago..

And here are the results:

* https://lore.kernel.org/all/?q=%28dfhh%3Afloppy_*+OR+dfn%3Adrivers%2Fblock%2Ffloppy.c+OR+s%3Afloppy+OR+%28%28nq%3Abug+OR+nq%3Aregression%29+AND+nq%3Afloppy%29%29+AND+rt%3A1.month.ago..

Now, how about getting that straight into your mailbox, so you don't have to
subscribe to the (very busy) linux-block list, if you are the floppy
maintainer?

## Installing lei

Lei is very new and probably isn't yet available as part of your distribution,
but I hope that it will change quickly once everyone realizes how awesome it
is.

I'm working on packaging lei for Fedora, so depending on when you're reading
this, try `dnf install lei` -- maybe it's already there. If it's not in Fedora
proper yet, you can get it from my copr:

    dnf copr enable icon/b4
    dnf install lei

If you're not a Fedora user, just consult the INSTALL file:

* https://public-inbox.org/INSTALL.html

## Maildir or IMAP?

Lei can deliver search results either into a local maildir, or to a remote
IMAP folder (or both). We'll do local maildir first and look at IMAP in a
future follow-up, as it requires some preparatory work.

## Getting going with lei-q

Let's take the exact query we used for the floppy drive above, and get lei to
deliver entire matching threads into a local maildir folder that we can read
with mutt:

    lei q -I https://lore.kernel.org/all/ -o ~/Mail/floppy \
      --threads --dedupe=mid \
      '(dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy \
      OR ((nq:bug OR nq:regression) AND nq:floppy)) \
      AND rt:1.month.ago..'

Before you run it, let's understand what it's going to do:

* `-I https://lore.kernel.org/all/` will query the aggregated index that
  contains information about all mailing lists archived on lore.kernel.org. It
  doesn't matter to which list the patch was sent -- if it's on lore, the
  query will find it.

* `-o ~/Mail/floppy` will create a new Maildir folder and put the search
  results there. Make sure that this folder doesn't already exist, or lei will
  clobber anything already present there (unless you use `--augment`, but I
  haven't tested this very extensively yet, so best to start with a clean
  slate).

* `--threads` will deliver entire threads even if the match is somewhere in
  the middle of the discussion. This is handy if, for example, someone
  says "this sounds like a bug in the floppy subsystem" somewhere in the
  middle of a conversation and `--threads` will automatically get you the
  entire conversation context.

* `--dedupe=mid` will deduplicate results based on the message-id header. The
  default behaviour is to dedupe based on the body contents, but with so many
  lists still adding junky "sent to the foo list" footers, this tends to
  result in too many duplicated results. Passing `--dedupe=mid` is less safe
  (someone *could* sneak in a bogus message with an identical message-id and
  have it delivered to you instead), but more convenient. YMMV, BYOB.

* Make sure you don't omit the final ".." in the `rt:` query parameter, or you
  will only get mail that was sent *on* that date, not *since* that date.

As always, backslashes and newlines are there just for readability -- you
don't need to use them.

After the command completes, you should get something similar to what is
below:

    # /usr/bin/curl -Sf -s -d '' https://lore.kernel.org/all/?x=m&t=1&q=(omitted)
    # /home/user/.local/share/lei/store 0/0
    # https://lore.kernel.org/all/ 122/?
    # https://lore.kernel.org/all/ 227/227
    # 150 written to /home/user/Mail/floppy/ (227 matches)

A few things to notice here:

1. The command actually executes a curl call and retrieves the results as an
   mbox file.
2. Lei will automatically convert `1.month.ago` into a precise timestamp
3. The command wrote 150 messages into the maildir we specified

We can now view these results with mutt (or neomutt):

    neomutt -f ~/Mail/floppy

It is safe to delete mail from this folder -- it will not get re-added during
`lei up` runs, as lei keeps track of seen messages on its own.

## Updating with lei-up

By default, `lei -q` will save your search and start keeping track of it. To
see your saved searches, run:

    $ lei ls-search
    /home/user/Mail/floppy

To fetch the newest messages:

    lei up ~/Mail/floppy

You will notice that the first line of output will say that lei automatically
limited the results to only those that arrived since the last time lei was
invoked for this particular saved search, so you will most likely get no new
messages.

As you add more queries in the future, you can update them all at once using:

    lei up --all

## Editing and discarding saved searches

To edit your saved search, just run `lei edit-search`. This will bring up your
$EDITOR with the configuration file lei uses internally:

    ; to refresh with new results, run: lei up /home/user/Mail/floppy
    ; `maxuid' and `lastresult' lines are maintained by "lei up" for optimization
    [lei]
        q = (dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy OR \
            ((nq:bug OR nq:regression) AND nq:floppy)) AND rt:1.month.ago..
    [lei "q"]
        include = https://lore.kernel.org/all/
        external = 1
        local = 1
        remote = 1
        threads = 1
        dedupe = mid
        output = maildir:/home/user/Mail/floppy
    [external "/home/user/.local/share/lei/store"]
        maxuid = 4821
    [external "https://lore.kernel.org/all/"]
        lastresult = 1636129583

This lets you edit the query parameters if you want to add/remove specific
keywords. I suggest you test them on lore.kernel.org first before putting them
into the configuration file, just to make sure you don't end up retrieving
tens of thousands of messages by mistake.

To delete a saved search, run:

    lei forget-search ~/Mail/floppy

This doesn't delete anything from `~/Mail/floppy`, it just makes it impossible
to run `lei up` to update it.

## Subscribing to entire mailing lists

To subscribe to entire mailing lists, you can query based on the list-id
header. For example, if you wanted to replace your individual subscriptions
to linux-block and linux-scsi with a single lei command, do:

    lei q -I https://lore.kernel.org/all/ -o ~/Mail/lists --dedupe=mid \
      '(l:linux-block.vger.kernel.org OR l:linux-scsi.vger.kernel.org) AND rt:1.week.ago..'

You can always edit this to add more lists at any time.

## Coming next

In the next series installment, I'll talk about how to deliver these results
straight to a remote IMAP folder and how to set up a systemd timer to get
newest mail automatically (if that's your thing -- I prefer to run `lei up`
manually and only when I'm ready for it).

-K

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lore+lei: getting started
  2021-11-05 17:07 lore+lei: getting started Konstantin Ryabitsev
@ 2021-11-08  2:17 ` Randy Dunlap
  2021-11-08 19:49 ` Rob Herring
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Randy Dunlap @ 2021-11-08  2:17 UTC (permalink / raw)
  To: Konstantin Ryabitsev, workflows

On 11/5/21 10:07 AM, Konstantin Ryabitsev wrote:
> For this reason, actual Linux development tends to happen on separate mailing
> lists dedicated to each particular subsystem. In turn, this has several
> negative side-effects:
> 
> 1. Developers working across multiple subsystems end up needing to subscribe
>     to many different mailing lists in order to stay aware of what is happening
>     in each area of the kernel.
> 
> 2. Contributors submitting patches find it increasingly difficult to know
>     where to send their work, especially if their patches touch many different
>     subsystems.

3. Users send email problem reports to LKML they are completely ignored.
     (They don't know better or they think that the big pipe must be useful for
     something or whatever....)

-- 
~Randy

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lore+lei: getting started
  2021-11-05 17:07 lore+lei: getting started Konstantin Ryabitsev
  2021-11-08  2:17 ` Randy Dunlap
@ 2021-11-08 19:49 ` Rob Herring
       [not found]   ` <20211108202204.q5zg6bachnvbjlnx@meerkat.local>
  2022-01-10 19:40 ` lore+lei: getting started Bjorn Helgaas
  2022-03-07 16:48 ` Rob Herring
  3 siblings, 1 reply; 11+ messages in thread
From: Rob Herring @ 2021-11-08 19:49 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: workflows

On Fri, Nov 5, 2021 at 12:07 PM Konstantin Ryabitsev
<konstantin@linuxfoundation.org> wrote:
>
> Hello, all:
>
> I am going to post a series of articles about public inbox's new lei tool
> (stands for "local email interface", but is clearly a "lorelei" joke :)). In
> addition to being available here on the workflows list, they will also be
> posted on my people.kernel.org blog.
>
> ## What's the problem?
>
> One of kernel developers' perennial complaints is that they just get Too Much
> Damn Email. Nobody in their right mind subscribes to "the LKML"
> (linux-kernel@vger.kernel.org) because it acts as a dumping ground for all
> email and the resulting firehose of patches and rants is completely impossible
> for a sane human being to follow.
>
> For this reason, actual Linux development tends to happen on separate mailing
> lists dedicated to each particular subsystem. In turn, this has several
> negative side-effects:
>
> 1. Developers working across multiple subsystems end up needing to subscribe
>    to many different mailing lists in order to stay aware of what is happening
>    in each area of the kernel.
>
> 2. Contributors submitting patches find it increasingly difficult to know
>    where to send their work, especially if their patches touch many different
>    subsystems.
>
> The `get_maintainer.pl` script is an attempt to solve the problem #2, and will
> look at the diff contents in order to suggest the list of recipients for each
> submitted patch. However, the submitter needs to be both aware of this script
> and know how to properly configure it in order to correctly use it with
> git-send-email.
>
> Further complicating the matter is the fact that `get_maintainer.pl` relies on
> the entries in the `MAINTAINERS` file. Any edits to that file must go through
> the regular patch submission and review process and it may take days or weeks
> before the updates find their way to individual contributors.
>
> Wouldn't it be nice if contributors could just send their patches to one
> place, and developers could just filter out the stuff that is relevant to
> their subsystem and ignore the rest?
>
> ## lore meets lei
>
> Public-inbox started out as a distributed mailing list archival framework with
> powerful search capabilities. We were happy to adopt it for our needs when we
> needed a proper home for kernel mailing list archives -- thus, lore.kernel.org
> came online.
>
> Even though it started out as merely a list archival service, it quickly
> became obvious that lore could be used for a lot more. Many developers ended
> up using its search features to quickly locate emails of interest, which in
> turn raised a simple question -- what if there was a way to "save a search"
> and have it deliver all new incoming mail matching certain parameters straight
> to the developers' inbox?
>
> You can now do this with lei.
>
> ## lore's search syntax
>
> Public-inbox uses Xapian behind the scenes, which allows to narrowly tailor
> the keyword database to very specific needs.
>
> For example, did you know that you can search lore.kernel.org for patches that
> touch specific files? Here's every patch that touched the MAINTAINERS file:
>
> * https://lore.kernel.org/all/?q=dfn%3AMAINTAINERS
>
> How about every patch that modifies a function that starts with `floppy_`:
>
> * https://lore.kernel.org/all/?q=dfhh%3Afloppy_*
>
> Say you're the floppy driver maintainer and wanted to find all mail that
> touches `drivers/block/floppy.c` and modifies any function that starts with
> `floppy_` or has "floppy" in the subject and maybe any other mail that
> mentions "floppy" and has the words "bug" or "regression"? And maybe limit the
> results to just the past month.
>
> Here's the query:
>
>     (dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy
>      OR ((nq:bug OR nq:regression) AND nq:floppy))
>     AND rt:1.month.ago..
>
> And here are the results:
>
> * https://lore.kernel.org/all/?q=%28dfhh%3Afloppy_*+OR+dfn%3Adrivers%2Fblock%2Ffloppy.c+OR+s%3Afloppy+OR+%28%28nq%3Abug+OR+nq%3Aregression%29+AND+nq%3Afloppy%29%29+AND+rt%3A1.month.ago..
>
> Now, how about getting that straight into your mailbox, so you don't have to
> subscribe to the (very busy) linux-block list, if you are the floppy
> maintainer?
>
> ## Installing lei
>
> Lei is very new and probably isn't yet available as part of your distribution,
> but I hope that it will change quickly once everyone realizes how awesome it
> is.
>
> I'm working on packaging lei for Fedora, so depending on when you're reading
> this, try `dnf install lei` -- maybe it's already there. If it's not in Fedora
> proper yet, you can get it from my copr:
>
>     dnf copr enable icon/b4
>     dnf install lei
>
> If you're not a Fedora user, just consult the INSTALL file:
>
> * https://public-inbox.org/INSTALL.html
>
> ## Maildir or IMAP?
>
> Lei can deliver search results either into a local maildir, or to a remote
> IMAP folder (or both). We'll do local maildir first and look at IMAP in a
> future follow-up, as it requires some preparatory work.
>
> ## Getting going with lei-q
>
> Let's take the exact query we used for the floppy drive above, and get lei to
> deliver entire matching threads into a local maildir folder that we can read
> with mutt:
>
>     lei q -I https://lore.kernel.org/all/ -o ~/Mail/floppy \
>       --threads --dedupe=mid \
>       '(dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy \
>       OR ((nq:bug OR nq:regression) AND nq:floppy)) \
>       AND rt:1.month.ago..'

I tried a similar one which I had working as a bookmark:

$ lei q -I https://lore.kernel.org/all/ -o ~/Mail/my-patches
--threads --dedupe=mid '(dfn:drivers OR dfn:arch OR dfn:Documentation
OR dfn:include OR dfn:scripts) AND f:robh@kernel.org'
# /home/rob/.local/share/lei/store 0/0
# /usr/bin/curl -Sf -s -d ''
https://lore.kernel.org/all/?x=m&t=1&q=(dfn%3A%22drivers+OR+dfn%3Aarch+OR+dfn%3ADocumentation+OR+dfn%3Ainclude+OR+dfn%3Ascripts)+AND+f%3Arobh%40kernel.org%22
# 0 written to /home/rob/Mail/my-patches/ (0 matches)

It seems there is some problem in quoting. Notice the '%22' that's
inserted in the url.

Also, the above query is a bit of a work-around as what I really want
is just all patches from me. I haven't been able to get something to
work. I've tried things like 'dfn:*' or 'dfn:/' or 'dfn:b/'.

Rob

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lei: incorrect quoting on saved searches (was Re: lore+lei: getting started)
       [not found]   ` <20211108202204.q5zg6bachnvbjlnx@meerkat.local>
@ 2021-11-08 20:49     ` Eric Wong
  2021-11-08 21:36       ` Konstantin Ryabitsev
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2021-11-08 20:49 UTC (permalink / raw)
  To: Rob Herring; +Cc: Konstantin Ryabitsev, meta, workflows

Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> On Mon, Nov 08, 2021 at 01:49:07PM -0600, Rob Herring wrote:
> 
> Moving this to meta.

I don't think workflows should've been dropped, though.

> > >     lei q -I https://lore.kernel.org/all/ -o ~/Mail/floppy \
> > >       --threads --dedupe=mid \
> > >       '(dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy \
> > >       OR ((nq:bug OR nq:regression) AND nq:floppy)) \
> > >       AND rt:1.month.ago..'
> > 
> > I tried a similar one which I had working as a bookmark:

That's actually treating the entire single-quoted section as
a phrase search for Xapian.

The correct way to use '(', ')', and '*' on the command-line for
Xapian is to shell escape them:

	lei q -I https://lore.kernel.org/all/ -o ~/Mail/floppy \
		--threads --dedupe=mid \
	\( dfn:drivers/block/floppy.c OR dfhh:floppy_\* OR s:floppy \
		OR \(\(nq:bug OR nq:regression\) AND nq:floppy\)\) \
		AND rt:1.month.ago...

Since shell escaping so many metacharacters is annoying,
stdin is supported (and implicit iff file|pipe):

	echo '(dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy \
		OR ((nq:bug OR nq:regression) AND nq:floppy)) \
		AND rt:1.month.ago..' | \
		lei q -I https://lore.kernel.org/all/ -o ~/Mail/floppy \
		--threads --dedupe=mid

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lei: incorrect quoting on saved searches (was Re: lore+lei: getting started)
  2021-11-08 20:49     ` lei: incorrect quoting on saved searches (was Re: lore+lei: getting started) Eric Wong
@ 2021-11-08 21:36       ` Konstantin Ryabitsev
  2021-11-08 21:48         ` Eric Wong
  0 siblings, 1 reply; 11+ messages in thread
From: Konstantin Ryabitsev @ 2021-11-08 21:36 UTC (permalink / raw)
  To: Eric Wong; +Cc: Rob Herring, meta, workflows

On Mon, Nov 08, 2021 at 08:49:23PM +0000, Eric Wong wrote:
> Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> > On Mon, Nov 08, 2021 at 01:49:07PM -0600, Rob Herring wrote:
> > 
> > Moving this to meta.
> 
> I don't think workflows should've been dropped, though.
> 
> > > >     lei q -I https://lore.kernel.org/all/ -o ~/Mail/floppy \
> > > >       --threads --dedupe=mid \
> > > >       '(dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy \
> > > >       OR ((nq:bug OR nq:regression) AND nq:floppy)) \
> > > >       AND rt:1.month.ago..'
> > > 
> > > I tried a similar one which I had working as a bookmark:
> 
> That's actually treating the entire single-quoted section as
> a phrase search for Xapian.

Hmm... I noticed that when I `lei edit-search` the initial query that was
causing quoting issues, I get the following:

	[lei]
		q = (dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org

So, the extra quotes didn't get added to the config file. Running `lei up` on
that saved search seems to do the right thing, so the erroneous quotes are
only added during the initial `lei q` call.

> The correct way to use '(', ')', and '*' on the command-line for
> Xapian is to shell escape them:

But putting them into single quotes should accomplish the same result, no? At
least, that's how I've always understood shell escaping.

-K

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lei: incorrect quoting on saved searches (was Re: lore+lei: getting started)
  2021-11-08 21:36       ` Konstantin Ryabitsev
@ 2021-11-08 21:48         ` Eric Wong
  2021-11-08 22:36           ` Konstantin Ryabitsev
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2021-11-08 21:48 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: Rob Herring, meta, workflows

Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> On Mon, Nov 08, 2021 at 08:49:23PM +0000, Eric Wong wrote:
> > Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> > > On Mon, Nov 08, 2021 at 01:49:07PM -0600, Rob Herring wrote:
> > 
> > > > >     lei q -I https://lore.kernel.org/all/ -o ~/Mail/floppy \
> > > > >       --threads --dedupe=mid \
> > > > >       '(dfn:drivers/block/floppy.c OR dfhh:floppy_* OR s:floppy \
> > > > >       OR ((nq:bug OR nq:regression) AND nq:floppy)) \
> > > > >       AND rt:1.month.ago..'
> > > > 
> > > > I tried a similar one which I had working as a bookmark:
> > 
> > That's actually treating the entire single-quoted section as
> > a phrase search for Xapian.
> 
> Hmm... I noticed that when I `lei edit-search` the initial query that was
> causing quoting issues, I get the following:
> 
> 	[lei]
> 		q = (dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org
> 
> So, the extra quotes didn't get added to the config file. Running `lei up` on
> that saved search seems to do the right thing, so the erroneous quotes are
> only added during the initial `lei q` call.

Right, each entry in lei.q is actually an entry in argv[].
So the correct query should look something like:

[lei]
        q = (
        q = dfn:drivers/block/floppy.c
        q = OR
...

> > The correct way to use '(', ')', and '*' on the command-line for
> > Xapian is to shell escape them:
> 
> But putting them into single quotes should accomplish the same result, no? At
> least, that's how I've always understood shell escaping.

Yeah, that works, too.  As long as spaces/tabs don't show up
within each argv[] element, it won't be interpreted as a phrase.

I really wanted:	lei q s:"a quick brown fox"
to work from a shell like it would in the WWW UI;
and thus deprioritized '(' and ')' working properly :x

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lei: incorrect quoting on saved searches (was Re: lore+lei: getting started)
  2021-11-08 21:48         ` Eric Wong
@ 2021-11-08 22:36           ` Konstantin Ryabitsev
  2021-11-08 22:57             ` Eric Wong
  0 siblings, 1 reply; 11+ messages in thread
From: Konstantin Ryabitsev @ 2021-11-08 22:36 UTC (permalink / raw)
  To: Eric Wong; +Cc: Rob Herring, meta, workflows

On Mon, Nov 08, 2021 at 09:48:36PM +0000, Eric Wong wrote:
> > Hmm... I noticed that when I `lei edit-search` the initial query that was
> > causing quoting issues, I get the following:
> > 
> > 	[lei]
> > 		q = (dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org
> > 
> > So, the extra quotes didn't get added to the config file. Running `lei up` on
> > that saved search seems to do the right thing, so the erroneous quotes are
> > only added during the initial `lei q` call.
> 
> Right, each entry in lei.q is actually an entry in argv[].
> So the correct query should look something like:

So, to be clear here... the following doesn't work because instead of multiple
query parameters to 'lei q' the single-quoted string becomes a single
parameter?

	lei q -I https://lore.kernel.org/all/ -o ~/work/temp/lei/robh-patches \
    --threads --dedupe=mid \
    '(dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org'

Any way to make this work? I find that it's more easily readable than the
"echo | lei q" version.

For bash users, the following should work as well:

	lei q -I https://lore.kernel.org/all/ -o ~/work/temp/lei/robh-patches \
    --threads --dedupe=mid <<< \
    '(dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org'

Suggestion, can -I accept the URL containing the query, so that the command
becomes:

    lei q -o ~/mail/foo --threads --dedupe=mid -I \
    https://lore.kernel.org/all/?q=f%3Atorvalds+AND+nq%3Agarbage

This way we pass both the location of the extindex to query AND the parameters
we should use, avoiding shell quoting problems?

-K

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lei: incorrect quoting on saved searches (was Re: lore+lei: getting started)
  2021-11-08 22:36           ` Konstantin Ryabitsev
@ 2021-11-08 22:57             ` Eric Wong
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2021-11-08 22:57 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: Rob Herring, meta, workflows

Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> On Mon, Nov 08, 2021 at 09:48:36PM +0000, Eric Wong wrote:
> > > Hmm... I noticed that when I `lei edit-search` the initial query that was
> > > causing quoting issues, I get the following:
> > > 
> > > 	[lei]
> > > 		q = (dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org
> > > 
> > > So, the extra quotes didn't get added to the config file. Running `lei up` on
> > > that saved search seems to do the right thing, so the erroneous quotes are
> > > only added during the initial `lei q` call.
> > 
> > Right, each entry in lei.q is actually an entry in argv[].
> > So the correct query should look something like:
> 
> So, to be clear here... the following doesn't work because instead of multiple
> query parameters to 'lei q' the single-quoted string becomes a single
> parameter?
> 
> 	lei q -I https://lore.kernel.org/all/ -o ~/work/temp/lei/robh-patches \
>     --threads --dedupe=mid \
>     '(dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org'
> 
> Any way to make this work? I find that it's more easily readable than the
> "echo | lei q" version.

I can't think of a way to make it work w/o breaking phrase searches
(or asking users to use both single and double-quotes):

	lei q 's:"a quick brown fox"' # yuck

> For bash users, the following should work as well:
> 
> 	lei q -I https://lore.kernel.org/all/ -o ~/work/temp/lei/robh-patches \
>     --threads --dedupe=mid <<< \
>     '(dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts) AND f:robh@kernel.org'

Oh, not sure about bash and <<<; but this heredoc should work with any
POSIX sh:

	lei q -I https://lore.kernel.org/all/ \
		-o ~/work/temp/lei/robh-patches \
		--threads --dedupe=mid <<'EOM'
(dfn:drivers OR dfn:arch OR dfn:Documentation OR dfn:include OR dfn:scripts)
AND f:robh@kernel.org
EOM

> Suggestion, can -I accept the URL containing the query, so that the command
> becomes:
> 
>     lei q -o ~/mail/foo --threads --dedupe=mid -I \
>     https://lore.kernel.org/all/?q=f%3Atorvalds+AND+nq%3Agarbage
> 
> This way we pass both the location of the extindex to query AND the parameters
> we should use, avoiding shell quoting problems?

Maybe, but URI escaping bothers the heck out of me, too.
I guess the heredoc example is actually good...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lore+lei: getting started
  2021-11-05 17:07 lore+lei: getting started Konstantin Ryabitsev
  2021-11-08  2:17 ` Randy Dunlap
  2021-11-08 19:49 ` Rob Herring
@ 2022-01-10 19:40 ` Bjorn Helgaas
  2022-01-11  1:52   ` Kyle Meyer
  2022-03-07 16:48 ` Rob Herring
  3 siblings, 1 reply; 11+ messages in thread
From: Bjorn Helgaas @ 2022-01-10 19:40 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: workflows

I'm really excited about lei; thanks very much for working on it!

On Fri, Nov 05, 2021 at 01:07:38PM -0400, Konstantin Ryabitsev wrote:
> By default, `lei -q` will save your search and start keeping track of it. To
> see your saved searches, run:

I think this is a typo for "lei q".  I only mention it because this
typo also appears in your blog:
https://people.kernel.org/monsieuricon/lore-lei-part-1-getting-started

> To edit your saved search, just run `lei edit-search`. This will bring up your
> $EDITOR with the configuration file lei uses internally:

This isn't working for me.  With current public-inbox (07cd8973baf8
("Makefile.PL: fix useless use of push")), I get:

  $ lei edit-search
  usage: lei edit-search OUTPUT
  E: OUTPUT not supplied
  $ lei edit-search out
  --no-save was used with out cwd=/home/bjorn

Maybe I'm doing something wrong?

"lei help" and "lei --help" are not very useful because I can't figure
out how to even get a list of the commands:

  $ lei help | cat
  usage: lei help [SUBCOMMAND]
  show help

  $ lei --help | cat
  usage: lei COMMAND ...
  ...

lib/PublicInbox/LEI.pm *looks* like it has good help text in it, so
maybe I'm doing something wrong.

Also their output gets piped through $PAGER by default, which isn't
super convenient.

Bjorn

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lore+lei: getting started
  2022-01-10 19:40 ` lore+lei: getting started Bjorn Helgaas
@ 2022-01-11  1:52   ` Kyle Meyer
  0 siblings, 0 replies; 11+ messages in thread
From: Kyle Meyer @ 2022-01-11  1:52 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: Konstantin Ryabitsev, workflows

Bjorn Helgaas writes:

>> To edit your saved search, just run `lei edit-search`. This will bring up your
>> $EDITOR with the configuration file lei uses internally:
>
> This isn't working for me.  With current public-inbox (07cd8973baf8
> ("Makefile.PL: fix useless use of push")), I get:
>
>   $ lei edit-search
>   usage: lei edit-search OUTPUT
>   E: OUTPUT not supplied
>   $ lei edit-search out
>   --no-save was used with out cwd=/home/bjorn
>
> Maybe I'm doing something wrong?

Specifying an output (a destination previously given to lei-q's
-o/--output/-mfolder) is required.  You can see which ones are available
with

  $ lei ls-search

> "lei help" and "lei --help" are not very useful because I can't figure
> out how to even get a list of the commands:
>
>   $ lei help | cat
>   usage: lei help [SUBCOMMAND]
>   show help
>
>   $ lei --help | cat
>   usage: lei COMMAND ...
>   ...
>
> lib/PublicInbox/LEI.pm *looks* like it has good help text in it, so
> maybe I'm doing something wrong.

`man lei` provides a pretty complete list of commands.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: lore+lei: getting started
  2021-11-05 17:07 lore+lei: getting started Konstantin Ryabitsev
                   ` (2 preceding siblings ...)
  2022-01-10 19:40 ` lore+lei: getting started Bjorn Helgaas
@ 2022-03-07 16:48 ` Rob Herring
  3 siblings, 0 replies; 11+ messages in thread
From: Rob Herring @ 2022-03-07 16:48 UTC (permalink / raw)
  To: Konstantin Ryabitsev, workflows

On Fri, Nov 5, 2021 at 12:07 PM Konstantin Ryabitsev
<konstantin@linuxfoundation.org> wrote:
>
> Hello, all:
>
> I am going to post a series of articles about public inbox's new lei tool
> (stands for "local email interface", but is clearly a "lorelei" joke :)). In
> addition to being available here on the workflows list, they will also be
> posted on my people.kernel.org blog.

I also wanted to do non-persistent searches. Essentially, the lore web
interface search box on the command line. lei can do this with the
right options and some avoidance of shell escaping. The shell script
below is what I came up with.

Note I have the stable exclusion added because subject searches with
'get the whole thread' enabled often picks up Greg's 100+ patch
series.

Rob

8<------------------------------------------------------------------
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only

usage()
{
        echo "syntax: `basename $0` [-t] <query string>"
        echo ""
        echo "For query syntax, see https://lore.kernel.org/all/_/text/help/"
        exit 1
}

while getopts "ht" opt
do
        case "$opt" in
        t)      threads="-t";;
        [h?])    usage;;
        esac
done
shift $((OPTIND-1))
query_str="$*"
[ -z "$query_str" ] && usage


tmp_mbox=$(mktemp)

echo "$query_str" NOT tc:stable@vger.kernel.org | \
  lei q --no-save --dedupe=mid -f mboxrd -O
https://lore.kernel.org/all/ -o $tmp_mbox --stdin

if [ -s "$tmp_mbox" ]; then
        mutt -f $tmp_mbox
fi

rm $tmp_mbox

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-03-07 16:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05 17:07 lore+lei: getting started Konstantin Ryabitsev
2021-11-08  2:17 ` Randy Dunlap
2021-11-08 19:49 ` Rob Herring
     [not found]   ` <20211108202204.q5zg6bachnvbjlnx@meerkat.local>
2021-11-08 20:49     ` lei: incorrect quoting on saved searches (was Re: lore+lei: getting started) Eric Wong
2021-11-08 21:36       ` Konstantin Ryabitsev
2021-11-08 21:48         ` Eric Wong
2021-11-08 22:36           ` Konstantin Ryabitsev
2021-11-08 22:57             ` Eric Wong
2022-01-10 19:40 ` lore+lei: getting started Bjorn Helgaas
2022-01-11  1:52   ` Kyle Meyer
2022-03-07 16:48 ` Rob Herring

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 NNTP newsgroup(s).