* Add /renew/ tag to moved/renamed/reflagged messages @ 2015-03-04 13:07 Baptiste 2015-03-04 14:31 ` [PATCH] " Baptiste 2015-03-05 8:43 ` francois 0 siblings, 2 replies; 6+ messages in thread From: Baptiste @ 2015-03-04 13:07 UTC (permalink / raw) To: notmuch [-- Attachment #1: Type: text/plain, Size: 1351 bytes --] Hi, new messages are given a default (configurable) tag, typically /new/ … This is handy for automatic tagging. What about another automatic tag to re-add to an existing mail when =notmuch new= detect a moved, renamed or reflagged message … This would allow something like tag synchro through an =IMAP= mailbox, or at least keep folder and tag organization coherent while a message is moved … my usecase is : - On PC A - message /1/ is received from =IMAP= in default mail folder, given tag /new/ - message /1/ is automatically tagged /inbox/ (see /afew/) - On PC B - message /1/ is received from =IMAP= in default mail folder, given tag /new/ - message /1/ is automatically tagged /inbox/ (see /afew/) - manual tagging into mail client as /archive/ - mail is moved (see /afew/) to /Archives/ folder due to /archive/ tag - message /1/ no more in default but /Archives/ folder is synchronized back to =IMAP= server - On PC A (not possible today) - message /1/ is re-received from =IMAP= in /Archives/ folder, and removed from default mail folder, added tag /renew/ - (today, =notmuch new= just detect the moved file, and thanksfully keep existing tags) - message /1/ is automatically tagged /archive/ due to presence in /Archives/ folder (and /renew/ tag) Thank you, -- ~~^v^~~ Baptiste [-- Attachment #2.1: Type: text/html, Size: 2158 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Re: Add /renew/ tag to moved/renamed/reflagged messages 2015-03-04 13:07 Add /renew/ tag to moved/renamed/reflagged messages Baptiste @ 2015-03-04 14:31 ` Baptiste 2015-04-10 23:56 ` David Bremner 2015-10-24 0:23 ` David Bremner 2015-03-05 8:43 ` francois 1 sibling, 2 replies; 6+ messages in thread From: Baptiste @ 2015-03-04 14:31 UTC (permalink / raw) To: notmuch [-- Attachment #1: Type: text/plain, Size: 8530 bytes --] Hi, > What about another automatic tag to re-add to an existing mail when =notmuch new= detect a moved, renamed or reflagged message ... the following code sample seems to actually do the job … Best regards, -- ~~^v^~~ Baptiste ----- #+BEGIN_EXAMPLE 5aa6f240a34d28ff3a8f768e399ec3c483961cb2 HEAD renew Author: Baptiste Fouques <bateast@bat.fr.eu.org> Date: Wed Mar 4 15:16:20 2015 +0100 Add /renew/ tags to moved or reflagged messages (message that are added or removed and have database dupplicated id) 5 files changed, 74 insertions(+), 1 deletion(-) doc/man1/notmuch-config.rst | 6 ++++++ notmuch-client.h | 8 ++++++++ notmuch-config.c | 25 +++++++++++++++++++++++++ notmuch-new.c | 21 ++++++++++++++++++++- notmuch-setup.c | 15 +++++++++++++++ Modified doc/man1/notmuch-config.rst diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst index 2676a86..6e58d1e 100644 --- a/doc/man1/notmuch-config.rst +++ b/doc/man1/notmuch-config.rst @@ -74,6 +74,12 @@ The available configuration items are described below. Default: ``unread;inbox``. + **renew.tags** + A list of tags that will be added to all moved or re-flagged messages + by **notmuch new**. + + Default: empty list. + ,**new.ignore** A list of file and directory names, without path, that will not be searched for messages by **notmuch new**. All the files and Modified notmuch-client.h diff --git a/notmuch-client.h b/notmuch-client.h index 5e0d475..3bf7f7b 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -309,6 +309,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config, size_t length); const char ** +notmuch_config_get_re_new_tags (notmuch_config_t *config, + size_t *length); +void +notmuch_config_set_re_new_tags (notmuch_config_t *config, + const char *new_tags[], + size_t length); + +const char ** notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length); Modified notmuch-config.c diff --git a/notmuch-config.c b/notmuch-config.c index a564bca..f7f787e 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -113,6 +113,8 @@ struct _notmuch_config { size_t user_other_email_length; const char **new_tags; size_t new_tags_length; + const char **re_new_tags; + size_t re_new_tags_length; const char **new_ignore; size_t new_ignore_length; notmuch_bool_t maildir_synchronize_flags; @@ -272,6 +274,8 @@ notmuch_config_open (void *ctx, config->user_other_email_length = 0; config->new_tags = NULL; config->new_tags_length = 0; + config->re_new_tags = NULL; + config->re_new_tags_length = 0; config->new_ignore = NULL; config->new_ignore_length = 0; config->maildir_synchronize_flags = TRUE; @@ -384,6 +388,10 @@ notmuch_config_open (void *ctx, notmuch_config_set_new_tags (config, tags, 2); } + if (notmuch_config_get_re_new_tags (config, &tmp) == NULL) { + notmuch_config_set_re_new_tags (config, NULL, 0); + } + if (notmuch_config_get_new_ignore (config, &tmp) == NULL) { notmuch_config_set_new_ignore (config, NULL, 0); } @@ -639,6 +647,14 @@ notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length) } const char ** +notmuch_config_get_re_new_tags (notmuch_config_t *config, size_t *length) +{ + return _config_get_list (config, "renew", "tags", + &(config->re_new_tags), + &(config->re_new_tags_length), length); +} + +const char ** notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length) { return _config_get_list (config, "new", "ignore", @@ -665,6 +681,15 @@ notmuch_config_set_new_tags (notmuch_config_t *config, } void +notmuch_config_set_re_new_tags (notmuch_config_t *config, + const char *list[], + size_t length) +{ + _config_set_list (config, "renew", "tags", list, length, + &(config->re_new_tags)); +} + +void notmuch_config_set_new_ignore (notmuch_config_t *config, const char *list[], size_t length) Modified notmuch-new.c diff --git a/notmuch-new.c b/notmuch-new.c index ddf42c1..1dc7b07 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -47,6 +47,8 @@ typedef struct { notmuch_bool_t debug; const char **new_tags; size_t new_tags_length; + const char **re_new_tags; + size_t re_new_tags_length; const char **new_ignore; size_t new_ignore_length; @@ -274,6 +276,8 @@ add_file (notmuch_database_t *notmuch, const char *filename, break; /* Non-fatal issues (go on to next file). */ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: + for (tag = state->re_new_tags; *tag != NULL; tag++) + notmuch_message_add_tag (message, *tag); if (state->synchronize_flags) notmuch_message_maildir_flags_to_tags (message); break; @@ -799,6 +803,7 @@ remove_filename (notmuch_database_t *notmuch, add_files_state_t *add_files_state) { notmuch_status_t status; + const char **tag; notmuch_message_t *message; status = notmuch_database_begin_atomic (notmuch); if (status) @@ -810,7 +815,9 @@ remove_filename (notmuch_database_t *notmuch, status = notmuch_database_remove_message (notmuch, path); if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) { add_files_state->renamed_messages++; - if (add_files_state->synchronize_flags == TRUE) + for (tag = add_files_state->re_new_tags; *tag != NULL; tag++) + notmuch_message_add_tag (message, *tag); + if (add_files_state->synchronize_flags == TRUE) notmuch_message_maildir_flags_to_tags (message); status = NOTMUCH_STATUS_SUCCESS; } else if (status == NOTMUCH_STATUS_SUCCESS) { @@ -948,6 +955,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) add_files_state.verbosity = VERBOSITY_VERBOSE; add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length); + add_files_state.re_new_tags = notmuch_config_get_re_new_tags (config, &add_files_state.re_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); db_path = notmuch_config_get_database_path (config); @@ -962,6 +970,17 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) return EXIT_FAILURE; } } + for (i = 0; i < add_files_state.re_new_tags_length; i++) { + const char *error_msg; + + error_msg = illegal_tag (add_files_state.re_new_tags[i], FALSE); + if (error_msg) { + fprintf (stderr, "Error: tag '%s' in re_new.tags: %s\n", + add_files_state.re_new_tags[i], error_msg); + return EXIT_FAILURE; + } + } + if (!no_hooks) { ret = notmuch_run_hook (db_path, "pre-new"); Modified notmuch-setup.c diff --git a/notmuch-setup.c b/notmuch-setup.c index 36a6171..c00516b 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -131,6 +131,8 @@ notmuch_setup_command (notmuch_config_t *config, unsigned int i; const char **new_tags; size_t new_tags_len; + const char **re_new_tags; + size_t re_new_tags_len; const char **search_exclude_tags; size_t search_exclude_tags_len; @@ -192,6 +194,7 @@ notmuch_setup_command (notmuch_config_t *config, } new_tags = notmuch_config_get_new_tags (config, &new_tags_len); + re_new_tags = notmuch_config_get_re_new_tags (config, &re_new_tags_len); printf ("Tags to apply to all new messages (separated by spaces) ["); print_tag_list (new_tags, new_tags_len); @@ -206,6 +209,18 @@ notmuch_setup_command (notmuch_config_t *config, g_ptr_array_free (tags, TRUE); } + printf ("Tags to apply to all moved or reflagged messages (separated by spaces) ["); + print_tag_list (re_new_tags, re_new_tags_len); + prompt ("]: "); + + if (strlen (response)) { + GPtrArray *tags = parse_tag_list (config, response); + + notmuch_config_set_re_new_tags (config, (const char **) tags->pdata, + tags->len); + + g_ptr_array_free (tags, TRUE); + } search_exclude_tags = notmuch_config_get_search_exclude_tags (config, &search_exclude_tags_len); #+END_EXAMPLE [-- Attachment #2.1: Type: text/html, Size: 8978 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Re: Add /renew/ tag to moved/renamed/reflagged messages 2015-03-04 14:31 ` [PATCH] " Baptiste @ 2015-04-10 23:56 ` David Bremner 2015-04-11 9:12 ` Gaute Hope 2015-10-24 0:23 ` David Bremner 1 sibling, 1 reply; 6+ messages in thread From: David Bremner @ 2015-04-10 23:56 UTC (permalink / raw) To: Baptiste, notmuch Baptiste <bateast@bat.fr.eu.org> writes: > Hi, > >> What about another automatic tag to re-add to an existing mail when =notmuch new= detect a moved, renamed or reflagged message ... > > the following code sample seems to actually do the job … > Sorry I still haven't had a chance to review your patch in detail. A few things I did wonder about - There is a patch series in progress to add a "last modified time" to all messages [1]. It seems like this should also work for your case since renaming counts as modification in this context. It might not be quite as easy/efficient for your use case as your proposal, but it seems like it should work. - What about messages added by notmuch-insert? I guess you are maybe not using it, but it seems odd to only support changes detected in notmuch-new. - This might be because I haven't worked through the details, but it isn't obvious to me how your patch behaves with messages with multiple files on disk. [1]: id:1428274754-1698-1-git-send-email-david@tethera.net ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Re: Add /renew/ tag to moved/renamed/reflagged messages 2015-04-10 23:56 ` David Bremner @ 2015-04-11 9:12 ` Gaute Hope 0 siblings, 0 replies; 6+ messages in thread From: Gaute Hope @ 2015-04-11 9:12 UTC (permalink / raw) To: David Bremner, Baptiste, notmuch Excerpts from David Bremner's message of April 11, 2015 1:56: > Baptiste <bateast@bat.fr.eu.org> writes: > >> Hi, >> >>> What about another automatic tag to re-add to an existing mail when =notmuch new= detect a moved, renamed or reflagged message ... >> >> the following code sample seems to actually do the job … >> > > Sorry I still haven't had a chance to review your patch in detail. A few > things I did wonder about > > - There is a patch series in progress to add a "last modified time" to > all messages [1]. It seems like this should also work for your case > since renaming counts as modification in this context. It might not be > quite as easy/efficient for your use case as your proposal, but it > seems like it should work. > > - What about messages added by notmuch-insert? I guess you are maybe not > using it, but it seems odd to only support changes detected in > notmuch-new. > > - This might be because I haven't worked through the details, but it > isn't obvious to me how your patch behaves with messages with multiple > files on disk. > > > > [1]: id:1428274754-1698-1-git-send-email-david@tethera.net I think I sent in something similar [2] before the lastmod stuff, there are some issues with reliably detecting all changes. Especially, changes that do not result in a rename. It would be made obsolete by the lastmod series though. - gaute [2]: id:1396800683-9164-1-git-send-email-eg@gaute.vetsj.com ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Re: Add /renew/ tag to moved/renamed/reflagged messages 2015-03-04 14:31 ` [PATCH] " Baptiste 2015-04-10 23:56 ` David Bremner @ 2015-10-24 0:23 ` David Bremner 1 sibling, 0 replies; 6+ messages in thread From: David Bremner @ 2015-10-24 0:23 UTC (permalink / raw) To: Baptiste, notmuch Baptiste <bateast@bat.fr.eu.org> writes: > Hi, > >> What about another automatic tag to re-add to an existing mail when =notmuch new= detect a moved, renamed or reflagged message ... > > > the following code sample seems to actually do the job … > I'm marking this obsolete because the lastmod changes are now in notmuch master. d ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Add /renew/ tag to moved/renamed/reflagged messages 2015-03-04 13:07 Add /renew/ tag to moved/renamed/reflagged messages Baptiste 2015-03-04 14:31 ` [PATCH] " Baptiste @ 2015-03-05 8:43 ` francois 1 sibling, 0 replies; 6+ messages in thread From: francois @ 2015-03-05 8:43 UTC (permalink / raw) To: Baptiste; +Cc: public-notmuch-gxuj+Tv9EO5zyzON3hdc1g On Wed, Mar 04, 2015 at 02:07:01PM +0100, Baptiste wrote: > new messages are given a default (configurable) tag, typically /new/ … > This is handy for automatic tagging. > > What about another automatic tag to re-add to an existing mail when > =notmuch new= detect a moved, renamed or reflagged message … This > would allow something like tag synchro through an =IMAP= mailbox, or > at least keep folder and tag organization coherent while a message > is moved … I would really like this too. An other use case is for mailing lists, my messages are tagged with new when they appear in my outbox but I would like to complete tags when receiving them via the mailing list. > > my usecase is : > - On PC A > - message /1/ is received from =IMAP= in default mail folder, given tag /new/ > - message /1/ is automatically tagged /inbox/ (see /afew/) > - On PC B > - message /1/ is received from =IMAP= in default mail folder, given tag /new/ > - message /1/ is automatically tagged /inbox/ (see /afew/) > - manual tagging into mail client as /archive/ > - mail is moved (see /afew/) to /Archives/ folder due to /archive/ tag > - message /1/ no more in default but /Archives/ folder is synchronized back to =IMAP= server > - On PC A (not possible today) > - message /1/ is re-received from =IMAP= in /Archives/ folder, and removed from default mail folder, added tag /renew/ > - (today, =notmuch new= just detect the moved file, and thanksfully keep existing tags) > - message /1/ is automatically tagged /archive/ due to presence in /Archives/ folder (and /renew/ tag) > > Thank you, > > -- > ~~^v^~~ Baptiste ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-10-24 0:24 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-03-04 13:07 Add /renew/ tag to moved/renamed/reflagged messages Baptiste 2015-03-04 14:31 ` [PATCH] " Baptiste 2015-04-10 23:56 ` David Bremner 2015-04-11 9:12 ` Gaute Hope 2015-10-24 0:23 ` David Bremner 2015-03-05 8:43 ` francois
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).