From acebbaece94867b56e6ef6ff341495da92319cec Mon Sep 17 00:00:00 2001 From: David Champion Date: Wed, 16 Nov 2016 15:43:50 -0800 Subject: [PATCH] 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. --- flags.c | 3 ++- init.h | 5 +++++ mh.c | 7 +++++-- mutt.h | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/flags.c b/flags.c index a7a9ec992..cb297e424 100644 --- a/flags.c +++ b/flags.c @@ -48,7 +48,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 5e7adf57e..5c07f8e35 100644 --- a/init.h +++ b/init.h @@ -849,6 +849,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 4ce73ebf7..792e3b91c 100644 --- a/mh.c +++ b/mh.c @@ -704,8 +704,11 @@ 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 94291c147..c3d001d74 100644 --- a/mutt.h +++ b/mutt.h @@ -395,6 +395,7 @@ enum OPTENVFROM, OPTFASTREPLY, OPTFCCCLEAR, + OPTFLAGSAFE, OPTFOLLOWUPTO, OPTFORCENAME, OPTFORWDECODE, -- 2.40.0