unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] automatic tagging based on imap maildir
@ 2012-10-25 23:33 Taesoo Kim
  2012-10-25 23:33 ` [PATCH 1/2] Automatic tagging based on maildir Taesoo Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Taesoo Kim @ 2012-10-25 23:33 UTC (permalink / raw)
  To: notmuch; +Cc: Taesoo Kim

Hi all,

To use gmail's label (imap maildir), parse maildir and add some tags as gmail's
labels.

Thanks,
Taesoo

Taesoo Kim (2):
  Automatic tagging based on maildir
  fix: initialize error var before using it

 notmuch-client.h |  7 +++++++
 notmuch-config.c | 43 +++++++++++++++++++++++++++++++++++++++----
 notmuch-new.c    | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 4 deletions(-)

-- 
1.8.0

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/2] Automatic tagging based on maildir
  2012-10-25 23:33 [PATCH 0/2] automatic tagging based on imap maildir Taesoo Kim
@ 2012-10-25 23:33 ` Taesoo Kim
  2012-10-26 11:31   ` David Bremner
                     ` (2 more replies)
  2012-10-25 23:33 ` [PATCH 2/2] fix: initialize error var before using it Taesoo Kim
  2012-10-26 17:10 ` [PATCH 0/2] automatic tagging based on imap maildir Amadeusz Żołnowski
  2 siblings, 3 replies; 16+ messages in thread
From: Taesoo Kim @ 2012-10-25 23:33 UTC (permalink / raw)
  To: notmuch; +Cc: Taesoo Kim

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.

Signed-off-by: Taesoo Kim <taesoo@mit.edu>
---
 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 <ctype.h>
 #include <unistd.h>
 
 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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] fix: initialize error var before using it
  2012-10-25 23:33 [PATCH 0/2] automatic tagging based on imap maildir Taesoo Kim
  2012-10-25 23:33 ` [PATCH 1/2] Automatic tagging based on maildir Taesoo Kim
@ 2012-10-25 23:33 ` Taesoo Kim
  2012-10-26 17:10 ` [PATCH 0/2] automatic tagging based on imap maildir Amadeusz Żołnowski
  2 siblings, 0 replies; 16+ messages in thread
From: Taesoo Kim @ 2012-10-25 23:33 UTC (permalink / raw)
  To: notmuch; +Cc: Taesoo Kim


Signed-off-by: Taesoo Kim <taesoo@mit.edu>
---
 notmuch-config.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/notmuch-config.c b/notmuch-config.c
index c95f9dd..195ddb4 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -403,6 +403,7 @@ notmuch_config_open (void *ctx,
 	g_error_free (error);
     }
 
+    error = NULL;
     config->maildir_add_as_tag_flags =
 	g_key_file_get_boolean (config->key_file,
 				"maildir", "add_as_tag_flags", &error);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] Automatic tagging based on maildir
  2012-10-25 23:33 ` [PATCH 1/2] Automatic tagging based on maildir Taesoo Kim
