1 diff -ur a/globals.h b/globals.h
2 --- a/globals.h 2010-05-28 17:16:31.000000000 -0400
3 +++ b/globals.h 2010-05-28 21:28:58.000000000 -0400
7 WHERE char *AssumedCharset;
8 +WHERE char *AttachKeyword;
10 WHERE char *Attribution;
11 WHERE char *AttachCharset;
12 diff -ur a/init.h b/init.h
13 --- a/init.h 2010-05-28 17:11:18.000000000 -0400
14 +++ b/init.h 2010-05-28 21:29:27.000000000 -0400
17 struct option_t MuttVars[] = {
19 + { "abort_noattach", DT_QUAD, R_NONE, OPT_ATTACH, M_ASKYES },
22 + ** If set to \fIyes\fP, when composing messages containing the word
23 + ** specified by $attach_keyword (default is "attach") and no attachments
24 + ** are given, composition will be aborted. If set to \fIno\fP, composing
25 + ** messages as such will never be aborted.
27 { "abort_nosubject", DT_QUAD, R_NONE, OPT_SUBJECT, M_ASKYES },
32 ** For an explanation of ``soft-fill'', see the $$index_format documentation.
34 + { "attach_keyword", DT_STR, R_NONE, UL &AttachKeyword, UL "attach" },
37 + ** If $abort_attach is not set to no, then the body of the message
38 + ** will be scanned for this keyword, and if found, you will be prompted
39 + ** if there are no attachments. This is case insensitive.
41 { "attach_sep", DT_STR, R_NONE, UL &AttachSep, UL "\n" },
44 diff -ur a/mutt.h b/mutt.h
45 --- a/mutt.h 2010-05-28 17:13:48.000000000 -0400
46 +++ b/mutt.h 2010-05-28 21:29:44.000000000 -0400
49 OPT_VERIFYSIG, /* verify PGP signatures */
51 + OPT_ATTACH, /* forgotten attachment detector */
53 /* THIS MUST BE THE LAST VALUE. */
56 diff -ur a/send.c b/send.c
57 --- a/send.c 2010-05-28 21:42:58.000000000 -0400
58 +++ b/send.c 2010-05-28 21:44:39.000000000 -0400
59 @@ -1113,6 +1113,34 @@
63 +mutt_search_attach_keyword(char* filename)
65 + /* searches for the magic keyword "attach" within a file */
67 + char* inputline = malloc(1024);
68 + char* lowerKeyword = malloc(strlen(AttachKeyword)+1);
69 + FILE *attf = fopen(filename, "r");
71 + for (i=0; i <= strlen(AttachKeyword); i++) {
72 + lowerKeyword[i] = tolower(AttachKeyword[i]);
74 + while (!feof(attf)) {
75 + fgets(inputline, 1024, attf);
76 + for (i=0; i < strlen(inputline); i++) {
77 + inputline[i] = tolower(inputline[i]);
79 + if (strstr(inputline, lowerKeyword)) {
91 ci_send_message (int flags, /* send mode */
92 HEADER *msg, /* template to use for new message */
93 char *tempfile, /* file specified by -i or -H */
94 @@ -1605,6 +1633,21 @@
98 + if (mutt_search_attach_keyword(msg->content->filename) &&
99 + !msg->content->next &&
100 + query_quadoption(OPT_ATTACH, _("No attachments, cancel sending?")) != M_NO)
102 + /* if the abort is automatic, print an error message */
103 + if (quadoption (OPT_ATTACH) == M_YES) {
104 + char errorstr[512];
105 + if (snprintf(errorstr, 512,
106 + "Message contains magic keyword \"%s\", but no attachments. Not sending.", AttachKeyword)==-1)
107 + errorstr[511] = 0; // terminate if need be. our string shouldnt be this long.
108 + mutt_error _(errorstr);
113 if (msg->content->next)
114 msg->content = mutt_make_multipart (msg->content);