unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Emmanuel Beffara <manu@beffara.org>
To: notmuch@notmuchmail.org
Subject: tagging moved messages
Date: Sat, 19 May 2012 17:40:43 +0200	[thread overview]
Message-ID: <20120519154043.GA7220@chantourne> (raw)

Hello,

What would be the proper way of automatically tagging messages whose
file has been renamed?

My use case is the following:

In order to have some synchronization of tags between several machines,
I use folders on the IMAP server. The idea is simply that messages
tagged "foo" are actually moved to a folder "foo". The same applies to
the "inbox" tag, and as an exception, messages in a folder named "saved"
are those with no tags. Of course this excludes having several tags on a
given message (except for the special tags like "unread" and "signed"),
but it does fit my needs for now. The post-new hook says this:

    #!/bin/sh
    for FOLDER in *
    do
        case $FOLDER in
        INBOX) TAG=inbox ;;
        Drafts) TAG=draft ;;
        Trash) TAG=killed ;;
        saved) continue ;;
        *) TAG=$FOLDER
        esac
        notmuch tag -$TAG -- tag:$TAG not folder:$FOLDER
        notmuch tag +$TAG -- folder:$FOLDER not tag:$TAG
    done

It does work but it is rather slow: 8 seconds, for a collection of 16000
messages. I can live with that but it does involve browsing the whole
collection for each tag. Having a tag on all moved messages, like for
the new ones, would dramatically improve this process.

Besides, the "folder:" prefix is not an exact search, so the above does
not work well if one folder name is part of another, like if I had a
folder "bar" and a folder "foo.bar". Is there a way around this?

I have another script called "pre-sync" that moves messages to folders
according to their tags. This one is called before offlineimap does the
full actual synchronization (calling notmuch new after that).

I welcome any comments on my usage pattern, as there may well be better
approaches I didn't think of...

-- 
Emmanuel

                 reply	other threads:[~2012-05-19 15:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120519154043.GA7220@chantourne \
    --to=manu@beffara.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).