]> granicus.if.org Git - neomutt/commitdiff
add <modify-labels-then-hide>
authorKarel Zak <kzak@redhat.com>
Thu, 15 Dec 2011 20:59:54 +0000 (21:59 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 15:30:04 +0000 (16:30 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
OPS.NOTMUCH
README.notmuch
curs_main.c
functions.h
mutt_notmuch.c
mutt_notmuch.h

index 21b611dfae14513c41d5f483f2e209aa94fe59d5..c69691ccf044ca68191c84799c2bc7af0c2450c5 100644 (file)
@@ -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"
index b51774d69e331986f16157b54be8b04375b0e47e..dabddba35b9d16477186980d44c79b593e694612 100644 (file)
@@ -61,6 +61,17 @@ notmuch support for mutt
       - default key: `
       - example: "+AAA +BBB -CCC"
 
+   modify-labels-then-hide:
+      - same as <modify-labels> but message is marked by <quasi-delete>
+      - not mapped to any key
+      - example (add "archive" notmuch tag and remove message from screen):
+
+       macro index A "<modify-labels-then-hide>archive\n<sync-mailbox>"
+
+   quasi-delete:
+      - delete message from mutt (usualy after <sync-mailbox> function), but
+        don't touch message on disk
+
 
  * muttrc:
 
index 49715baf33a3a4a25526fd786fcd6065f7a269a4..fd670fd71f851012afc6ed5c42f66c348c584f44 100644 (file)
@@ -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';
index be524c23e1ee59c11f2dbc9284efde84e77af9a0..ef64deb5c6b831e850abcce70ffe728b520faf41 100644 (file)
@@ -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 }
index b04f60c049c87d50eeb26503658424cae21230cb..43fa12f17270336608a4124e0cd767539a995972 100644 (file)
@@ -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;
index c2080d622c60dc38ef8afd233531538776791be6..b2ec6f63f0c91e76b401308a1b2b1406ebc75f06 100644 (file)
@@ -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);