@ 2012-10-26 11:31   ` David Bremner
  2012-10-26 13:19   ` Michal Nazarewicz
  2012-10-26 17:14   ` Jani Nikula
  2 siblings, 0 replies; 16+ messages in thread
From: David Bremner @ 2012-10-26 11:31 UTC (permalink / raw)
  To: Taesoo Kim, notmuch

Taesoo Kim <taesoo@mit.edu> writes:

> 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.
>

Hi Taesoo;

Welcome to the list!

What happens with your patch when a tag is deleted, either by moving the
mesage in the file system (e.g. by offlineimap) or in the notmuch
database? At a quick glance, I guess neither propagates.

Do you store messages multiple times to match multiple tag settings on
gmail?  If so, do you have any numbers about how much extra space that
uses?

All the best,

d

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] Automatic tagging based on maildir
  2012-10-25 23:33 ` [PATCH 1/2] Automatic tagging based on maildir Taesoo Kim
  2012-10-26 11:31   ` David Bremner
@ 2012-10-26 13:19   ` Michal Nazarewicz
  2012-10-26 17:14   ` Jani Nikula
  2 siblings, 0 replies; 16+ messages in thread
From: Michal Nazarewicz @ 2012-10-26 13:19 UTC (permalink / raw)
  To: Taesoo Kim, notmuch; +Cc: Taesoo Kim

[-- Attachment #1: Type: text/plain, Size: 1780 bytes --]

On Fri, Oct 26 2012, Taesoo Kim <taesoo@mit.edu> wrote:
> @@ -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 */

It actually does not assert that.  It just checks “/”.

> +    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);
> +	}

strtok() would make it easier.

> +    }
> +    talloc_free (tok);
> +}

How about (not tested):

static void
_add_maildir_as_tag(notmuch_database_t *notmuch,
		    notmuch_message_t *msg, const char *path)
{
    const char *a = NULL, *b = NULL;
    char *dir, *tag, *saveptr;

    while ((path = strchr(path, '/'))) {
	a = b;
	b = path;
    }

    if (!a || ++a >= b ||
	(strcmp(b, "/cur") && strcmp(b, "/new") && strcmp(b, "/tmp")))
	return;

    dir = talloc_strndup(notmuch, a, b - a);
    while ((tag = strtok_r(dir, ".", &saveptr)))
	notmuch_message_add_tag(msg, tag);

    talloc_free(dir);
}

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-25 23:33 [PATCH 0/2] automatic tagging based on imap maildir Taesoo Kim
  2012-10-25 23:33 ` [PATCH 1/2] Automatic tagging based on maildir Taesoo Kim
  2012-10-25 23:33 ` [PATCH 2/2] fix: initialize error var before using it Taesoo Kim
@ 2012-10-26 17:10 ` Amadeusz Żołnowski
  2012-10-26 23:02   ` David Bremner
  2 siblings, 1 reply; 16+ messages in thread
From: Amadeusz Żołnowski @ 2012-10-26 17:10 UTC (permalink / raw)
  To: Taesoo Kim; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

Quoting Taesoo Kim (2012-10-26 01:33:57)
> To use gmail's label (imap maildir), parse maildir and add some tags
> as gmail's labels.

Is this what Teythoon's afew [0] does (and lots more)?

[0] https://github.com/teythoon/afew/


-- 
Amadeusz Żołnowski

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iQEcBAABAgAGBQJQisQAAAoJEPATRTHh2/q1MJ8H/jaQh2paErdIWSqV5G/QLkQg
xI6GE2Gtr6coHHztjW9xjCy29NuOsHEiZbg7985v4mp5rjKQcXqBcbcaD+mrRsAa
iTUbK8dwTMRBYZI5wKi91CoTr56wukq9y7z6GRox7YF/2dlTbkDvGU0LnSvCfS3t
JSCxrjDr5XAN6dyqzEo4WqEckMuEv8j9APmApaqTtlgTvQn4W9rQ9hvVEFbZUoqN
jkQaKPiERgk0t4giQ5t51OsALPNG2D1vvu5t08TTAjMWYDe3wjS5BT4ijxSkwb/I
y/DhpgJ0oHOt6jB/vTGJKcHtbTNE1pw39c2cF9fwQMZ5pA8iQSueYfWmiqy/518=
=sjlD
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] Automatic tagging based on maildir
  2012-10-25 23:33 ` [PATCH 1/2] Automatic tagging based on maildir Taesoo Kim
  2012-10-26 11:31   ` David Bremner
  2012-10-26 13:19   ` Michal Nazarewicz
@ 2012-10-26 17:14   ` Jani Nikula
  2 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-10-26 17:14 UTC (permalink / raw)
  To: Taesoo Kim; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 7594 bytes --]

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
> 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 <taesoo@mit.edu>
> ---
>  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 <ctype.h>
>  #include <unistd.h>
>
>  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

[-- Attachment #2: Type: text/html, Size: 10340 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-26 17:10 ` [PATCH 0/2] automatic tagging based on imap maildir Amadeusz Żołnowski
@ 2012-10-26 23:02   ` David Bremner
  2012-10-27  4:41     ` Taesoo Kim
  0 siblings, 1 reply; 16+ messages in thread
From: David Bremner @ 2012-10-26 23:02 UTC (permalink / raw)
  To: Amadeusz Żołnowski, Taesoo Kim; +Cc: notmuch

Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:

> Is this what Teythoon's afew [0] does (and lots more)?
>
> [0] https://github.com/teythoon/afew/

Perhaps this is obvious to everyone, but just in case.  Even if a patch
series did duplicate exactly functionality in afew (and I don't know
whether it does or not), we still might want to include the
functionality in core notmuch.

