From ab3bf2e7da31d3d38e3defc0cacd8658353da7d7 Mon Sep 17 00:00:00 2001 From: Emmanuel Beffara Date: Sat, 19 May 2012 17:40:43 +0200 Subject: [PATCH] tagging moved messages --- 4a/719a6a665341b3b75ccbe7edc6bf870fb0c0d7 | 102 ++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 4a/719a6a665341b3b75ccbe7edc6bf870fb0c0d7 diff --git a/4a/719a6a665341b3b75ccbe7edc6bf870fb0c0d7 b/4a/719a6a665341b3b75ccbe7edc6bf870fb0c0d7 new file mode 100644 index 000000000..9917850c5 --- /dev/null +++ b/4a/719a6a665341b3b75ccbe7edc6bf870fb0c0d7 @@ -0,0 +1,102 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 6E2DD431FB6 + for ; Sat, 19 May 2012 08:49:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id WpgvgbkTOF+F for ; + Sat, 19 May 2012 08:49:19 -0700 (PDT) +X-Greylist: delayed 557 seconds by postgrey-1.32 at olra; + Sat, 19 May 2012 08:49:19 PDT +Received: from smtp.univmed.fr (smtp.univmed.fr [139.124.132.70]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id B14B3431FAE + for ; Sat, 19 May 2012 08:49:19 -0700 (PDT) +Received: from localhost (dra13-2-82-237-244-11.fbx.proxad.net + [82.237.244.11]) by smtp.univmed.fr (Postfix) with ESMTPSA id 52C7D2003E; + Sat, 19 May 2012 17:39:59 +0200 (CEST) +Date: Sat, 19 May 2012 17:40:43 +0200 +From: Emmanuel Beffara +To: notmuch@notmuchmail.org +Subject: tagging moved messages +Message-ID: <20120519154043.GA7220@chantourne> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Miltered: at smtp.univmed.fr with ID 4FB7BECF.000 by Joe's j-chkmail (http : + // j-chkmail dot ensmp dot fr)! +X-j-chkmail-Enveloppe: 4FB7BECF.000/82.237.244.11/dra13-2-82-237-244-11.fbx.proxad.net/localhost/ +X-j-chkmail-Score: MSGID : 4FB7BECF.000 on smtp.univmed.fr : j-chkmail score : + . : R=. U=. O=## B=0.010 -> S=0.016 +X-j-chkmail-Status: Ham +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 19 May 2012 15:49:20 -0000 + +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 -- 2.26.2