From 8b38412151ce0cf12acf0ef3351adc5e27bf698f Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Wed, 16 Sep 1998 05:57:22 +0000 Subject: [PATCH] Introduce the OPTUSEHEADERDATE pseudo-option to control mutt_write_rfc822_header()'s behaviour for the purposes of the edit_message feature. --- compose.c | 6 +++++- curs_main.c | 4 +++- mutt.h | 4 ++-- sendlib.c | 10 ++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/compose.c b/compose.c index dee6689b1..43f1bfaaa 100644 --- a/compose.c +++ b/compose.c @@ -1063,16 +1063,20 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (mutt_enter_fname ("Write message to mailbox", fname, sizeof (fname), &menu->redraw, 1) != -1 && fname[0]) { + int oldhdrdate; mutt_message ("Writing message to %s ...", fname); mutt_expand_path (fname, sizeof (fname)); if (msg->content->next) msg->content = mutt_make_multipart (msg->content); - if (mutt_write_fcc (NONULL (fname), msg, NULL, 2) < 0) + oldhdrdate = option(OPTUSEHEADERDATE); + set_option(OPTUSEHEADERDATE); + if (mutt_write_fcc (NONULL (fname), msg, NULL, 1) < 0) msg->content = mutt_remove_multipart (msg->content); else mutt_message ("Message written."); + if(!oldhdrdate) unset_option(OPTUSEHEADERDATE); } break; diff --git a/curs_main.c b/curs_main.c index ec8652bd2..1179f4b87 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1485,8 +1485,10 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */) CHECK_MSGCOUNT; CHECK_READONLY; - + + set_option(OPTUSEHEADERDATE); ci_send_message (SENDEDITMSG, NULL, NULL, Context, CURHDR); + unset_option(OPTUSEHEADERDATE); menu->redraw = REDRAW_FULL; break; diff --git a/mutt.h b/mutt.h index 6e5d18cb7..bc89caf83 100644 --- a/mutt.h +++ b/mutt.h @@ -331,7 +331,8 @@ enum OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ OPTSORTCOLLAPSE, /* (pseudo) used by mutt_sort_headers() */ - + OPTUSEHEADERDATE, /* (pseudo) used by edit-message */ + #ifdef _PGPPATH OPTPGPCHECKTRUST, /* (pseudo) used by pgp_select_key () */ OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ @@ -340,7 +341,6 @@ enum - OPTMAX }; diff --git a/sendlib.c b/sendlib.c index 63c2239c2..d0d15c3d3 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1205,7 +1205,6 @@ static void write_references (LIST *r, FILE *f) * mode == 1 => "lite" mode (used for edit_hdrs) * mode == 0 => normal mode. write full header + MIME headers * mode == -1 => write just the envelope info (used for postponing messages) - * mode == -2 => just like -1, but write the Date: from the message (used for edit-message support) */ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, int mode) @@ -1213,15 +1212,16 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, int mode) char buffer[LONG_STRING]; LIST *tmp = env->userhdrs; - if (mode == 0) - fputs (mutt_make_date (buffer, sizeof(buffer)), fp); - else if (mode == -2) + if (option(OPTUSEHEADERDATE)) { if(env->date) fprintf(fp, "Date: %s\n", env->date); else fputs (mutt_make_date(buffer, sizeof(buffer)), fp); } + else if (mode == 0) + fputs (mutt_make_date (buffer, sizeof(buffer)), fp); + /* OPTUSEFROM is not consulted here so that we can still write a From: @@ -1876,8 +1876,6 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post) } /* post == 1 => postpone message. Set mode = -1 in mutt_write_rfc822_header() - * post == 2 => Editing this message. - * Set mode = -2 in mutt_write_rfc822_header() * post == 0 => Normal mode. Set mode = 0 in mutt_write_rfc822_header() * */ mutt_write_rfc822_header (msg->fp, hdr->env, hdr->content, post ? -post : 0); -- 2.40.0