d

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-26 23:02   ` David Bremner
@ 2012-10-27  4:41     ` Taesoo Kim
  2012-10-27 13:00       ` David Bremner
  0 siblings, 1 reply; 16+ messages in thread
From: Taesoo Kim @ 2012-10-27  4:41 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch, Taesoo Kim

It seems afew can be used for converting gmail labels to notmuch
tags. After spending 10 min on google search, I decided to implement
what I wanted to have -- also my lab mates wanted to too. So you guys
think it's duplicated, just ignore these patches :)

Thanks for notmuch. We all loved notmuch.
Taesoo

On 10/26/12 at 08:02pm, David Bremner wrote:
> Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:
> 
> > Is this what Teythoon's afew [0] does (and lots more)?
> >
> > [0] https://github.com/teythoon/afew/
> 
> Perhaps this is obvious to everyone, but just in case.  Even if a patch
> series did duplicate exactly functionality in afew (and I don't know
> whether it does or not), we still might want to include the
> functionality in core notmuch.
> 
> d

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-27  4:41     ` Taesoo Kim
@ 2012-10-27 13:00       ` David Bremner
  2012-10-28 10:03         ` Andrei POPESCU
  0 siblings, 1 reply; 16+ messages in thread
From: David Bremner @ 2012-10-27 13:00 UTC (permalink / raw)
  To: Taesoo Kim; +Cc: notmuch

Taesoo Kim <tsgatesv@gmail.com> writes:

> It seems afew can be used for converting gmail labels to notmuch
> tags. After spending 10 min on google search, I decided to implement
> what I wanted to have -- also my lab mates wanted to too. So you guys
> think it's duplicated, just ignore these patches :)

As I said (or tried to say), in my opinion, duplication with an external
package is not the main issue; I think moving features into the core
when appropriate is a normal development process. On the other hand, I'm
not really a gmail user, so I don't know yet if these patches solve
enough of the problem to be interesting.

To some extent it's up to you, whether you prefer to maintain a private
branch, or spend the effort on getting the patches upstream. For better
or worse, getting patches into notmuch is rarely fire-and-forget; almost
everything goes through several rounds of review. No hard feelings
either way ;).

Cheers,

David

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-27 13:00       ` David Bremner
@ 2012-10-28 10:03         ` Andrei POPESCU
  2012-10-28 15:31           ` Austin Clements
  2012-10-30 18:18           ` Amadeusz Żołnowski
  0 siblings, 2 replies; 16+ messages in thread
From: Andrei POPESCU @ 2012-10-28 10:03 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch, Taesoo Kim

