unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Carl Worth <cworth@cworth.org>
To: Michiel Buddingh' <michiel@michielbuddingh.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH] notmuch: Add Maildir directory name as tag name for messages
Date: Wed, 25 Nov 2009 09:52:00 -0800	[thread overview]
Message-ID: <87skc23327.fsf@yoom.home.cworth.org> (raw)
In-Reply-To: <9bfdedddeab9c58cd45d8d448323d0fc@localhost>

On Sun, 22 Nov 2009 10:33:53 +0100, Michiel Buddingh' <michiel@michielbuddingh.net> wrote:
> On the positive side, this allows us to map these flags onto tags,
> at least for indexing (the patch at the bottom implements this), and,
> if I can pry you away from your principles, later for modification
> as well.

Hi Michiel,

I'm finally getting around to reviewing this patch. I think the
functionality of respecting these maildir flags for initial import is
going to be really important. So thanks for looking at this!

Some comments on the patches below.

> +enum storage_type
> +notmuch_config_get_storage_type (notmuch_config_t *config);
> +
>  notmuch_bool_t
>  debugger_is_active (void);
>  
> +
> +
> +
>  #endif

[nit] Try to look out for introducing excess whitespace like that.

> +    " The other value is 'storage_type', which can currently be set to\n"
> +    " 'maildir' or 'none'.\n";

This part of the patch I don't like. I've got a mail collection spanning
over a decade, and it's seen a lot of strange things. Most of my mail is
in maildir format, but not quite all of it. And I actually like the
ability to just shove random new messages into the mail store manually
without having to create a maildir name for it.

So I don't think a global configuration makes sense here. Meanwhile,
it's really easy to detect the presence of a maildir. Whenever we see
child directories of "cur", "new", and "tmp" then we should turn on the
processing of maildir flags for when processing mail in "cur" and "new".

> @@ -257,7 +262,7 @@ notmuch_config_open (void *ctx,
>  	    talloc_free (email);
>  	}
>      }
> -
> +    
>      /* When we create a new configuration file here, we  add some
>       * comments to help the user understand what can be done. */
>      if (is_new) {

[nit] Trailing whitespace inserted there as well.

Hmm... I was going to say that git ships with a pre-commit hook you can
turn on that checks for trailing whitespace and aborts the commit if
it's present. But it looks like the currently shipping pre-commit.sample
hook doesn't do this anymore. So I'll have to find out what the current
recommended way is to get this behavior. Does anybody here know?

> +	i += 3;
> +	for (; i < (path + l) && !end_of_flags; i++) {
> +	    switch (*i) {
> +	    case 'F': /* flagged */
> +		notmuch_message_add_tag (message, "flagged");
> +		break;
> +	    case 'R': /* the message has been replied to */
> +		notmuch_message_add_tag (message, "replied");
> +		break;
> +	    case 'D': 
> +		notmuch_message_add_tag (message, "draft");
> +		break;
> +	    case 'S': /* Indicate a message has been read */
> +		notmuch_message_add_tag (message, "seen");
> +		seen = TRUE;
> +		break;
> +	    case 'T': /* Indicates a message has been marked as trash */
> +		notmuch_message_add_tag (message, "trashed");
> +		break;
> +	    case 'P': /* indicates a message has been forwarded */
> +		notmuch_message_add_tag (message, "passed");
> +		break;
> +	    default:
> +		end_of_flags = TRUE;
> +		break;
> +	    }
> +	}
> +    }
> +    
> +    if (i == NULL || !seen) { 
> +	/* mark messages without any flags, or the seen flag as 'unseen' */
> +	notmuch_message_add_tag (message, "unseen");
> +    }

OK, now we're into the meat of things. Clearly, you're directly
supporting the documented flags of maildir. But we need to do a few
things differently here. Most importantly, notmuch is already using an
"unread" tag, so maildir's S flag should map that *that* rather than
adding new "unseen" and "seen" flags. So messages with the S flag would
not get the "unread" tag and messages without S would get the "unread"
tag.

The "flagged" and "replied" tags seem reasonable enough. But for
"trashed" and "passed" I think I'd rather see the tag names as "deleted"
and "forwarded". (Since I can imagine adding commands to notmuch for
"delete" and "forward" but not for "trash" nor "pass").

Finally, all of the new behavior here needs to be documented in both
notmuch.1 and notmuch.c where the current behavior with respect to
"inbox" and "unread" is already documented.

Oh, and setting the "inbox" tag correctly here based on the maildir tags
is the final and most important thing. It looks like that's missing from
the above. So, a missing "S" flag should map to adding both the "inbox"
and "unread" tags.

> (state->ignore_read_only_directories)) {
>  	state->saw_read_only_directory = TRUE;
> -	goto DONE;
> +	goto DONE;	    
>      }

Trailing whitespace strikes again! :-)


> +	    if (state->storage_type == MAILDIR) {
> +		char * leaf = basename(next);

You could save the basename call by examining the leaf name when it is
available as a standalone string up in the caller.

So this patch is close, but needs a few fixes.

Thanks again,

-Carl

  parent reply	other threads:[~2009-11-25 17:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18 15:55 [PATCH] notmuch: Add Maildir directory name as tag name for messages Aneesh Kumar K.V
2009-11-21 18:39 ` Carl Worth
2009-11-21 20:28   ` Carl Worth
2009-11-21 22:12     ` Bart Trojanowski
     [not found]       ` <9cce5525b093b87fe74d427954ffad89@localhost>
2009-11-22  4:04         ` Carl Worth
2009-11-22  9:33           ` Michiel Buddingh'
2009-11-22 10:57             ` Dirk-Jan C. Binnema
2009-11-22 16:00               ` Michiel Buddingh'
2009-11-22 21:44                 ` Dirk-Jan C. Binnema
2009-11-22 12:19             ` Carl Worth
2009-11-22 15:57               ` Michiel Buddingh'
2009-11-25 17:52             ` Carl Worth [this message]
2009-11-26 21:12               ` Michiel Buddingh'
2009-11-26 21:53                 ` Ingmar Vanhassel
2009-11-27 12:01                   ` Jan Janak
2009-11-28  3:26                 ` Carl Worth
2009-12-06 19:55                   ` Michiel Buddingh'
2010-02-10  3:13                     ` [PATCH] notmuch: Respect maildir message flags Tim Stoakes
2010-02-15  8:13                       ` Stewart Smith
2010-02-16  1:58                         ` Stewart Smith
2010-02-16  2:12                           ` martin f krafft
2010-02-16  2:21                             ` Stewart Smith
2010-02-16  4:21                               ` martin f krafft
2010-02-16  9:35                               ` Michal Sojka
2010-03-01 13:28                               ` [PATCH] notmuch-new: Respect maildir flags when importing a new message Sebastian Spaeth
2010-04-07 21:16                                 ` Carl Worth
2010-04-08 12:57                                   ` Michal Sojka
2009-11-22 10:37           ` [PATCH] notmuch: Add Maildir directory name as tag name for messages Dirk-Jan C. Binnema

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=87skc23327.fsf@yoom.home.cworth.org \
    --to=cworth@cworth.org \
    --cc=michiel@michielbuddingh.net \
    --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).