From: Jani Nikula Date: Fri, 26 Oct 2012 17:14:31 +0000 (+0300) Subject: Re: [PATCH 1/2] Automatic tagging based on maildir X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=d907c89cbd18f4526e3bdf8809d991fdf958f53f;p=notmuch-archives.git Re: [PATCH 1/2] Automatic tagging based on maildir --- diff --git a/29/c7d3a6196ee4965d743e0a70c205e93bc354a1 b/29/c7d3a6196ee4965d743e0a70c205e93bc354a1 new file mode 100644 index 000000000..1eea19436 --- /dev/null +++ b/29/c7d3a6196ee4965d743e0a70c205e93bc354a1 @@ -0,0 +1,581 @@ +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 61B72431FAF + for ; Fri, 26 Oct 2012 10:14:34 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.699 +X-Spam-Level: +X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 + tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 ZqzrwqcPbOGl for ; + Fri, 26 Oct 2012 10:14:33 -0700 (PDT) +Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com + [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id F35FC431FAE + for ; Fri, 26 Oct 2012 10:14:32 -0700 (PDT) +Received: by mail-ob0-f181.google.com with SMTP id un3so3081399obb.26 + for ; Fri, 26 Oct 2012 10:14:31 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=mime-version:in-reply-to:references:date:message-id:subject:from:to + :cc:content-type:x-gm-message-state; + bh=VP7UzhUSvG9AYMn9UO4VwqLWX8Fm/t/v0hElru5OhM8=; + b=a/wOg+d3jHke03w4CqVgBHvz8K6aizQ7ZHosGwGxEW0Ff9DOFbgvc0ax9oTOnR2YIu + yMEKwdtxJWe1S8AxxRCw52YLSZPI7gLIznydSRthh2rtyVD9AuJu1s2e/Ny3lZgxlMqh + vs4kJ7bZcgm2axyc407oloIusR6/AGDU/c2+EblZLeOJJN+3IBHum1+gS013sf4G6D+l + cLSX3dNlsQGt130VP6xY3U+Ajdp7DZnZ2xXBKzQYpJ1ZDvLDWNwVs6UE0UwCmqzutlEV + yLPpoM5Zg+vLAQe9TqQviqo0++L17OQoFKuEiWkkP9HQxzNxXbuC84e4x+hWwQRFY8Tg + HWlA== +MIME-Version: 1.0 +Received: by 10.182.31.50 with SMTP id x18mr18624613obh.56.1351271671492; Fri, + 26 Oct 2012 10:14:31 -0700 (PDT) +Received: by 10.76.69.138 with HTTP; Fri, 26 Oct 2012 10:14:31 -0700 (PDT) +Received: by 10.76.69.138 with HTTP; Fri, 26 Oct 2012 10:14:31 -0700 (PDT) +In-Reply-To: <1351208039-32293-2-git-send-email-taesoo@mit.edu> +References: <1351208039-32293-1-git-send-email-taesoo@mit.edu> + <1351208039-32293-2-git-send-email-taesoo@mit.edu> +Date: Fri, 26 Oct 2012 20:14:31 +0300 +Message-ID: + +Subject: Re: [PATCH 1/2] Automatic tagging based on maildir +From: Jani Nikula +To: Taesoo Kim +Content-Type: multipart/alternative; boundary=14dae93b56d4f9726104ccf97331 +X-Gm-Message-State: + ALoCoQnH3kjb5Z1/tHGvBcpClbYFMXaziGQxpGRpiQ8uP/LiExwoJMoYoIQu1N20oaaQerc1jbOU +Cc: notmuch@notmuchmail.org +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: Fri, 26 Oct 2012 17:14:34 -0000 + +--14dae93b56d4f9726104ccf97331 +Content-Type: text/plain; charset=UTF-8 + +On Oct 26, 2012 8:46 AM, "Taesoo Kim" wrote: +> +> Since gmail will provide labels as imap sub/folders, notmuch also can +> take advantage of labels as tags, when maildir.add_as_tag_flags is +> specified. + +Why not use the folder: prefix? What does your patch do that can't be +achieved with that? + +BR, +Jani. + +> +> Signed-off-by: Taesoo Kim +> --- +> notmuch-client.h | 7 +++++++ +> notmuch-config.c | 42 ++++++++++++++++++++++++++++++++++++++---- +> notmuch-new.c | 32 ++++++++++++++++++++++++++++++++ +> 3 files changed, 77 insertions(+), 4 deletions(-) +> +> diff --git a/notmuch-client.h b/notmuch-client.h +> index ae9344b..ce05e52 100644 +> --- a/notmuch-client.h +> +++ b/notmuch-client.h +> @@ -265,6 +265,13 @@ void +> notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config, +> notmuch_bool_t +synchronize_flags); +> +> +notmuch_bool_t +> +notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config); +> + +> +void +> +notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config, +> + notmuch_bool_t +add_as_tag_flags); +> + +> const char ** +> notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t +*length); +> +> diff --git a/notmuch-config.c b/notmuch-config.c +> index 3e37a2d..c95f9dd 100644 +> --- a/notmuch-config.c +> +++ b/notmuch-config.c +> @@ -88,7 +88,16 @@ static const char maildir_config_comment[] = +> "\n" +> "\tThe \"notmuch new\" command will notice flag changes in +filenames\n" +> "\tand update tags, while the \"notmuch tag\" and \"notmuch +restore\"\n" +> - "\tcommands will notice tag changes and update flags in filenames\n"; +> + "\tcommands will notice tag changes and update flags in filenames\n" +> + "\n" +> + "\tadd_as_tag_flags Valid values are true and false.\n" +> + "\n" +> + "\nIf ture, then add the lower-cased name of maildirs" +> + "\n(also deliminated by .) as tags" +> + "\n" +> + "\n\te.g. Life -> life" +> + "\n\te.g. MIT.CSAIL -> mit, csail" +> + "\n\te.g. Mailing.OSS.Linux -> mailing, oss, linux"; +> +> static const char search_config_comment[] = +> " Search configuration\n" +> @@ -114,6 +123,7 @@ struct _notmuch_config { +> const char **new_ignore; +> size_t new_ignore_length; +> notmuch_bool_t maildir_synchronize_flags; +> + notmuch_bool_t maildir_add_as_tag_flags; +> const char **search_exclude_tags; +> size_t search_exclude_tags_length; +> }; +> @@ -251,7 +261,7 @@ notmuch_config_open (void *ctx, +> fprintf (stderr, "Out of memory.\n"); +> return NULL; +> } +> - +> + +> talloc_set_destructor (config, notmuch_config_destructor); +> +> if (filename) { +> @@ -393,6 +403,14 @@ notmuch_config_open (void *ctx, +> g_error_free (error); +> } +> +> + config->maildir_add_as_tag_flags = +> + g_key_file_get_boolean (config->key_file, +> + "maildir", "add_as_tag_flags", &error); +> + if (error) { +> + notmuch_config_set_maildir_add_as_tag_flags (config, FALSE); +> + g_error_free (error); +> + } +> + +> /* Whenever we know of configuration sections that don't appear in +> * the configuration file, we add some comments to help the user +> * understand what can be done. */ +> @@ -438,7 +456,7 @@ notmuch_config_open (void *ctx, +> } +> +> /* Close the given notmuch_config_t object, freeing all resources. +> - * +> + * +> * Note: Any changes made to the configuration are *not* saved by this +> * function. To save changes, call notmuch_config_save before +> * notmuch_config_close. +> @@ -720,7 +738,7 @@ notmuch_config_command_get (void *ctx, char *item) +> } else if (strcmp(item, "user.other_email") == 0) { +> const char **other_email; +> size_t i, length; +> - +> + +> other_email = notmuch_config_get_user_other_email (config, +&length); +> for (i = 0; i < length; i++) +> printf ("%s\n", other_email[i]); +> @@ -891,3 +909,19 @@ notmuch_config_set_maildir_synchronize_flags +(notmuch_config_t *config, +> "maildir", "synchronize_flags", +synchronize_flags); +> config->maildir_synchronize_flags = synchronize_flags; +> } +> + +> + +> +notmuch_bool_t +> +notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config) +> +{ +> + return config->maildir_add_as_tag_flags; +> +} +> + +> +void +> +notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config, +> + notmuch_bool_t +add_as_tag_flags) +> +{ +> + g_key_file_set_boolean (config->key_file, +> + "maildir", "add_as_tag_flags", +add_as_tag_flags); +> + config->maildir_add_as_tag_flags = add_as_tag_flags; +> +} +> diff --git a/notmuch-new.c b/notmuch-new.c +> index 56c4a6f..9ec983f 100644 +> --- a/notmuch-new.c +> +++ b/notmuch-new.c +> @@ -20,6 +20,7 @@ +> +> #include "notmuch-client.h" +> +> +#include +> #include +> +> typedef struct _filename_node { +> @@ -53,6 +54,7 @@ typedef struct { +> _filename_list_t *directory_mtimes; +> +> notmuch_bool_t synchronize_flags; +> + notmuch_bool_t add_as_tag_flags; +> } add_files_state_t; +> +> static volatile sig_atomic_t do_print_progress = 0; +> @@ -240,6 +242,32 @@ _entry_in_ignore_list (const char *entry, +add_files_state_t *state) +> return FALSE; +> } +> +> +static void +> +_add_maildir_as_tag(notmuch_database_t *notmuch, +> + notmuch_message_t *msg, const char *path) +> +{ +> + char *tok = talloc_strdup (notmuch, path); +> + int len = strlen(tok); +> + +> + /* asserts path ends with /cur|/tmp|/new */ +> + if (len > 4 && tok[len - 4] == '/') { +> + char *iter = tok + len - 4; +> + *iter = '\0'; +> + while (-- iter && iter >= tok) { +> + char c = *iter; +> + if (c == '/' || c == '.') { +> + *iter = '\0'; +> + notmuch_message_add_tag (msg, iter + 1); +> + if (c == '/') { +> + break; +> + } +> + } +> + *iter = tolower(*iter); +> + } +> + } +> + talloc_free (tok); +> +} +> + +> /* Examine 'path' recursively as follows: +> * +> * o Ask the filesystem for the mtime of 'path' (fs_mtime) +> @@ -508,6 +536,9 @@ add_files (notmuch_database_t *notmuch, +> notmuch_message_freeze (message); +> for (tag=state->new_tags; *tag != NULL; tag++) +> notmuch_message_add_tag (message, *tag); +> + if (state->add_as_tag_flags == TRUE) { +> + _add_maildir_as_tag(notmuch, message, path); +> + } +> if (state->synchronize_flags == TRUE) +> notmuch_message_maildir_flags_to_tags (message); +> notmuch_message_thaw (message); +> @@ -878,6 +909,7 @@ notmuch_new_command (void *ctx, int argc, char +*argv[]) +> add_files_state.new_tags = notmuch_config_get_new_tags (config, +&add_files_state.new_tags_length); +> add_files_state.new_ignore = notmuch_config_get_new_ignore (config, +&add_files_state.new_ignore_length); +> add_files_state.synchronize_flags = +notmuch_config_get_maildir_synchronize_flags (config); +> + add_files_state.add_as_tag_flags = +notmuch_config_get_maildir_add_as_tag_flags (config); +> db_path = notmuch_config_get_database_path (config); +> +> if (run_hooks) { +> -- +> 1.8.0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch + +--14dae93b56d4f9726104ccf97331 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +


+On Oct 26, 2012 8:46 AM, "Taesoo Kim" <taesoo@mit.edu> wrote:
+>
+> Since gmail will provide labels as imap sub/folders, notmuch also can<= +br> +> take advantage of labels as tags, when maildir.add_as_tag_flags is
+> specified.

+

Why not use the folder: prefix? What does your patch do that can't b= +e achieved with that?

+

BR,
+Jani.

+

>
+> Signed-off-by: Taesoo Kim <taesoo= +@mit.edu>
+> ---
+> =C2=A0notmuch-client.h | =C2=A07 +++++++
+> =C2=A0notmuch-config.c | 42 ++++++++++++++++++++++++++++++++++++++----= +
+> =C2=A0notmuch-new.c =C2=A0 =C2=A0| 32 ++++++++++++++++++++++++++++++++= +
+> =C2=A03 files changed, 77 insertions(+), 4 deletions(-)
+>
+> diff --git a/notmuch-client.h b/notmuch-client.h
+> index ae9344b..ce05e52 100644
+> --- a/notmuch-client.h
+> +++ b/notmuch-client.h
+> @@ -265,6 +265,13 @@ void
+> =C2=A0notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *= +config,
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= +=A0 =C2=A0 =C2=A0 notmuch_bool_t synchronize_flags);
+>
+> +notmuch_bool_t
+> +notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config= +);
+> +
+> +void
+> +notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config= +,
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= +=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = +=C2=A0 =C2=A0notmuch_bool_t add_as_tag_flags);
+> +
+> =C2=A0const char **
+> =C2=A0notmuch_config_get_search_exclude_tags (notmuch_config_t *config= +, size_t *length);
+>
+> diff --git a/notmuch-config.c b/notmuch-config.c
+> index 3e37a2d..c95f9dd 100644
+> --- a/notmuch-config.c
+> +++ b/notmuch-config.c
+> @@ -88,7 +88,16 @@ static const char maildir_config_comment[] =3D
+> =C2=A0 =C2=A0 =C2=A0"\n"
+> =C2=A0 =C2=A0 =C2=A0"\tThe \"notmuch new\" command will= + notice flag changes in filenames\n"
+> =C2=A0 =C2=A0 =C2=A0"\tand update tags, while the \"notmuch = +tag\" and \"notmuch restore\"\n"
+> - =C2=A0 =C2=A0"\tcommands will notice tag changes and update fla= +gs in filenames\n";
+> + =C2=A0 =C2=A0"\tcommands will notice tag changes and update fla= +gs in filenames\n"
+> + =C2=A0 =C2=A0"\n"
+> + =C2=A0 =C2=A0"\tadd_as_tag_flags =C2=A0 =C2=A0 =C2=A0 Valid val= +ues are true and false.\n"
+> + =C2=A0 =C2=A0"\n"
+> + =C2=A0 =C2=A0"\nIf ture, then add the lower-cased name of maild= +irs"
+> + =C2=A0 =C2=A0"\n(also deliminated by .) as tags"
+> + =C2=A0 =C2=A0"\n"
+> + =C2=A0 =C2=A0"\n\te.g. Life =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = +=C2=A0 =C2=A0-> life"
+> + =C2=A0 =C2=A0"\n\te.g. MIT.CSAIL =C2=A0 =C2=A0 =C2=A0 =C2=A0 -&= +gt; mit, csail"
+> + =C2=A0 =C2=A0"\n\te.g. Mailing.OSS.Linux -> mailing, oss, li= +nux";
+>
+> =C2=A0static const char search_config_comment[] =3D
+> =C2=A0 =C2=A0 =C2=A0" Search configuration\n"
+> @@ -114,6 +123,7 @@ struct _notmuch_config {
+> =C2=A0 =C2=A0 =C2=A0const char **new_ignore;
+> =C2=A0 =C2=A0 =C2=A0size_t new_ignore_length;
+> =C2=A0 =C2=A0 =C2=A0notmuch_bool_t maildir_synchronize_flags;
+> + =C2=A0 =C2=A0notmuch_bool_t maildir_add_as_tag_flags;
+> =C2=A0 =C2=A0 =C2=A0const char **search_exclude_tags;
+> =C2=A0 =C2=A0 =C2=A0size_t search_exclude_tags_length;
+> =C2=A0};
+> @@ -251,7 +261,7 @@ notmuch_config_open (void *ctx,
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 fprintf (stderr, "Out of memory.\n&qu= +ot;);
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return NULL;
+> =C2=A0 =C2=A0 =C2=A0}
+> -
+> +
+> =C2=A0 =C2=A0 =C2=A0talloc_set_destructor (config, notmuch_config_dest= +ructor);
+>
+> =C2=A0 =C2=A0 =C2=A0if (filename) {
+> @@ -393,6 +403,14 @@ notmuch_config_open (void *ctx,
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 g_error_free (error);
+> =C2=A0 =C2=A0 =C2=A0}
+>
+> + =C2=A0 =C2=A0config->maildir_add_as_tag_flags =3D
+> + =C2=A0 =C2=A0 =C2=A0 g_key_file_get_boolean (config->key_file, +> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= +=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "maildir", "add_as_ta= +g_flags", &error);
+> + =C2=A0 =C2=A0if (error) {
+> + =C2=A0 =C2=A0 =C2=A0 notmuch_config_set_maildir_add_as_tag_flags (co= +nfig, FALSE);
+> + =C2=A0 =C2=A0 =C2=A0 g_error_free (error);
+> + =C2=A0 =C2=A0}
+> +
+> =C2=A0 =C2=A0 =C2=A0/* Whenever we know of configuration sections that= + don't appear in
+> =C2=A0 =C2=A0 =C2=A0 * the configuration file, we add some comments to= + help the user
+> =C2=A0 =C2=A0 =C2=A0 * understand what can be done. */
+> @@ -438,7 +456,7 @@ notmuch_config_open (void *ctx,
+> =C2=A0}
+>
+> =C2=A0/* Close the given notmuch_config_t object, freeing all resource= +s.
+> - *
+> + *
+> =C2=A0 * Note: Any changes made to the configuration are *not* saved b= +y this
+> =C2=A0 * function. To save changes, call notmuch_config_save before +> =C2=A0 * notmuch_config_close.
+> @@ -720,7 +738,7 @@ notmuch_config_command_get (void *ctx, char *item)= +
+> =C2=A0 =C2=A0 =C2=A0} else if (strcmp(item, "user.other_email&quo= +t;) =3D=3D 0) {
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 const char **other_email;
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 size_t i, length;
+> -
+> +
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 other_email =3D notmuch_config_get_user_ot= +her_email (config, &length);
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (i =3D 0; i < length; i++)
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf ("%s\n", ot= +her_email[i]);
+> @@ -891,3 +909,19 @@ notmuch_config_set_maildir_synchronize_flags (not= +much_config_t *config,
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = +=C2=A0 =C2=A0 =C2=A0 =C2=A0 "maildir", "synchronize_flags&qu= +ot;, synchronize_flags);
+> =C2=A0 =C2=A0 =C2=A0config->maildir_synchronize_flags =3D synchroni= +ze_flags;
+> =C2=A0}
+> +
+> +
+> +notmuch_bool_t
+> +notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config= +)
+> +{
+> + =C2=A0 =C2=A0return config->maildir_add_as_tag_flags;
+> +}
+> +
+> +void
+> +notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config= +,
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= +=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = +=C2=A0 =C2=A0notmuch_bool_t add_as_tag_flags)
+> +{
+> + =C2=A0 =C2=A0g_key_file_set_boolean (config->key_file,
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= +=A0 =C2=A0 =C2=A0 =C2=A0 "maildir", "add_as_tag_flags",= + add_as_tag_flags);
+> + =C2=A0 =C2=A0config->maildir_add_as_tag_flags =3D add_as_tag_flag= +s;
+> +}
+> diff --git a/notmuch-new.c b/notmuch-new.c
+> index 56c4a6f..9ec983f 100644
+> --- a/notmuch-new.c
+> +++ b/notmuch-new.c
+> @@ -20,6 +20,7 @@
+>
+> =C2=A0#include "notmuch-client.h"
+>
+> +#include <ctype.h>
+> =C2=A0#include <unistd.h>
+>
+> =C2=A0typedef struct _filename_node {
+> @@ -53,6 +54,7 @@ typedef struct {
+> =C2=A0 =C2=A0 =C2=A0_filename_list_t *directory_mtimes;
+>
+> =C2=A0 =C2=A0 =C2=A0notmuch_bool_t synchronize_flags;
+> + =C2=A0 =C2=A0notmuch_bool_t add_as_tag_flags;
+> =C2=A0} add_files_state_t;
+>
+> =C2=A0static volatile sig_atomic_t do_print_progress =3D 0;
+> @@ -240,6 +242,32 @@ _entry_in_ignore_list (const char *entry, add_fil= +es_state_t *state)
+> =C2=A0 =C2=A0 =C2=A0return FALSE;
+> =C2=A0}
+>
+> +static void
+> +_add_maildir_as_tag(notmuch_database_t *notmuch,
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 notmu= +ch_message_t *msg, const char *path)
+> +{
+> + =C2=A0 =C2=A0char *tok =3D talloc_strdup (notmuch, path);
+> + =C2=A0 =C2=A0int len =3D strlen(tok);
+> +
+> + =C2=A0 =C2=A0/* asserts path ends with /cur|/tmp|/new */
+> + =C2=A0 =C2=A0if (len > 4 && tok[len - 4] =3D=3D '/= +9;) {
+> + =C2=A0 =C2=A0 =C2=A0 char *iter =3D tok + len - 4;
+> + =C2=A0 =C2=A0 =C2=A0 *iter =3D '\0';
+> + =C2=A0 =C2=A0 =C2=A0 while (-- iter && iter >=3D tok) { +> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 char c =3D *iter;
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (c =3D=3D '/' || c =3D= +=3D '.') {
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *iter =3D '\0&#= +39;;
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 notmuch_message_add= +_tag (msg, iter + 1);
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (c =3D=3D '/= +') {
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break= +;
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *iter =3D tolower(*iter);
+> + =C2=A0 =C2=A0 =C2=A0 }
+> + =C2=A0 =C2=A0}
+> + =C2=A0 =C2=A0talloc_free (tok);
+> +}
+> +
+> =C2=A0/* Examine 'path' recursively as follows:
+> =C2=A0 *
+> =C2=A0 * =C2=A0 o Ask the filesystem for the mtime of 'path' (= +fs_mtime)
+> @@ -508,6 +536,9 @@ add_files (notmuch_database_t *notmuch,
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 notmuch_message_freeze (mess= +age);
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (tag=3Dstate->new_tag= +s; *tag !=3D NULL; tag++)
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 notmuch_messag= +e_add_tag (message, *tag);
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (state->add_as_tag_flags = +=3D=3D TRUE) {
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 _add_maildir_as_tag= +(notmuch, message, path);
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (state->synchronize_fl= +ags =3D=3D TRUE)
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 notmuch_messag= +e_maildir_flags_to_tags (message);
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 notmuch_message_thaw (messag= +e);
+> @@ -878,6 +909,7 @@ notmuch_new_command (void *ctx, int argc, char *ar= +gv[])
+> =C2=A0 =C2=A0 =C2=A0add_files_state.new_tags =3D notmuch_config_get_ne= +w_tags (config, &add_files_state.new_tags_length);
+> =C2=A0 =C2=A0 =C2=A0add_files_state.new_ignore =3D notmuch_config_get_= +new_ignore (config, &add_files_state.new_ignore_length);
+> =C2=A0 =C2=A0 =C2=A0add_files_state.synchronize_flags =3D notmuch_conf= +ig_get_maildir_synchronize_flags (config);
+> + =C2=A0 =C2=A0add_files_state.add_as_tag_flags =3D notmuch_config_get= +_maildir_add_as_tag_flags (config);
+> =C2=A0 =C2=A0 =C2=A0db_path =3D notmuch_config_get_database_path (conf= +ig);
+>
+> =C2=A0 =C2=A0 =C2=A0if (run_hooks) {
+> --
+> 1.8.0
+>
+> _______________________________________________
+> notmuch mailing list
+> notmuch@notmuchmail.org= +
+> http://not= +muchmail.org/mailman/listinfo/notmuch
+

+ +--14dae93b56d4f9726104ccf97331--