Re: [notmuch] [PATCH] notmuch: Add Maildir directory name as tag name for messages
authorMichiel Buddingh' <michiel@michielbuddingh.net>
Thu, 26 Nov 2009 21:12:02 +0000 (22:12 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:44 +0000 (09:35 -0800)
03/3a24970fce43fafd9d6e43bd4dd09ef47fb128 [new file with mode: 0644]

diff --git a/03/3a24970fce43fafd9d6e43bd4dd09ef47fb128 b/03/3a24970fce43fafd9d6e43bd4dd09ef47fb128
new file mode 100644 (file)
index 0000000..5084d0b
--- /dev/null
@@ -0,0 +1,158 @@
+Return-Path: <michiel@michielbuddingh.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C0A8F431FC0\r
+       for <notmuch@notmuchmail.org>; Thu, 26 Nov 2009 13:12:02 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id O36BZb+Q8qNm for <notmuch@notmuchmail.org>;\r
+       Thu, 26 Nov 2009 13:12:01 -0800 (PST)\r
+Received: from aegir.org.uk (aegir.org.uk [87.238.170.13])\r
+       by olra.theworths.org (Postfix) with ESMTP id 96D1F431FBC\r
+       for <notmuch@notmuchmail.org>; Thu, 26 Nov 2009 13:12:01 -0800 (PST)\r
+Received: from localhost.localdomain (109-9-ftth.onsnetstudenten.nl\r
+       [145.120.9.109])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by aegir.org.uk (Postfix) with ESMTPSA id 842BB2E04E;\r
+       Thu, 26 Nov 2009 22:12:00 +0100 (CET)\r
+Date: Thu, 26 Nov 2009 22:12:02 +0100\r
+From: Michiel Buddingh' <michiel@michielbuddingh.net>\r
+To: notmuch@notmuchmail.org, cworth@cworth.org\r
+Message-ID: <4b0eef22.JwxdgTGElffx149F%michiel@michielbuddingh.net>\r
+References: <87fx8bygi7.fsf@linux.vnet.ibm.com>\r
+       <87bpiv4t9h.fsf@yoom.home.cworth.org>\r
+       <87y6lz39nd.fsf@yoom.home.cworth.org>\r
+       <20091121221207.GB17268@jukie.net>\r
+       <9cce5525b093b87fe74d427954ffad89@localhost>\r
+       <87d43b2oif.fsf@yoom.home.cworth.org>\r
+       <9bfdedddeab9c58cd45d8d448323d0fc@localhost>\r
+       <87skc23327.fsf@yoom.home.cworth.org>\r
+In-Reply-To: <87skc23327.fsf@yoom.home.cworth.org>\r
+User-Agent: Heirloom mailx 12.4 7/29/08\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Transfer-Encoding: 7bit\r
+Subject: Re: [notmuch] [PATCH] notmuch: Add Maildir directory name as tag\r
+       name for messages\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 26 Nov 2009 21:12:03 -0000\r
+\r
+Carl Worth <cworth@cworth.org> wrote:\r
+> > +    " The other value is 'storage_type', which can currently be set to\n"\r
+> > +    " 'maildir' or 'none'.\n";\r
+>\r
+> This part of the patch I don't like. I've got a mail collection spanning\r
+> over a decade, and it's seen a lot of strange things. Most of my mail is\r
+> in maildir format, but not quite all of it. And I actually like the\r
+> ability to just shove random new messages into the mail store manually\r
+> without having to create a maildir name for it.\r
+>\r
+> So I don't think a global configuration makes sense here. Meanwhile,\r
+> it's really easy to detect the presence of a maildir. Whenever we see\r
+> child directories of "cur", "new", and "tmp" then we should turn on the\r
+> processing of maildir flags for when processing mail in "cur" and "new".\r
+\r
+  I considered that approach; ideally, we could test for the presence of\r
+all three of cur, tmp and new--but this is rather messy to do in the\r
+current treewalk structure.  Taking any one of them as proof positive of\r
+a Maildir might lead to unpleasant surprises--it's not all that incon-\r
+ceivable for someone to name a mail folder 'tmp'.\r
+\r
+  There's another matter; Some mail stores will place (large) index files\r
+in folder roots, i.e. one level above cur/, tmp/ and new/.  Looking\r
+at the ones dovecot (an IMAP server) uses, I can make out a from header,\r
+a subject header, and a message-id, as plaintext in the first 100k or\r
+so.  It's not all that inconceivable that notmuch might register it as\r
+a 'real' email, with unpleasant consequences for the index.\r
+\r
+  I've seen some patches fly by that add support for multiple mail\r
+stores.  Turning on Maildir support on a per-directory basis might\r
+resolve that problem while still supporting heterogenous mail archives\r
+to some degree.  I am not convinced we can do the right thing\r
+automatically without causing some grief to a subset of users.\r
+\r
+> > @@ -257,7 +262,7 @@ notmuch_config_open (void *ctx,\r
+> >        talloc_free (email);\r
+> >    }\r
+> >      }\r
+> > -\r
+> > +    \r
+> >      /* When we create a new configuration file here, we  add some\r
+> >       * comments to help the user understand what can be done. */\r
+> >      if (is_new) {\r
+>\r
+> [nit] Trailing whitespace inserted there as well.\r
+\r
+> Hmm... I was going to say that git ships with a pre-commit hook you can\r
+> turn on that checks for trailing whitespace and aborts the commit if\r
+> it's present. But it looks like the currently shipping pre-commit.sample\r
+> hook doesn't do this anymore.\r
+\r
+Haven't tested it, but it seems you can put\r
+\r
+[core]\r
+    whitespace = trailing-space,space-before-tab\r
+\r
+into your ~/.gitconfig now.  I've also set emacs to mark trailing\r
+whitespace with big red markers.\r
+\r
+> OK, now we're into the meat of things. Clearly, you're directly\r
+> supporting the documented flags of maildir. But we need to do a few\r
+> things differently here. Most importantly, notmuch is already using an\r
+> "unread" tag, so maildir's S flag should map that *that* rather than\r
+> adding new "unseen" and "seen" flags. So messages with the S flag would\r
+> not get the "unread" tag and messages without S would get the "unread"\r
+> tag.\r
+\r
+When writing the patch, I assumed there might be a minor (but important)\r
+distinction between marking a mail 'seen' (i.e. the MUA storing the fact\r
+that the file has been visited) and 'read' (i.e. the user marking the\r
+contents of a mail as being read and understood).  As I found out later,\r
+notmuch's interpretation of 'read' and 'unread' is the former, so there\r
+is no distinction.\r
+\r
+> The "flagged" and "replied" tags seem reasonable enough. But for\r
+> "trashed" and "passed" I think I'd rather see the tag names as "deleted"\r
+> and "forwarded". (Since I can imagine adding commands to notmuch for\r
+> "delete" and "forward" but not for "trash" nor "pass").\r
+\r
+Fair enough.\r
+\r
+> Oh, and setting the "inbox" tag correctly here based on the maildir tags\r
+> is the final and most important thing. It looks like that's missing from\r
+> the above. So, a missing "S" flag should map to adding both the "inbox"\r
+> and "unread" tags.\r
+\r
+Makes sense, will do.\r
+\r
+> > +      if (state->storage_type == MAILDIR) {\r
+> > +          char * leaf = basename(next);\r
+>\r
+> You could save the basename call by examining the leaf name when it is\r
+> available as a standalone string up in the caller.\r
+\r
+Which would require testing with S_ISDIR twice, which is uglier, but\r
+essentially free, so I'll grant it's the better thing to do.\r
+\r
+> So this patch is close, but needs a few fixes.\r
+\r
+I'll be happy to implement them, although I'd like for others to chime\r
+in on the configure-as-Maildir vs. autodetect-Maildir issue.  And thanks\r
+for your patience in working through my patch.\r
+\r
+-- \r
+Michiel Buddingh'\r