[-- Attachment #1: Type: text/plain, Size: 1484 bytes --]

On Sb, 27 oct 12, 10:00:46, David Bremner wrote:
> 
> As I said (or tried to say), in my opinion, duplication with an external
> package is not the main issue; I think moving features into the core
> when appropriate is a normal development process. On the other hand, I'm
> not really a gmail user, so I don't know yet if these patches solve
> enough of the problem to be interesting.

They are interesting not only for Gmail[1], but also for other kinds of 
setups. As far as I understand (please correct me if I'm wrong), 
currently notmuch treats multiple copies of a message similar to Gmail 
(indexes one, but ignores the rest), which is why I'm *not* receiving 
any mailing lists on my Gmail account.

Besides that consider also that I'm subscribed to about 40 mailing 
lists, each sorted to it's own folder by rules based on List-Id (which 
notmuch doesn't support yet as far as I know). This separation is very 
useful for my read-flow.

However, there are messages crossposed to several lists. It would be 
great if notmuch or (more probably) a client using notmuch could mark 
all copies of a message as read in all folders, but still keep it there 
(otherwise the thread in the respective folder is incomplete).

[1] yes, this is probably one missing feature that prevents me from 
putting my Gmail account in notmuch as well.

Kind regards,
Andrei
-- 
If you can't explain it simply, you don't understand it well enough.
(Albert Einstein)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-28 10:03         ` Andrei POPESCU
@ 2012-10-28 15:31           ` Austin Clements
  2012-10-28 21:44             ` Andrei POPESCU
  2012-10-30 18:18           ` Amadeusz Żołnowski
  1 sibling, 1 reply; 16+ messages in thread
From: Austin Clements @ 2012-10-28 15:31 UTC (permalink / raw)
  To: Andrei POPESCU; +Cc: notmuch, Taesoo Kim

Quoth Andrei POPESCU on Oct 28 at 12:03 pm:
> On Sb, 27 oct 12, 10:00:46, David Bremner wrote:
> > 
> > As I said (or tried to say), in my opinion, duplication with an external
> > package is not the main issue; I think moving features into the core
> > when appropriate is a normal development process. On the other hand, I'm
> > not really a gmail user, so I don't know yet if these patches solve
> > enough of the problem to be interesting.
> 
> They are interesting not only for Gmail[1], but also for other kinds of 

What is preventing folder: searches from addressing this?

> setups. As far as I understand (please correct me if I'm wrong), 
> currently notmuch treats multiple copies of a message similar to Gmail 
> (indexes one, but ignores the rest), which is why I'm *not* receiving 
> any mailing lists on my Gmail account.

notmuch tracks all copies of a message, but its output generally shows
messages, rather than files, so you see a message only once regardless
of how many copies there are in the file system.

Why does that cause you to not receive mailing lists?  (Or did I
misinterpret your statement?)

> Besides that consider also that I'm subscribed to about 40 mailing 
> lists, each sorted to it's own folder by rules based on List-Id (which 
> notmuch doesn't support yet as far as I know). This separation is very 
> useful for my read-flow.
> 
> However, there are messages crossposed to several lists. It would be 
> great if notmuch or (more probably) a client using notmuch could mark 
> all copies of a message as read in all folders, but still keep it there 
> (otherwise the thread in the respective folder is incomplete).

If I understand what you're saying, this is exactly what notmuch does.
When you remove the "unread" tag, notmuch will (should?) add the
"seen" maildir flag to all copies of that message in the file system
(barring some corner-cases that flag sync doesn't handle well; maybe
you're encountering one of those?).  And since notmuch never deletes
files, they will remain in the folders they were filed in.

> [1] yes, this is probably one missing feature that prevents me from 
> putting my Gmail account in notmuch as well.
> 
> Kind regards,
> Andrei

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-28 15:31           ` Austin Clements
@ 2012-10-28 21:44             ` Andrei POPESCU
  2012-10-28 22:12               ` Austin Clements
  0 siblings, 1 reply; 16+ messages in thread
From: Andrei POPESCU @ 2012-10-28 21:44 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

On Du, 28 oct 12, 11:31:38, Austin Clements wrote:
> 
> Why does that cause you to not receive mailing lists?  (Or did I
> misinterpret your statement?)

Yes. The main deterrent in Gmail silently dropping my own postings 
returning via the list, because it considers it identical to the sent 
message.
 
> If I understand what you're saying, this is exactly what notmuch does.
> When you remove the "unread" tag, notmuch will (should?) add the
> "seen" maildir flag to all copies of that message in the file system
> (barring some corner-cases that flag sync doesn't handle well; maybe
> you're encountering one of those?).  And since notmuch never deletes
> files, they will remain in the folders they were filed in.

Great. Then I only need a client that suits me. I've wanted to have a 
look at mutt-kz, but keep postponing it.

Kind regards,
Andrei
-- 
If you can't explain it simply, you don't understand it well enough.
(Albert Einstein)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-28 21:44             ` Andrei POPESCU
@ 2012-10-28 22:12               ` Austin Clements
  2012-10-29  0:07                 ` Andrei POPESCU
  0 siblings, 1 reply; 16+ messages in thread
From: Austin Clements @ 2012-10-28 22:12 UTC (permalink / raw)
  To: Andrei POPESCU; +Cc: notmuch

Quoth Andrei POPESCU on Oct 28 at 11:44 pm:
> On Du, 28 oct 12, 11:31:38, Austin Clements wrote:
> > 
> > Why does that cause you to not receive mailing lists?  (Or did I
> > misinterpret your statement?)
> 
> Yes. The main deterrent in Gmail silently dropping my own postings 
> returning via the list, because it considers it identical to the sent 
> message.

Ah.  And I assume you want to see those in your inbox even if they're
not a reply to some other message in your inbox?  I do recall Gmail
suppressing list reflections.

Though I think that, by default, notmuch *will* put your own list
postings in your inbox.  Assuming the list sends the message back to
you (not all do), and assuming your notmuch new.tags contains inbox,
notmuch will simply see it as a new message and tag it inbox.  If you
have Fcc setup in your frontend of choice to save sent messages in a
folder indexed by notmuch, then it should likewise tag the message
inbox as soon as it indexes it.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-28 22:12               ` Austin Clements
@ 2012-10-29  0:07                 ` Andrei POPESCU
  0 siblings, 0 replies; 16+ messages in thread
From: Andrei POPESCU @ 2012-10-29  0:07 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]

[Remembered to Reply-All, my fingers are trained to Reply-List only ;) ]

On Du, 28 oct 12, 18:12:40, Austin Clements wrote:
> 
> Ah.  And I assume you want to see those in your inbox even if they're
> not a reply to some other message in your inbox?  I do recall Gmail
> suppressing list reflections.

Yes, except the Inbox part :p. As already mentioned, I sort all lists by 
List-Id and I want to have my own posts nicely in their place in the 
corresponding threads (cross-posts included). Most of the times I even 
read my posts again, to spot significant mistakes.

> Though I think that, by default, notmuch *will* put your own list
> postings in your inbox.  Assuming the list sends the message back to
> you (not all do), and assuming your notmuch new.tags contains inbox,
> notmuch will simply see it as a new message and tag it inbox.  If you
> have Fcc setup in your frontend of choice to save sent messages in a
> folder indexed by notmuch, then it should likewise tag the message
> inbox as soon as it indexes it.

Mmm, can't comment on that until I have a "full" notmuch client. Right 
now I'm using mutt and notmuch-mutt only.

Kind regards,
Andrei
-- 
If you can't explain it simply, you don't understand it well enough.
(Albert Einstein)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] automatic tagging based on imap maildir
  2012-10-28 10:03         ` Andrei POPESCU
  2012-10-28 15:31           ` Austin Clements
@ 2012-10-30 18:18           ` Amadeusz Żołnowski
  1 sibling, 0 replies; 16+ messages in thread
From: Amadeusz Żołnowski @ 2012-10-30 18:18 UTC (permalink / raw)
  To: Andrei POPESCU; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 635 bytes --]

Quoting Andrei POPESCU (2012-10-28 11:03:24)
> Besides that consider also that I'm subscribed to about 40 mailing
> lists, each sorted to it's own folder by rules based on List-Id (which
> notmuch doesn't support yet as far as I know). This separation is very
> useful for my read-flow.

But 'afew' supports it:

a) It supports tagging mail based on list-id.
b) It supports moving messages across folders (afair, but I have never used
that feature).

So combining both should give you effect you want.  I really recommend
you to take a look at 'afew'.  It helps a lot with initial tagging.


-- 
Amadeusz Żołnowski

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iQEcBAABAgAGBQJQkBoCAAoJEPATRTHh2/q1SZsH/jVM2elBorRDLyUieVDJpTE4
vBr9xgvjFSGWwIjkyvq6wDhdULjqhSfYVCt842IhDnUB8k5f5BWF1A+Y5I7DkwfW
MYhpEw1KjiYIyWJfxhPCYh3XPNL9HGEMmj/yOdzdjM1ZzOzSzGnGdZ1lW3godpSO
6MhpuHlPCJ3ZRtTPHmkGUA4vHkJp8oRgdmn/4hqvbnLDb8BPGVvhLHUG8h+9LLQ9
PoME1j3TBoy7kqSRBrYAn89LqzKLjJ6d6vb3z9jR781vpAleOWYh2eJq1ZSolGl2
wHaaGMOj6aXdloljtlLjsuzbZuyKiKygsJgxNj6IWjEJKG8EiraQbG6shKXqKaU=
=c+Ei
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-10-30 18:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-25 23:33 [PATCH 0/2] automatic tagging based on imap maildir Taesoo Kim
2012-10-25 23:33 ` [PATCH 1/2] Automatic tagging based on maildir Taesoo Kim
2012-10-26 11:31   ` David Bremner
2012-10-26 13:19   ` Michal Nazarewicz
2012-10-26 17:14   ` Jani Nikula
2012-10-25 23:33 ` [PATCH 2/2] fix: initialize error var before using it Taesoo Kim
2012-10-26 17:10 ` [PATCH 0/2] automatic tagging based on imap maildir Amadeusz Żołnowski
2012-10-26 23:02   ` David Bremner
2012-10-27  4:41     ` Taesoo Kim
2012-10-27 13:00       ` David Bremner
2012-10-28 10:03         ` Andrei POPESCU
2012-10-28 15:31           ` Austin Clements
2012-10-28 21:44             ` Andrei POPESCU
2012-10-28 22:12               ` Austin Clements
2012-10-29  0:07                 ` Andrei POPESCU
2012-10-30 18:18           ` Amadeusz Żołnowski

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).