unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Louis Rilling <l.rilling@av7.net>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH 2/2] tags_to_maildir_flags: Don't rename if no flags change
Date: Mon, 11 Jul 2011 16:07:12 -0400	[thread overview]
Message-ID: <20110711200712.GB25558@mit.edu> (raw)
In-Reply-To: <1310394978-11883-3-git-send-email-l.rilling@av7.net>

I worry that this may compound the confusion caused by mutt's handling
of the new flag, but I suppose people aren't likely to manipulate any
of the other maildir-synchronized flags without also marking the
message as seen.  At any rate, the change is certainly correct
technically.  A few nits below.

Quoth Louis Rilling on Jul 11 at  4:36 pm:
> notmuch_message_tags_to_maildir_flags() unconditionally moves messages from
> maildir directory "new/" to maildir directory "cur/", which makes messages lose
> their "new" status in the MUA. However some users want to keep this "new"
> status after, for instance, an auto-tagging of new messages.
> 
> However, as Austin mentioned and according to the maildir specification,
> messages living in "new/" are not allowed to have flags, even if mutt allows it
> to happen. For this reason, this patch prevents moving messages from "new/" to
> "cur/", only if no flags have to be changed. It's hopefully enough to satisfy
> mutt (and maybe other MUAs showing the "new" status) users checking the "new"
> status.
> 
> Signed-off-by: Louis Rilling <l.rilling@av7.net>
> ---
>  lib/message.cc |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/message.cc b/lib/message.cc
> index 64b6cf8..131d99b 100644
> --- a/lib/message.cc
> +++ b/lib/message.cc
> @@ -1139,7 +1139,7 @@ _get_maildir_flag_actions (notmuch_message_t *message,
>   * compute the new maildir filename.
>   *
>   * If the existing filename is in the directory "new", the new
> - * filename will be in the directory "cur".
> + * filename will be in the directory "cur", unless no flags are changed.
>   *
>   * After a sequence of ":2," in the filename, any subsequent
>   * single-character flags will be added or removed according to the
> @@ -1162,6 +1162,7 @@ _new_maildir_filename (void *ctx,
>      char *filename_new, *dir;
>      char flag_map[128];
>      int flags_in_map = 0;
> +    bool flags_changed = false;

The convention in notmuch is to use notmuch_bool_t, TRUE, and FALSE
(though, admittedly, I don't know why; avoiding C99-isms?)

>      unsigned int i;
>      char *s;
>  
> @@ -1202,6 +1203,7 @@ _new_maildir_filename (void *ctx,
>  	if (flag_map[flag] == 0) {
>  	    flag_map[flag] = 1;
>  	    flags_in_map++;
> +	    flags_changed = true;
>  	}
>      }
>  
> @@ -1210,9 +1212,17 @@ _new_maildir_filename (void *ctx,
>  	if (flag_map[flag]) {
>  	    flag_map[flag] = 0;
>  	    flags_in_map--;
> +	    flags_changed = true;
>  	}
>      }
>  
> +    /* No need to rename. Messages in new/ can be kept in new/.
> +     * Note: We don't even try to fix buggy messages having flags and living in
> +     * new/. It's not our business.
> +     */
> +    if (!flags_changed)
> +	return NULL;
> +

NULL generally indicates an error in notmuch and is currently used
that way in _new_maildir_filename, so even though the caller currently
doesn't really care, I'd lean against overloading it to indicate that
the filename doesn't need to change.  Despite the slight inefficiency,
I would recommend returning talloc_strdup (ctx, filename).

>      filename_new = (char *) talloc_size (ctx,
>  					 info - filename +
>  					 strlen (":2,") + flags_in_map + 1);

  reply	other threads:[~2011-07-11 20:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23 15:36 [RFC][PATCH] tags_to_maildir_flags: Add option to not move messages from "new/" to "cur/" Louis Rilling
2011-06-24 15:19 ` Austin Clements
2011-06-24 20:34   ` Louis Rilling
2011-06-27 21:15     ` Carl Worth
2011-07-11 14:36       ` [PATCH 0/2] lib: Don't always move from maildir new/ to maildir cur/ Louis Rilling
2011-07-11 14:36       ` [PATCH 1/2] tags_to_maildir_flags: Cleanup double assignement Louis Rilling
2011-07-11 14:36       ` [PATCH 2/2] tags_to_maildir_flags: Don't rename if no flags change Louis Rilling
2011-07-11 20:07         ` Austin Clements [this message]
2011-07-11 22:38           ` Louis Rilling
2011-07-11 22:41             ` [PATCH v2] " Louis Rilling
2011-07-12  0:04               ` Austin Clements
2011-07-12  0:03             ` [PATCH 2/2] " Austin Clements
2011-07-12 13:47               ` Louis Rilling

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=20110711200712.GB25558@mit.edu \
    --to=amdragon@mit.edu \
    --cc=l.rilling@av7.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).