user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Josh Steadmon <steadmon@google.com>
To: meta@public-inbox.org
Subject: How do I write labels back to the source Maildir?
Date: Wed, 24 Jan 2024 14:51:04 -0800	[thread overview]
Message-ID: <ZbGUWGw6DEGf3Ufp@google.com> (raw)

Hi folks,

This ended up being a longer email than I wanted, so to summarize, my
main question is: is it possible to have lei write labels created with
`lei-tag` back to the source Maildir which was indexed with `lei-index`?
Additional details below:


I'm a Git developer, and I am subscribed to git@vger.kernel.org. I sync
that mail from my corp Gmail account to a local Maildir with mbsync. I
would like that single Maildir to be the canonical source of mail, which
I generally read with Mutt.

Within that Maildir, I would like to be able to quickly find emails
about unit tests. I can find these on lore.kernel.org with a query like:
"dfn:t/unit-tests OR s:unit OR ((nq:bug OR nq:regression) AND nq:unit)"

Ideally, I'd like some sort of automated lei setup to tag messages
matching the above query, and then I can use Mutt's built-in filtering
to show me only those threads.

Since I want the mbsync-ed Maildir to be the canonical source of mail,
it sounds like `lei-index` is what I want. I ran
`lei index ~/.mail/gmail/git-external` and it seems to be OK.

Next I want to see if I can search those indexed mails, so I run
`lei q dfn:t/unit-tests OR s:unit OR \(\(nq:bug OR nq:regression\) AND nq:unit\)`
and I get some JSON containing email metadata matching the query. So
far, so good.

Now I want to label those matching messages. After a bit of
experimentation, I come up with the following combination of lei-q and
lei-tag:
```
lei q -f mboxrd dfn:t/unit-tests OR s:unit OR \(\(nq:bug OR nq:regression\) AND nq:unit\) \
  | lei tag -F mboxrd - +L:git-unit-tests
```

To make sure the label was applied, I run `lei q L:git-unit-tests` and I
get back the same set of emails I expect. Great.

However, now I'm stuck trying to get that label metadata back into my
Maildir. I've tried both `lei refresh-mail-sync` and `lei export-kw`
with various combinations of options, but nothing is updating the
Maildir. I thought that at least one of these commands would update the
matching emails with an "X-Label: git-unit-tests" header, although now I
can't find any reference to X-Label in the lei docs, so I probably
confused myself somehow about that.


I *can* get lei-q to write these matching emails to a separate Maildir
using `lei q -o /tmp/git-unit-tests dfn:t/unit-tests ...`, but this
workflow is more annoying than I'd hoped for, as metadata is not
automatically synced between the various Maildirs, and it's a bit slower
in Mutt to switch Maildirs than to filter the currently open one.

So to repeat my original question, is there any way to get lei to
somehow update the source Maildir to reflect the labels on these tagged
messages?

Thanks in advance for any advice,
Josh

             reply	other threads:[~2024-01-24 22:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 22:51 Josh Steadmon [this message]
2024-01-25  0:26 ` How do I write labels back to the source Maildir? Eric Wong
2024-01-29 21:31   ` Josh Steadmon

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://public-inbox.org/README

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

  git send-email \
    --in-reply-to=ZbGUWGw6DEGf3Ufp@google.com \
    --to=steadmon@google.com \
    --cc=meta@public-inbox.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://80x24.org/public-inbox.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).