Preserve flags & tags when re-editing a message
authorOlivier Brunel <jjk@jjacky.com>
Wed, 27 Dec 2017 20:59:40 +0000 (21:59 +0100)
committerColin Leroy <colin@colino.net>
Thu, 30 Aug 2018 14:14:39 +0000 (16:14 +0200)
When re-editing a message, let's preserve its flags (color labels, etc)
and tags. Can be especially useful for those who use such things on queued
messages, and find themselves re-editing messages afterwards but before
actually sending them.

src/compose.c

index 5583ba4..0cb01fb 100644 (file)
@@ -2366,6 +2366,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
        }
 
        compose->targetinfo = procmsg_msginfo_copy(msginfo);
+       compose->targetinfo->tags = g_slist_copy(msginfo->tags);
 
        compose_extract_original_charset(compose);
 
@@ -6300,6 +6301,20 @@ static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, Fold
        } else
                *msgpath = tmp;
 
+       if (compose->mode == COMPOSE_REEDIT && compose->targetinfo) {
+               MsgInfo *mi = folder_item_get_msginfo(queue, num);
+               if (mi) {
+                       procmsg_msginfo_change_flags(mi,
+                               compose->targetinfo->flags.perm_flags,
+                               compose->targetinfo->flags.tmp_flags & ~(MSG_COPY | MSG_MOVE | MSG_MOVE_DONE),
+                               0, 0);
+
+                       g_slist_free(mi->tags);
+                       mi->tags = g_slist_copy(compose->targetinfo->tags);
+                       procmsg_msginfo_free(&mi);
+               }
+       }
+
        if (compose->mode == COMPOSE_REEDIT && remove_reedit_target) {
                compose_remove_reedit_target(compose, FALSE);
        }