flags.c |  3 ++-
 init.h  |  5 +++++
 mh.c    |  7 +++++--
 mutt.h  |  1 +
 4 files changed, 13 insertions(+), 3 deletions(-)


# HG changeset patch
# User David Champion <[email protected]>
# Date 1472599870 25200
#      Tue Aug 30 16:31:10 2016 -0700
# Node ID b8cc2b58219505f3d5f348a7dece9a3e1a3a96ee
# Parent  121fa0badf9e9d0ec311345c48827bed24edc754
When $flag_safe is set, flagged messages cannot be deleted.

This saves them from bulk operations on threads and tagged messages.  To
remove a flagged message, first unflag it.

diff --git a/flags.c b/flags.c
--- a/flags.c
+++ b/flags.c
@@ -45,7 +45,8 @@
 
       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
--- a/init.h
+++ b/init.h
@@ -798,6 +798,11 @@
   ** 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
--- a/mh.c
+++ b/mh.c
@@ -696,8 +696,11 @@
        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
--- a/mutt.h
+++ b/mutt.h
@@ -342,6 +342,7 @@
   OPTENVFROM,
   OPTFASTREPLY,
   OPTFCCCLEAR,
+  OPTFLAGSAFE,
   OPTFOLLOWUPTO,
   OPTFORCENAME,
   OPTFORWDECODE,

Reply via email to