Giter Club home page Giter Club logo

afew's Introduction

afew

GithubTag TravisStatus

About

afew is an initial tagging script for notmuch mail:

Its basic task is to provide automatic tagging each time new mail is registered with notmuch. In a classic setup, you might call it after 'notmuch new' in an offlineimap post sync hook.

It can do basic thing such as adding tags based on email headers or maildir folders, handling killed threads and spam.

In move mode, afew will move mails between maildir folders according to configurable rules that can contain arbitrary notmuch queries to match against any searchable attributes.

fyi: afew plays nicely with alot, a GUI for notmuch mail ;)

Current NEWS

afew is quite young, so expect a few user visible API or configuration format changes, though I'll try to minimize such disruptive events.

Please keep an eye on NEWS.md for important news.

Also, feel free to ask your questions and discuss usage in the [#afewmail IRC Channel](http://webchat.freenode.net/?channels=#afewmail) on freenode.

Features

  • spam handling (flush all tags, add spam)
  • killed thread handling
  • tags posts to lists with lists, $list-id
  • autoarchives mails sent from you
  • catchall -> remove new, add inbox
  • can operate on new messages [default], --all messages or on custom query results
  • can move mails based on arbitrary notmuch queries, so your sorting may show on your traditional mail client (well, almost ;))
  • has a --dry-run mode for safe testing
  • works with python 2.7, 3.1 and 3.2

Installation

Make sure you have already installed your distributions notmuch package, and the notmuch python bindings, which might come in separate python-notmuch and python3-notmuch packages.

It is recommended to install afew itself inside a virtualenv as an unprivileged user, either via checking out the source code and installing via setup.py, or via pip.

# create and activate virtualenv
$ python -m venv --system-site-packages .venv
$ source .venv/bin/activate

# install via pip from PyPI:
$ pip install afew

# or install from source:
$ python setup.py install

You might want to symlink .venv/bin/afew somewhere inside your path (~/bin/ in this case):

Configuration

Make sure that ~/.notmuch-config reads:

[new]
tags=new

Put a list of filters into ~/.config/afew/config:

# This is the default filter chain
[SpamFilter]
[KillThreadsFilter]
[ListMailsFilter]
[ArchiveSentMailsFilter]
[InboxFilter]

And configure rules to sort mails on your disk, if you want:

[MailMover]
folders = INBOX Junk
max_age = 15

# rules
INBOX = 'tag:spam':Junk 'NOT tag:inbox':Archive
Junk = 'NOT tag:spam AND tag:inbox':INBOX 'NOT tag:spam':Archive

Commandline help

$ afew --help
Usage: afew [options] [--] [query]

Options:
  -h, --help            show this help message and exit

  Actions:
    Please specify exactly one action.

    -t, --tag           run the tag filters
    -m, --move-mails    move mail files between maildir folders

  Query modifiers:
    Please specify either --all or --new or a query string.

    -a, --all           operate on all messages
    -n, --new           operate on all new messages

  General options:
    -C NOTMUCH_CONFIG, --notmuch-config=NOTMUCH_CONFIG
                        path to the notmuch configuration file [default:
                        $NOTMUCH_CONFIG or ~/.notmuch-config]
    -e ENABLE_FILTERS, --enable-filters=ENABLE_FILTERS
                        filter classes to use, separated by ',' [default:
                        filters specified in afew's config]
    -d, --dry-run       don't change the db [default: False]
    -R REFERENCE_SET_SIZE, --reference-set-size=REFERENCE_SET_SIZE
                        size of the reference set [default: 1000]
    -T DAYS, --reference-set-timeframe=DAYS
                        do not use mails older than DAYS days [default: 30]
    -v, --verbose       be more verbose, can be given multiple times

Boring stuff

Simulation

Adding --dry-run to any --tag or --sync-tags action prevents modification of the notmuch db. Add some -vv goodness to see some action.

Initial tagging

Basic tagging stuff requires no configuration, just run

$ afew --tag --new

To do this automatically you can add the following hook into your ~/.offlineimaprc:

Tag filters

Tag filters are plugin-like modules that encapsulate tagging functionality. There is a filter that handles the archiving of mails you sent, one that handles spam, one for killed threads, one for mailing list magic...

The tag filter concept allows you to easily extend afew's tagging abilities by writing your own filters. Take a look at the default configuration file (afew/defaults/afew.config) for a list of available filters and how to enable filters and create customized filter types.

Move mode

To invoke afew in move mode, provide the --move-mails option on the command line. Move mode will respect --dry-run, so throw in --verbose and watch what effects a real run would have.

In move mode, afew will check all mails (or only recent ones) in the configured maildir folders, deciding whether they should be moved to another folder.

The decision is based on rules defined in your config file. A rule is bound to a source folder and specifies a target folder into which a mail will be moved that is matched by an associated query.

This way you will be able to transfer your sorting principles roughly to the classic folder based maildir structure understood by your traditional mail server. Tag your mails with notmuch, call afew --move-mails in an offlineimap presynchook and enjoy a clean inbox in your webinterface/GUI-client at work.

For information on how to configure rules for move mode, what you can do with it and what you can't, please refer to docs/move_mode.

Have fun :)

afew's People

Contributors

0x64746b avatar guillaumeseren avatar flokli avatar pazz avatar larsks avatar do3cc avatar aidecoe avatar foobacca avatar lucc avatar larkery avatar wyleyr avatar silbe avatar chrisfleming avatar twopir avatar kaisforza avatar mineo avatar khinsen avatar adimasci avatar andir avatar ankurdave avatar xunam avatar insanum avatar gauteh avatar kyrias avatar nyergler avatar pablooliveira avatar tohojo avatar mmirate avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.