Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amerlyq opened this issue Aug 12, 2019 · 4 comments
Open

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

amerlyq opened this issue Aug 12, 2019 · 4 comments

Comments

@amerlyq
Copy link

amerlyq commented Aug 12, 2019

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?

@GuillaumeSeren
Copy link
Collaborator

GuillaumeSeren commented Aug 16, 2019

Hey,

Yes I use it mostly to move, according to the tag of a message (unread, spam, archived) and to sync its state to the imap server, its been in a refactoring discussion for some time now, so ideas and patches are welcome.

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.

You can do that by using more precise query, as you are showing at the begin at the beginning,
I use a similar logic on my side:

Mail/INBOX = 'tag:spam':Mail/spam 'tag:sent':Mail/sent
Mail/archive = 'tag:':Mail/INBOX 'tag:spam':Mail/spam 'tag:sent':Mail/sent
Mail/spam = 'NOT tag:spam':Mail/INBOX 'tag:sent':Mail/sent
Mail/sent = 'NOT tag:sent':Mail/INBOX 'tag:spam':Mail/spam

Or simply execute each line one by one and immediately move messages and update notmuch db -- to prevent next line matching already moved messages.

This is actually the behavior of the proposal I've made for the mailmover(#189), feel
free to test it but it is the same idea move one bye one and update db.

@amerlyq
Copy link
Author

amerlyq commented Aug 16, 2019

You can do that by using more precise query
I use a similar logic on my side

Exactly, still your example still lacks a little to showcase the scale of the problem :)

I had seen #189 but it isn't obvious from description if it allows to accomplish what I thought for.
I will trust your words. Hey, @flokli , @andir -- can we restart integration work for #189 -- after all more than year had passed from the time its changes were almost approved?

@amerlyq
Copy link
Author

amerlyq commented Dec 4, 2019

I see some huge activity in commits history.
Does any of newly introduced changes address the issue at least laterally?

@flokli
Copy link
Member

flokli commented Dec 4, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants