Commit 6f0bcf0a 6f0bcf0acfa68bbd771917d1a6fd0f4e9b574608 by Sergey Poznyakoff

Implemented -group.

1 parent d03fb2bd
Showing 1 changed file with 26 additions and 1 deletions
...@@ -45,6 +45,8 @@ static struct argp_option options[] = { ...@@ -45,6 +45,8 @@ static struct argp_option options[] = {
45 {"nocc", ARG_NOCC, "{all|to|cc|me}", 0, 45 {"nocc", ARG_NOCC, "{all|to|cc|me}", 0,
46 N_("Specify whom to remove from the Cc: list of the reply")}, 46 N_("Specify whom to remove from the Cc: list of the reply")},
47 {"folder", ARG_FOLDER, N_("FOLDER"), 0, N_("Specify folder to operate upon")}, 47 {"folder", ARG_FOLDER, N_("FOLDER"), 0, N_("Specify folder to operate upon")},
48 {"group", ARG_GROUP, N_("BOOL"), OPTION_ARG_OPTIONAL,
49 N_("Construct a group or followup reply") },
48 {"editor", ARG_EDITOR, N_("PROG"), 0, N_("Set the editor program to use")}, 50 {"editor", ARG_EDITOR, N_("PROG"), 0, N_("Set the editor program to use")},
49 {"noedit", ARG_NOEDIT, 0, 0, N_("Suppress the initial edit")}, 51 {"noedit", ARG_NOEDIT, 0, 0, N_("Suppress the initial edit")},
50 {"fcc", ARG_FCC, N_("FOLDER"), 0, N_("* Set the folder to receive Fcc's.")}, 52 {"fcc", ARG_FCC, N_("FOLDER"), 0, N_("* Set the folder to receive Fcc's.")},
...@@ -84,6 +86,7 @@ struct mh_option mh_option[] = { ...@@ -84,6 +86,7 @@ struct mh_option mh_option[] = {
84 {"fcc", 1, MH_OPT_ARG, "folder"}, 86 {"fcc", 1, MH_OPT_ARG, "folder"},
85 {"filter", 2, MH_OPT_ARG, "program"}, 87 {"filter", 2, MH_OPT_ARG, "program"},
86 {"format", 2, MH_OPT_BOOL }, 88 {"format", 2, MH_OPT_BOOL },
89 {"group", 1, MH_OPT_BOOL },
87 {"inplace", 1, MH_OPT_BOOL }, 90 {"inplace", 1, MH_OPT_BOOL },
88 {"query", 1, MH_OPT_BOOL }, 91 {"query", 1, MH_OPT_BOOL },
89 {"whatnowproc", 2, MH_OPT_ARG, "program"}, 92 {"whatnowproc", 2, MH_OPT_ARG, "program"},
...@@ -91,7 +94,7 @@ struct mh_option mh_option[] = { ...@@ -91,7 +94,7 @@ struct mh_option mh_option[] = {
91 { 0 } 94 { 0 }
92 }; 95 };
93 96
94 static char *format_str = 97 static char default_format_str[] =
95 "%(lit)%(formataddr %<{reply-to}%?{from}%?{sender}%?{return-path}%>)" 98 "%(lit)%(formataddr %<{reply-to}%?{from}%?{sender}%?{return-path}%>)"
96 "%<(nonnull)%(void(width))%(putaddr To: )\\n%>" 99 "%<(nonnull)%(void(width))%(putaddr To: )\\n%>"
97 "%(lit)%<(rcpt to)%(formataddr{to})%>%<(rcpt cc)%(formataddr{cc})%>%<(rcpt me)%(formataddr(me))%>" 100 "%(lit)%<(rcpt to)%(formataddr{to})%>%<(rcpt cc)%(formataddr{cc})%>%<(rcpt me)%(formataddr(me))%>"
...@@ -103,6 +106,7 @@ static char *format_str = ...@@ -103,6 +106,7 @@ static char *format_str =
103 "X-Mailer: MH \\(%(package_string)\\)\\n" 106 "X-Mailer: MH \\(%(package_string)\\)\\n"
104 "--------\n"; 107 "--------\n";
105 108
109 static char *format_str = NULL;
106 static mh_format_t format; 110 static mh_format_t format;
107 static int width = 80; 111 static int width = 80;
108 112
...@@ -159,11 +163,27 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) ...@@ -159,11 +163,27 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
159 break; 163 break;
160 164
161 case ARG_FORM: 165 case ARG_FORM:
166 free (format_str);
167 format_str = NULL;
162 s = mh_expand_name (MHLIBDIR, arg, 0); 168 s = mh_expand_name (MHLIBDIR, arg, 0);
163 mh_read_formfile (s, &format_str); 169 mh_read_formfile (s, &format_str);
164 free (s); 170 free (s);
165 break; 171 break;
166 172
173 case ARG_GROUP:
174 if (is_true (arg))
175 {
176 s = mh_expand_name (MHLIBDIR, "replgroupcomps", 0);
177 mh_read_formfile (s, &format_str);
178 free (s);
179 }
180 else
181 {
182 free (format_str);
183 format_str = NULL;
184 }
185 break;
186
167 case ARG_DRAFTMESSAGE: 187 case ARG_DRAFTMESSAGE:
168 wh_env.draftmessage = arg; 188 wh_env.draftmessage = arg;
169 break; 189 break;
...@@ -219,6 +239,11 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) ...@@ -219,6 +239,11 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
219 mh_license (argp_program_version); 239 mh_license (argp_program_version);
220 break; 240 break;
221 241
242 case ARGP_KEY_FINI:
243 if (!format_str)
244 format_str = default_format_str;
245 break;
246
222 default: 247 default:
223 return 1; 248 return 1;
224 } 249 }
......