]> granicus.if.org Git - neomutt/commitdiff
When $flag_safe is set, flagged messages cannot be deleted.
authorDavid Champion <dgc@bikeshed.us>
Wed, 16 Nov 2016 23:43:50 +0000 (15:43 -0800)
committerDavid Champion <dgc@bikeshed.us>
Wed, 16 Nov 2016 23:43:50 +0000 (15:43 -0800)
This saves them from bulk operations on threads and tagged messages.  To
remove a flagged message, first unflag it.

flags.c
init.h
mh.c
mutt.h

diff --git a/flags.c b/flags.c
index 3e80251372dab11c7daceaf219fa23621db0e702..e47950dc171dd6c5c7e5fd592c9d3d95fea9a790 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -45,7 +45,8 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
 
       if (bf)
       {
-       if (!h->deleted && !ctx->readonly)
+       if (!h->deleted && !ctx->readonly
+           && (!h->flagged || !option(OPTFLAGSAFE)))
        {
          h->deleted = 1;
           update = 1;
diff --git a/init.h b/init.h
index a0a399c11530069bf46cdbddb59ff3d822af1366..9a37194e9b29ca8944e50a8542936034d27bfbdb 100644 (file)
--- a/init.h
+++ b/init.h
@@ -799,6 +799,11 @@ struct option_t MuttVars[] = {
   ** signed.
   ** (PGP only)
   */
+  { "flag_safe", DT_BOOL, R_NONE, OPTFLAGSAFE, 0 },
+  /*
+  ** .pp
+  ** If set, flagged messages cannot be deleted.
+  */
   { "folder",          DT_PATH, R_NONE, UL &Maildir, UL "~/Mail" },
   /*
   ** .pp
diff --git a/mh.c b/mh.c
index 41493f91a1a446b61dcad7b4102d63c1bc82abad..a96d09c1e6348817bc87f46c4deeb47827848ce0 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -696,8 +696,11 @@ static void maildir_parse_flags (HEADER * h, const char *path)
        break;
 
       case 'T':                /* trashed */
-       h->trash = 1;
-       h->deleted = 1;
+       if (!h->flagged || !option(OPTFLAGSAFE))
+       {
+         h->trash = 1;
+         h->deleted = 1;
+       }
        break;
       
       default:
diff --git a/mutt.h b/mutt.h
index 98b77ffac834483e0da36eb43039ede79c269b89..98660daeb8052f4542994147280332c9e77e36a3 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -352,6 +352,7 @@ enum
   OPTENVFROM,
   OPTFASTREPLY,
   OPTFCCCLEAR,
+  OPTFLAGSAFE,
   OPTFOLLOWUPTO,
   OPTFORCENAME,
   OPTFORWDECODE,