From: Karel Zak Date: Thu, 15 Dec 2011 20:59:54 +0000 (+0100) Subject: add X-Git-Tag: neomutt-20160404~13^2~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c5139207ba5be453f2fd9251c884de269b428a4;p=neomutt add Signed-off-by: Karel Zak --- diff --git a/OPS.NOTMUCH b/OPS.NOTMUCH index 21b611dfa..c69691ccf 100644 --- a/OPS.NOTMUCH +++ b/OPS.NOTMUCH @@ -1,3 +1,4 @@ OP_MAIN_CHANGE_VFOLDER "open a different virtual folder" OP_MAIN_VFOLDER_FROM_QUERY "generate virtual folder from query" OP_MAIN_MODIFY_LABELS "modify (notmuch) tags" +OP_MAIN_MODIFY_LABELS_THEN_HIDE "modify labeld and then hide message" diff --git a/README.notmuch b/README.notmuch index b51774d69..dabddba35 100644 --- a/README.notmuch +++ b/README.notmuch @@ -61,6 +61,17 @@ notmuch support for mutt - default key: ` - example: "+AAA +BBB -CCC" + modify-labels-then-hide: + - same as but message is marked by + - not mapped to any key + - example (add "archive" notmuch tag and remove message from screen): + + macro index A "archive\n" + + quasi-delete: + - delete message from mutt (usualy after function), but + don't touch message on disk + * muttrc: diff --git a/curs_main.c b/curs_main.c index 49715baf3..fd670fd71 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1380,16 +1380,18 @@ int mutt_index_menu (void) #ifdef USE_NOTMUCH case OP_MAIN_MODIFY_LABELS: + case OP_MAIN_MODIFY_LABELS_THEN_HIDE: + { if (Context->magic != M_NOTMUCH) { mutt_message _("No virtual folder, aborting."); break; } CHECK_MSGCOUNT; CHECK_VISIBLE; - buf[0] = '\0'; - if (mutt_get_field ("Add/remove labels: ", buf, sizeof (buf), 0) != 0 || !buf[0]) - { - mutt_message _("No labels, aborting."); + *buf = '\0'; + if (mutt_get_field ("Add/remove labels: ", buf, sizeof (buf), 0) || !*buf) + { + mutt_message _("No label specified, aborting."); break; } if (tag && !option (OPTAUTOTAG)) @@ -1408,7 +1410,12 @@ int mutt_index_menu (void) if (Context->hdrs[Context->v2r[j]]->tagged) { if (!Context->quiet) mutt_progress_update(&progress, ++px, -1); - nm_modify_message_tags(Context, Context->hdrs[Context->v2r[j]], buf, sizeof (buf)); + nm_modify_message_tags(Context, Context->hdrs[Context->v2r[j]], buf); + if (op == OP_MAIN_MODIFY_LABELS_THEN_HIDE) + { + Context->hdrs[Context->v2r[j]]->quasi_deleted = TRUE; + Context->changed = TRUE; + } } } nm_longrun_done(Context); @@ -1416,10 +1423,15 @@ int mutt_index_menu (void) } else { - if (nm_modify_message_tags(Context, CURHDR, buf, sizeof (buf))) { + if (nm_modify_message_tags(Context, CURHDR, buf)) { mutt_message _("Failed to modify labels, aborting."); break; } + if (op == OP_MAIN_MODIFY_LABELS_THEN_HIDE) + { + CURHDR->quasi_deleted = TRUE; + Context->changed = TRUE; + } if (option (OPTRESOLVE)) { if ((menu->current = ci_next_undeleted (menu->current)) == -1) @@ -1435,6 +1447,7 @@ int mutt_index_menu (void) } menu->redraw |= REDRAW_STATUS; break; + } case OP_MAIN_VFOLDER_FROM_QUERY: buf[0] = '\0'; diff --git a/functions.h b/functions.h index be524c23e..ef64deb5c 100644 --- a/functions.h +++ b/functions.h @@ -184,6 +184,7 @@ const struct binding_t OpMain[] = { /* map: index */ { "change-vfolder", OP_MAIN_CHANGE_VFOLDER, "X" }, { "vfolder-from-query", OP_MAIN_VFOLDER_FROM_QUERY, "\033X" }, { "modify-labels", OP_MAIN_MODIFY_LABELS, "`" }, + { "modify-labels-then-hide", OP_MAIN_MODIFY_LABELS_THEN_HIDE, NULL }, #endif { NULL, 0, NULL } }; @@ -304,6 +305,7 @@ const struct binding_t OpPager[] = { /* map: pager */ { "change-vfolder", OP_MAIN_CHANGE_VFOLDER, "X" }, { "vfolder-from-query", OP_MAIN_VFOLDER_FROM_QUERY, "\033X" }, { "modify-labels", OP_MAIN_MODIFY_LABELS, "`" }, + { "modify-labels-then-hide", OP_MAIN_MODIFY_LABELS_THEN_HIDE, NULL }, #endif { NULL, 0, NULL } diff --git a/mutt_notmuch.c b/mutt_notmuch.c index b04f60c04..43fa12f17 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -478,7 +478,7 @@ static notmuch_message_t *get_message(notmuch_database_t *db, HEADER *hdr) return id && db ? notmuch_database_find_message(db, id) : NULL; } -int nm_modify_message_tags(CONTEXT *ctx, HEADER *hdr, char *buf0, size_t bufsz) +int nm_modify_message_tags(CONTEXT *ctx, HEADER *hdr, char *buf0) { notmuch_database_t *db = NULL; notmuch_message_t *msg = NULL; diff --git a/mutt_notmuch.h b/mutt_notmuch.h index c2080d622..b2ec6f63f 100644 --- a/mutt_notmuch.h +++ b/mutt_notmuch.h @@ -14,7 +14,7 @@ char *nm_header_get_tags(HEADER *h); int nm_get_count(char *path, unsigned *all, unsigned *new); int nm_update_filename(CONTEXT *ctx, const char *old, const char *new); char *nm_uri_from_query(CONTEXT *ctx, char *buf, size_t bufsz); -int nm_modify_message_tags(CONTEXT *ctx, HEADER *hdr, char *buf, size_t bufsz); +int nm_modify_message_tags(CONTEXT *ctx, HEADER *hdr, char *tags); void nm_longrun_init(CONTEXT *cxt, int writable); void nm_longrun_done(CONTEXT *cxt);