Skip to content

Need option to disable copying per multi-match in MailMover #242

Open
@amerlyq

Description

Copying mails matching multiple queries is supposed to be killer feature, but it creates too much frustration for me. In my setup I manage every action-item in =INBOX and expect auto-archiving of full threads, when I remove unread and flagged tags from ALL mails in these threads.
This is what I have configured in notmuch:

$ notmuch config list
...
maildir.synchronize_flags=true
index.header.List=List-Id
index.header.To=To
query.abandoned=folder:INBOX AND NOT query:important
query.concluded=query:abandoned AND query:sentreply
query.idontcare=query:abandoned AND NOT query:sentreply
query.important=thread:"{folder:INBOX AND (tag:unread OR tag:flagged)}"
query.sentreply=thread:"{folder:INBOX AND tag:replied}"

And that's how I'm forced to use it in afew:

INBOX =
  'NOT tag:flagged AND tag:log':log
  'NOT tag:flagged AND NOT tag:log AND tag:spam':spam
  'query:abandoned AND NOT (tag:log OR tag:spam) AND thread:"{folder:INBOX AND tag:my}"':my
  'query:abandoned AND NOT (tag:log OR tag:spam OR thread:"{folder:INBOX AND tag:my}") AND tag:info':info
  'query:abandoned AND NOT (tag:log OR tag:spam OR thread:"{folder:INBOX AND tag:my}" OR tag:info) AND thread:"{folder:INBOX AND tag:org}"':org
  'query:abandoned AND NOT (tag:log OR tag:spam OR thread:"{folder:INBOX AND tag:my}" OR tag:info OR thread:"{folder:INBOX AND tag:org}") AND tag:junk':junk
  'query:abandoned AND NOT (tag:junk OR thread:"{folder:INBOX AND tag:my}" OR tag:info OR thread:"{folder:INBOX AND tag:org}") AND query:sentreply':work
  'query:abandoned AND NOT (tag:junk OR thread:"{folder:INBOX AND tag:my}" OR tag:info OR thread:"{folder:INBOX AND tag:org}" OR query:sentreply)':dontcare

log =
  'tag:build':log.build
  'tag:maint':log.maint
  'tag:report':log.report
  'from:jira':log.jira
  'from:confluence':log.confl
  'from:stash':log.stash

As you can see -- it's a hellish labour to ensure all tags are independent.
I want option to disable copying messages into two matching locations -- and apply rules line by line.
So I could simplify query to simply:

INBOX =
  'tag:flagged OR NOT query:abandoned':INBOX
  'tag:log':log
  'tag:spam':spam
  'thread:"{folder:INBOX AND tag:my}"':my
  'tag:info':info
  'thread:"{folder:INBOX AND tag:org}"':org
  'tag:junk':junk
  'query:sentreply':work
  '*':dontcare

To implement this, afew must shadow select emails to automatically prevent considering them for next query automatically. Or simply execute each line one by one and immediately move messages and update notmuch db -- to prevent next line matching already moved messages.

Alternative variant, to accomodate both worlds -- copying and not -- expects to extend config format -- so queries inside single assignments will copy, but next assignments will be executed only after full DB sync.
I.e. first query allows copying, but next one will work with clean state after first completes.

INBOX =
  'tag:log':log
  'tag:spam':spam

INBOX = 'thread:"{folder:INBOX AND tag:my}"':my
INBOX = 'tag:info':info
INBOX = 'thread:"{folder:INBOX AND tag:org}"':org
INBOX = 'tag:junk':junk
INBOX = 'query:sentreply':work
INBOX = '*':dontcare

It's a pity, that you can't have same key multiple times in config.

What can we do to achieve desired option?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions