## Intro

When I came back to the email account where I first subscribed to LKML,
it was *full*.

But if you are anyway using a local email client like `mutt`,
there is a better option than subscribing via email:
The `lei` program lets you import Linux mailing list archives into local maildirs:

```pikchr
fill = lightblue

box "public-inbox at" "lore.kernel.org" wid 120%
arrow <- "2. query" above
box "lei"
arrow "3. store" above wid 120%
cylinder "local" "maildir" fill lightyellow ht 120% wid 80%
arrow from last box.n up 1cm <- " 1. lei up --all" ljust
text "user"
```

The server side needs to run the [public-inbox](https://public-inbox.org) software.

## Set up

First, create a directory for your maildirs:

```
mkdir -p .Mail/lei
```

> Arch Linux installs `lei` into an unusual location.  In this case, add this to `.bashrc`:
> 
> ```
> alias lei=/usr/bin/vendor_perl/lei
> ```
{.info}

## Subscription/Search management

Subscribe to various mailing lists and to the mails that go to yourself ([Query Language](https://lore.kernel.org/all/_/text/help/)):

```
# Linux Security Module list
lei q --only=https://lore.kernel.org/linux-security-module \
      --output="${HOME}/.Mail/lei/lsm"                     \
      'rt:12.months.ago..'

# Linux Man Pages list
lei q --only=https://lore.kernel.org/linux-man \
      --output="${HOME}/.Mail/lei/man"         \
      'rt:12.months.ago..'

# Mails where I am in To: or Cc:, and the surrounding threads
lei q --only=https://lore.kernel.org/all \
      --output="${HOME}/.Mail/lei/tome"  \
      --threads                          \
      'a:myemail@example.com rt:36.months.ago..'
```

The `lei q` command is not issuing a single-shot query,
but it is storing the query locally as a subscription.

These subscriptions are called "searches" in lei lingo,
and their results are stored in the given maildir directories.

To see all the searches you have, use:

```
lei ls-search
```

To remove an existing search, use

```
lei forget-search "${HOME}/.Mail/lei/lsm"  # example
```

## Regularly: Update subscriptions/searches

To update all lei subscriptions and populate new content into the maildirs:

```
lei up --all
```

Now you are all set, and you can read the mailing lists with the MUA of your choice:

```
mutt -f ~/.Mail/lei/lsm
```

## References

* [lore+lei: part 1, getting started](https://people.kernel.org/monsieuricon/lore-lei-part-1-getting-started)
* [lore+lei, part 2, now with IMAP](https://people.kernel.org/monsieuricon/lore-lei-part-2-now-with-imap)
* [LWN: Digging into the community's lore with lei](https://lwn.net/Articles/878205/)

Thanks to [derkling](http://derkling.matbug.net/blog:email_setup), who pointed me to `lei`!
