mh: minor changes in forw and repl; provide a set of traditional scan formats.
* mh/.gitignore: Update. * mh/compcommon.c (mh_comp_draft): Rewrite using mh_find_file and simplify. All callers changed. * mh/mh.h (mh_comp_draft): Change signature. * mh/comp.c (opt_handler) <ARGP_KEY_FINI>: Make sure formfile is initialized. * mh/forw.c: Likewise. * mh/repl.c (opt_handler): Remove unused variable. * mh/tests/comp.at (compcmd): Remove -form. * mh/tests/forw.at (forwcmd): Likewise. * mh/etc/.gitignore: New file. * mh/etc/Makefile.am: New file. * mh/etc/forwcomps: New file. * mh/etc/scan.default: New file. * mh/etc/scan.mailx: New file. * mh/etc/scan.size: New file. * mh/etc/scan.time: New file. * mh/etc/scan.timely: New file.
Showing
16 changed files
with
194 additions
and
50 deletions
... | @@ -8,14 +8,11 @@ ali | ... | @@ -8,14 +8,11 @@ ali |
8 | anno | 8 | anno |
9 | burst | 9 | burst |
10 | comp | 10 | comp |
11 | elc-stamp | ||
12 | fmtcheck | 11 | fmtcheck |
13 | folder | 12 | folder |
14 | forw | 13 | forw |
15 | inc | 14 | inc |
16 | install-mh | 15 | install-mh |
17 | mailutils-mh.el | ||
18 | mailutils-mh.elc | ||
19 | mark | 16 | mark |
20 | mh_alias.h | 17 | mh_alias.h |
21 | mh_alias_gram.c | 18 | mh_alias_gram.c | ... | ... |
... | @@ -146,6 +146,11 @@ opt_handler (int key, char *arg, struct argp_state *state) | ... | @@ -146,6 +146,11 @@ opt_handler (int key, char *arg, struct argp_state *state) |
146 | whatnowproc = NULL; | 146 | whatnowproc = NULL; |
147 | break; | 147 | break; |
148 | 148 | ||
149 | case ARGP_KEY_FINI: | ||
150 | if (!formfile) | ||
151 | mh_find_file ("components", &formfile); | ||
152 | break; | ||
153 | |||
149 | default: | 154 | default: |
150 | return ARGP_ERR_UNKNOWN; | 155 | return ARGP_ERR_UNKNOWN; |
151 | } | 156 | } |
... | @@ -294,7 +299,7 @@ main (int argc, char **argv) | ... | @@ -294,7 +299,7 @@ main (int argc, char **argv) |
294 | 299 | ||
295 | case DISP_REPLACE: | 300 | case DISP_REPLACE: |
296 | unlink (wh_env.draftfile); | 301 | unlink (wh_env.draftfile); |
297 | mh_comp_draft (formfile, "components", wh_env.file); | 302 | mh_comp_draft (formfile, wh_env.file); |
298 | } | 303 | } |
299 | } | 304 | } |
300 | 305 | ... | ... |
... | @@ -27,53 +27,44 @@ static char *default_format_str = | ... | @@ -27,53 +27,44 @@ static char *default_format_str = |
27 | "--------\n"; | 27 | "--------\n"; |
28 | 28 | ||
29 | void | 29 | void |
30 | mh_comp_draft (const char *formfile, const char *defformfile, | 30 | mh_comp_draft (const char *formfile, const char *draftfile) |
31 | const char *draftfile) | ||
32 | { | 31 | { |
33 | char *s = NULL; | 32 | char *s; |
34 | if (formfile) | 33 | |
34 | if (mh_find_file (formfile, &s) == 0) | ||
35 | { | 35 | { |
36 | s = mh_expand_name (MHLIBDIR, formfile, 0); | ||
37 | if (mh_file_copy (s, draftfile)) | 36 | if (mh_file_copy (s, draftfile)) |
38 | exit (1); | 37 | exit (1); |
38 | free (s); | ||
39 | } | 39 | } |
40 | else | 40 | else |
41 | { | 41 | { |
42 | s = mh_expand_name (MHLIBDIR, defformfile, 0); | 42 | /* I doubt if we need that: */ |
43 | if (access (s, R_OK) == 0) | 43 | int rc; |
44 | mu_stream_t stream; | ||
45 | |||
46 | if ((rc = mu_file_stream_create (&stream, | ||
47 | draftfile, | ||
48 | MU_STREAM_WRITE|MU_STREAM_CREAT))) | ||
44 | { | 49 | { |
45 | if (mh_file_copy (s, draftfile)) | 50 | mu_error (_("cannot open output file \"%s\": %s"), |
46 | exit (1); | 51 | draftfile, mu_strerror (rc)); |
52 | exit (1); | ||
47 | } | 53 | } |
48 | else | 54 | |
55 | rc = mu_stream_write (stream, | ||
56 | default_format_str, | ||
57 | strlen (default_format_str), NULL); | ||
58 | mu_stream_close (stream); | ||
59 | mu_stream_destroy (&stream); | ||
60 | |||
61 | if (rc) | ||
49 | { | 62 | { |
50 | int rc; | 63 | mu_error (_("error writing to \"%s\": %s"), |
51 | mu_stream_t stream; | 64 | draftfile, mu_strerror (rc)); |
52 | 65 | exit (1); | |
53 | if ((rc = mu_file_stream_create (&stream, | ||
54 | draftfile, | ||
55 | MU_STREAM_WRITE|MU_STREAM_CREAT))) | ||
56 | { | ||
57 | mu_error (_("cannot open output file \"%s\": %s"), | ||
58 | draftfile, mu_strerror (rc)); | ||
59 | exit (1); | ||
60 | } | ||
61 | |||
62 | rc = mu_stream_write (stream, | ||
63 | default_format_str, | ||
64 | strlen (default_format_str), NULL); | ||
65 | mu_stream_close (stream); | ||
66 | mu_stream_destroy (&stream); | ||
67 | |||
68 | if (rc) | ||
69 | { | ||
70 | mu_error (_("error writing to \"%s\": %s"), | ||
71 | draftfile, mu_strerror (rc)); | ||
72 | exit (1); | ||
73 | } | ||
74 | } | 66 | } |
75 | } | 67 | } |
76 | free (s); | ||
77 | } | 68 | } |
78 | 69 | ||
79 | int | 70 | int | ... | ... |
mh/etc/.gitignore
0 → 100644
mh/etc/Makefile.am
0 → 100644
1 | ## This file is part of GNU Mailutils. | ||
2 | ## Copyright (C) 2001, 2002, 2003, 2007, 2009, 2010 Free Software | ||
3 | ## Foundation, Inc. | ||
4 | ## | ||
5 | ## GNU Mailutils is free software; you can redistribute it and/or | ||
6 | ## modify it under the terms of the GNU General Public License as | ||
7 | ## published by the Free Software Foundation; either version 3, or (at | ||
8 | ## your option) any later version. | ||
9 | ## | ||
10 | ## GNU Mailutils is distributed in the hope that it will be useful, but | ||
11 | ## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | ## General Public License for more details. | ||
14 | ## | ||
15 | ## You should have received a copy of the GNU General Public License | ||
16 | ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | mhlibdir = $(pkgdatadir)/mh | ||
19 | |||
20 | LISPSRC = mailutils-mh.el | ||
21 | lisp_LISP = @lisp_LISP@ | ||
22 | EXTRA_LISP = mailutils-mh.el | ||
23 | |||
24 | MH_FILES = \ | ||
25 | components\ | ||
26 | forwcomps\ | ||
27 | mhl.format\ | ||
28 | mhl.forward\ | ||
29 | mhl.repl\ | ||
30 | mhl.usenet\ | ||
31 | replcomps\ | ||
32 | replgroupcomps\ | ||
33 | scan.default\ | ||
34 | scan.mailx\ | ||
35 | scan.size\ | ||
36 | scan.time\ | ||
37 | scan.timely | ||
38 | |||
39 | mhlib_DATA = $(MH_FILES) $(LISPSRC) | ||
40 | |||
41 | EXTRA_DIST = $(MH_FILES) mailutils-mh.eli | ||
42 | DISTCLEANFILES = mailutils-mh.el | ||
43 | |||
44 | SUFFIXES = .eli .el | ||
45 | mailutils-mh.el: mailutils-mh.eli | ||
46 | |||
47 | .eli.el: | ||
48 | sed "s,BINDIR,$(bindir),g;s,MHLIBDIR,$(mhlibdir),g" $< > $@ | ||
49 |
mh/etc/forwcomps
0 → 100644
mh/etc/scan.default
0 → 100644
1 | %; Default scan format GNU MH. | ||
2 | %; | ||
3 | %; GNU Mailutils -- a suite of utilities for electronic mail | ||
4 | %; Copyright (C) 2003, 2010 Free Software Foundation, Inc. | ||
5 | %; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>. | ||
6 | %; | ||
7 | %; NOTE: This file is not actually used and is supplied for your reference | ||
8 | %; only. It shows the default format string, which is compiled into | ||
9 | %; "scan". | ||
10 | %4(msg)\ | ||
11 | %<(cur)+%| %>\ | ||
12 | %<{replied}-%?{encrypted}E%| %>\ | ||
13 | %02(mon{date})/%02(mday{date})\ | ||
14 | %<{date} %|*%>\ | ||
15 | %<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\ | ||
16 | %<(zero)%17(decode(friendly{from}))%>\ | ||
17 | %(decode{subject})%<{body}<<%{body}>>%> | ||
18 | %; End of scan.default |
mh/etc/scan.mailx
0 → 100644
1 | %; Mimic the mailx(1) output. | ||
2 | %; | ||
3 | %; GNU Mailutils -- a suite of utilities for electronic mail | ||
4 | %; Copyright (C) 2003, 2010 Free Software Foundation, Inc. | ||
5 | %; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>. | ||
6 | %; | ||
7 | %<(cur)>%| %>\ | ||
8 | %<{status} %|N%>\ | ||
9 | %<{replied}R%?{encrypted}E%| %>\ | ||
10 | %4(msg) \ | ||
11 | %<(mymbox{from})%<{to}To: %13(decode(friendly{to}))%>%>\ | ||
12 | %<(zero)%17(decode(friendly{from}))%> \ | ||
13 | %3(day{date}) %3(month{date}) %02(mday{date}) \ | ||
14 | %02(hour{date}):%02(min{date}) \ | ||
15 | %(decode{subject}) | ||
16 | %; End of scan.mailx | ||
17 |
mh/etc/scan.size
0 → 100644
1 | %; "Size"-format for GNU MH scan. | ||
2 | %; | ||
3 | %; GNU Mailutils -- a suite of utilities for electronic mail | ||
4 | %; Copyright (C) 2003, 2010 Free Software Foundation, Inc. | ||
5 | %; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>. | ||
6 | %; | ||
7 | %; This format is similar to scan.default, except that it prints the | ||
8 | %; size of the message before the sender name column. | ||
9 | %; | ||
10 | %4(msg)\ | ||
11 | %<(cur)+%| %>\ | ||
12 | %<{replied}-%?{encrypted}E%| %>\ | ||
13 | %02(mon{date})/%02(mday{date})\ | ||
14 | %<{date} %|*%>\ | ||
15 | %5(size) \ | ||
16 | %<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\ | ||
17 | %<(zero)%17(decode(friendly{from}))%>\ | ||
18 | %(decode{subject})%<{body}<<%{body}%> | ||
19 | %; End of scan.size |
mh/etc/scan.time
0 → 100644
1 | %; "Time"-format for GNU MH scan. | ||
2 | %; | ||
3 | %; GNU Mailutils -- a suite of utilities for electronic mail | ||
4 | %; Copyright (C) 2003, 2010 Free Software Foundation, Inc. | ||
5 | %; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>. | ||
6 | %; | ||
7 | %; This format is similar to scan.default, except that it prints the | ||
8 | %; date in 1-minute resolution and adds a timezone. | ||
9 | %; | ||
10 | %4(msg)\ | ||
11 | %<(cur)+%| %>\ | ||
12 | %<{replied}-%?{encrypted}E%| %>\ | ||
13 | %02(mon{date})/%02(mday{date})\ | ||
14 | %02(hour{date}):%02(min{date})%3(tzone{date})\ | ||
15 | %<{date} %|*%>\ | ||
16 | %<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\ | ||
17 | %<(zero)%17(decode(friendly{from}))%>\ | ||
18 | %(decode{subject})%<{body}<<%{body}%> | ||
19 | %; End of scan.time |
mh/etc/scan.timely
0 → 100644
1 | %; "Timely"-format for GNU MH scan. | ||
2 | %; | ||
3 | %; GNU Mailutils -- a suite of utilities for electronic mail | ||
4 | %; Copyright (C) 2003, 2010 Free Software Foundation, Inc. | ||
5 | %; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>. | ||
6 | %; | ||
7 | %; The time output in this format depends on the time difference between | ||
8 | %; the current time and the time being printed. | ||
9 | %; | ||
10 | %4(msg)\ | ||
11 | %<(cur)+%| %>\ | ||
12 | %<{replied}-%?{encrypted}E%| %>\ | ||
13 | %(void(rclock{date}))\ | ||
14 | %<(gt 15768000)%03(month{date})%(void(year{date}))%02(modulo 100)\ | ||
15 | %?(gt 604800)%02(mday{date})%03(month{date})\ | ||
16 | %?(gt 86400) %(day{date}) %|\ | ||
17 | %02(hour{date}):%02(min{date})%>\ | ||
18 | %<{date} %|*%>\ | ||
19 | %<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\ | ||
20 | %<(zero)%17(decode(friendly{from}))%>\ | ||
21 | %(decode{subject})%<{body}<<%{body}%> | ||
22 | %; End of scan.timely | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -225,6 +225,11 @@ opt_handler (int key, char *arg, struct argp_state *state) | ... | @@ -225,6 +225,11 @@ opt_handler (int key, char *arg, struct argp_state *state) |
225 | whatnowproc = NULL; | 225 | whatnowproc = NULL; |
226 | break; | 226 | break; |
227 | 227 | ||
228 | case ARGP_KEY_FINI: | ||
229 | if (!formfile) | ||
230 | mh_find_file ("forwcomps", &formfile); | ||
231 | break; | ||
232 | |||
228 | default: | 233 | default: |
229 | return ARGP_ERR_UNKNOWN; | 234 | return ARGP_ERR_UNKNOWN; |
230 | } | 235 | } |
... | @@ -522,7 +527,7 @@ main (int argc, char **argv) | ... | @@ -522,7 +527,7 @@ main (int argc, char **argv) |
522 | 527 | ||
523 | case DISP_REPLACE: | 528 | case DISP_REPLACE: |
524 | unlink (wh_env.draftfile); | 529 | unlink (wh_env.draftfile); |
525 | mh_comp_draft (formfile, "forwcomps", wh_env.file); | 530 | mh_comp_draft (formfile, wh_env.file); |
526 | finish_draft (); | 531 | finish_draft (); |
527 | } | 532 | } |
528 | 533 | ... | ... |
... | @@ -378,8 +378,7 @@ int mh_seq_delete (mu_mailbox_t mbox, const char *name, mh_msgset_t *mset, | ... | @@ -378,8 +378,7 @@ int mh_seq_delete (mu_mailbox_t mbox, const char *name, mh_msgset_t *mset, |
378 | int flags); | 378 | int flags); |
379 | const char *mh_seq_read (mu_mailbox_t mbox, const char *name, int flags); | 379 | const char *mh_seq_read (mu_mailbox_t mbox, const char *name, int flags); |
380 | 380 | ||
381 | void mh_comp_draft (const char *formfile, const char *defformfile, | 381 | void mh_comp_draft (const char *formfile, const char *draftfile); |
382 | const char *draftfile); | ||
383 | int check_draft_disposition (struct mh_whatnow_env *wh, int use_draft); | 382 | int check_draft_disposition (struct mh_whatnow_env *wh, int use_draft); |
384 | 383 | ||
385 | void ali_parse_error (const char *fmt, ...) MU_PRINTFLIKE(1,2); | 384 | void ali_parse_error (const char *fmt, ...) MU_PRINTFLIKE(1,2); | ... | ... |
... | @@ -139,8 +139,6 @@ decode_cc_flag (const char *opt, const char *arg) | ... | @@ -139,8 +139,6 @@ decode_cc_flag (const char *opt, const char *arg) |
139 | static error_t | 139 | static error_t |
140 | opt_handler (int key, char *arg, struct argp_state *state) | 140 | opt_handler (int key, char *arg, struct argp_state *state) |
141 | { | 141 | { |
142 | char *s; | ||
143 | |||
144 | switch (key) | 142 | switch (key) |
145 | { | 143 | { |
146 | case ARGP_KEY_INIT: | 144 | case ARGP_KEY_INIT: | ... | ... |
... | @@ -15,9 +15,7 @@ | ... | @@ -15,9 +15,7 @@ |
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | m4_pushdef([MH_KEYWORDS],[comp]) | 17 | m4_pushdef([MH_KEYWORDS],[comp]) |
18 | m4_pushdef([compcmd],[comp dnl | 18 | m4_pushdef([compcmd],[comp -editor $abs_top_srcdir/mh/tests/mhed]) |
19 | -form components dnl | ||
20 | -editor $abs_top_srcdir/mh/tests/mhed]) | ||
21 | 19 | ||
22 | MH_CHECK([comp -file],[comp00 comp-file],[ | 20 | MH_CHECK([comp -file],[comp00 comp-file],[ |
23 | dir=`pwd` | 21 | dir=`pwd` | ... | ... |
... | @@ -15,9 +15,7 @@ | ... | @@ -15,9 +15,7 @@ |
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | m4_pushdef([MH_KEYWORDS],[forw]) | 17 | m4_pushdef([MH_KEYWORDS],[forw]) |
18 | m4_pushdef([forwcmd],[forw dnl | 18 | m4_pushdef([forwcmd],[forw -editor $abs_top_srcdir/mh/tests/mhed]) |
19 | -form components dnl | ||
20 | -editor $abs_top_srcdir/mh/tests/mhed]) | ||
21 | 19 | ||
22 | MH_CHECK([forw msg],[forw00 forw-msg],[ | 20 | MH_CHECK([forw msg],[forw00 forw-msg],[ |
23 | mkdir Mail/inbox | 21 | mkdir Mail/inbox | ... | ... |
-
Please register or sign in to post a comment