From 979b4540f8aeb227eac3589cc80980615bf55701 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 3e8025137..e47950dc1 100644 --- 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 a0a399c11..9a37194e9 100644 --- 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 41493f91a..a96d09c1e 100644 --- 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 98b77ffac..98660daeb 100644 --- a/mutt.h +++ b/mutt.h @@ -352,6 +352,7 @@ enum OPTENVFROM, OPTFASTREPLY, OPTFCCCLEAR, + OPTFLAGSAFE, OPTFOLLOWUPTO, OPTFORCENAME, OPTFORWDECODE, -- 2.40.0