afewmail / afew

an initial tagging script for notmuch mail
ISC License
325 stars 97 forks source link

make afew idempotent #308

Open xaltsc opened 2 years ago

xaltsc commented 2 years ago

One of the most annoying aspects of afew for me is that it requires several runs to get the desired tags attached to mails or to get mails moved to the right folder.

As a feature, I believe afew should achieve two/three goals, both being rather rewriting-theoretic.

  1. Being able to detect if the tagging process/configuration is "well-behaved", i.e. convergent, i.e. the rewriting directed graph does not contain any cycle, i.e. exists only one normal form (on the commutative monoid generated by the possible tags).
  2. When the configuration is well-behaved, achieve the final step in one run only.
  3. When the configuration is well-behaved, "compile" it to a better configuration that is both legible and is the identity on a second run.

I think that the hardest part of achieving this is to take Python filters into account, but this may be dismissed in the first approach, since this may require some changes in the API and break stuff.

I may task myself to submit a PR for that in the (hopefully near) future, I had discussed about that with @GuillaumeSeren on the IRC channel in Spring 2020, but any help, remarks, whatever kind of input is very much welcome.

GuillaumeSeren commented 2 years ago

Hey @xaltsc I remember you !

  1. Being able to detect if the tagging process/configuration is "well-behaved", i.e. convergent, i.e. the rewriting directed graph does not contain any cycle, i.e. exists only one normal form (on the commutative monoid generated by the possible tags).
  2. When the configuration is well-behaved, achieve the final step in one run only.
  3. When the configuration is well-behaved, "compile" it to a better configuration that is both legible and is the identity on a second run.

I like challenge too so if I can help having this done would be awesome, but it may be quite a long shot to go from the actual code to this.

I think the first part like calculating the expected state may be doable without rewriting everything.