** evaluated; no alias expansion takes place; user-defined headers
** and signatures are not added to the message.
*/
+ { "resume_edited_draft_files", DT_BOOL, R_NONE, OPTRESUMEEDITEDDRAFTFILES, 1 },
+ /*
+ ** .pp
+ ** If \fIset\fP, draft files previously edited (via \fC-E -H\fP on
+ ** the command line) will have $$resume_draft_files automatically
+ ** set when they are used as a draft file again.
+ ** .pp
+ ** The first time a draft file is saved, mutt will add a header,
+ ** X-Mutt-Resume-Draft to the saved file. The next time the draft
+ ** file is read in, if mutt sees the header, it will set
+ ** $$resume_draft_files.
+ ** .pp
+ ** This option is designed to prevent multiple signatures,
+ ** user-defined headers, and other processing effects from being
+ ** made multiple times to the draft file.
+ */
{ "reverse_alias", DT_BOOL, R_BOTH, OPTREVALIAS, 0 },
/*
** .pp
HEADER *context_hdr = NULL;
ENVELOPE *opts_env = msg->env;
struct stat st;
+ LIST *uh, **last_uhp;
sendflags |= SENDDRAFTFILE;
context_hdr = mutt_new_header ();
context_hdr->offset = 0;
context_hdr->content = mutt_new_body ();
- fstat (fileno (fin), &st);
+ if (fstat (fileno (fin), &st))
+ {
+ perror (draftFile);
+ exit (1);
+ }
context_hdr->content->length = st.st_size;
mutt_prepare_template (fin, NULL, msg, context_hdr, 0);
+ /* Scan for mutt header to set OPTRESUMEDRAFTFILES */
+ for (last_uhp = &msg->env->userhdrs, uh = *last_uhp;
+ uh; uh = *last_uhp)
+ {
+ if (ascii_strncasecmp ("X-Mutt-Resume-Draft:", uh->data, 20) == 0)
+ {
+ if (option (OPTRESUMEEDITEDDRAFTFILES))
+ set_option (OPTRESUMEDRAFTFILES);
+
+ *last_uhp = uh->next;
+ uh->next = NULL;
+ mutt_free_list (&uh);
+ }
+ else
+ last_uhp = &uh->next;
+ }
+
rfc822_append (&msg->env->to, opts_env->to, 0);
rfc822_append (&msg->env->cc, opts_env->cc, 0);
rfc822_append (&msg->env->bcc, opts_env->bcc, 0);
}
mutt_write_rfc822_header (fout, msg->env, msg->content, -1, 0);
+ if (option (OPTRESUMEEDITEDDRAFTFILES))
+ fprintf (fout, "X-Mutt-Resume-Draft: 1\n");
fputc ('\n', fout);
if ((mutt_write_mime_body (msg->content, fout) == -1))
{