I would like to propose that we make the list of tags applied by 'notmuch new' configurable. Right now notmuch applies two tags to all new messages added to the database, 'inbox' and 'unread'. The two tags are added by the C code in notmuch-new.c and they cannot be changed without editing the source file and recompiling notmuch.
The four patches that follow this email allow for configuring the tags to be added by 'notmuch new' either in the configuration file or on the command line. This change was motivated by my desire to remove both tags from newly added messages. My rules for adding these two tags are more complex and I do it in a script run after 'notmuch new'. Instead of 'inbox' and 'unread', I configure 'notmuch new' to add a new tag called 'new' (and only that one). This tag marks newly added messages that haven't been properly tagged yet by my auto-tagging scripts. The last script I run after 'notmuch new' removes that tag. My auto-tagging scripts process only messages with the tag 'new'. On a side note; It may seem logical to add/omit the tag 'unread' directly in 'notmuch new' based on the Maildir flags extracted from the filename of the message. I suggest that we don't do that in 'notmuch new'. A better way would be writing a small script or command that can be run *after* 'notmuch new'. We could then distribute it with notmuch (maybe with other small tagging scripts for common situations). I think Maildir flags should be processed after 'notmuch new' is because if there are multiple copies of a message with different flags, we may need to see all flags from all filenames to set corresponding tags properly and we may also need to take the directory part into consideration (i.e. the new mail is in 'new', not 'cur'). The list of tags to be applied by notmuch can be configured in the configuration file. There is a new section [new] which contains configuration options for 'notmuch new'. There is only one option called 'tags'. The option contains a semicolon separated list of tags: [new] tags=inbox;unread # Emulate the original behavior One of the patches updates 'notmuch setup' to create the section and add the tags option with tags 'inbox' and 'unread', but only if a new configuration file is being created. If the configuration file already exists then it just copies the contents from the old configuration file to the new one. We do not ask the user for the list of tags in the interactive part, that would have been too much. Users can edit the configuration file manually if they want to change the list of tags. If they create a new configuration file then they probably want to accept the default anyway. There is one catch for users who already have a configuration file and start using the patches. They will need to add the new section and the tags option manually if they want to preserve current behavior of applying 'inbox' and 'unread' automatically by 'notmuch new'. The last patch in the set adds a new command line option to 'notmuch new'. The name of the option is --tag and it can be used to override any tags configured in the configuration file. For example: notmuch new --tag=outbox --tag=read adds the tags 'outbox' and 'read' and ignores any tags from the configuration file. Comments and opinions are welcome! -- Jan