diff options
author | Kevin McCarthy <kevin@8t8.us> | 2016-03-08 15:57:55 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2016-03-08 15:57:55 -0800 |
commit | 29033a6fecce4430a6a8d6281b7ead8da253fb6b (patch) | |
tree | 7e092170e2a1529f7d93d60ae77e2a159797673b /main.c | |
parent | f28113671f789c7d64ae94c2092f5be6870fe311 (diff) |
Add $resume_edited_draft_files option.
This adds an extra header when saving edited draft files (-E -H on the
command line). With this header, the next time they are edited, they
are automatically "resumed" (by setting $resume_draft_files).
The idea is to prevent multiple user-defined headers and signatures
from being added to the draft message by avoiding processing it as a
brand new message after the first time.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -997,6 +997,7 @@ int main (int argc, char **argv) HEADER *context_hdr = NULL; ENVELOPE *opts_env = msg->env; struct stat st; + LIST *uh, **last_uhp; sendflags |= SENDDRAFTFILE; @@ -1006,11 +1007,32 @@ int main (int argc, char **argv) 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); @@ -1102,6 +1124,8 @@ int main (int argc, char **argv) } 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)) { |