Commit c3b9cfe4 c3b9cfe405a73936906f5c81d83a1fa190c932f8 by Sergey Poznyakoff

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.
1 parent e53b5587
......@@ -8,14 +8,11 @@ ali
anno
burst
comp
elc-stamp
fmtcheck
folder
forw
inc
install-mh
mailutils-mh.el
mailutils-mh.elc
mark
mh_alias.h
mh_alias_gram.c
......
......@@ -146,6 +146,11 @@ opt_handler (int key, char *arg, struct argp_state *state)
whatnowproc = NULL;
break;
case ARGP_KEY_FINI:
if (!formfile)
mh_find_file ("components", &formfile);
break;
default:
return ARGP_ERR_UNKNOWN;
}
......@@ -294,7 +299,7 @@ main (int argc, char **argv)
case DISP_REPLACE:
unlink (wh_env.draftfile);
mh_comp_draft (formfile, "components", wh_env.file);
mh_comp_draft (formfile, wh_env.file);
}
}
......
......@@ -27,53 +27,44 @@ static char *default_format_str =
"--------\n";
void
mh_comp_draft (const char *formfile, const char *defformfile,
const char *draftfile)
mh_comp_draft (const char *formfile, const char *draftfile)
{
char *s = NULL;
if (formfile)
char *s;
if (mh_find_file (formfile, &s) == 0)
{
s = mh_expand_name (MHLIBDIR, formfile, 0);
if (mh_file_copy (s, draftfile))
exit (1);
free (s);
}
else
{
s = mh_expand_name (MHLIBDIR, defformfile, 0);
if (access (s, R_OK) == 0)
/* I doubt if we need that: */
int rc;
mu_stream_t stream;
if ((rc = mu_file_stream_create (&stream,
draftfile,
MU_STREAM_WRITE|MU_STREAM_CREAT)))
{
if (mh_file_copy (s, draftfile))
exit (1);
mu_error (_("cannot open output file \"%s\": %s"),
draftfile, mu_strerror (rc));
exit (1);
}
else
rc = mu_stream_write (stream,
default_format_str,
strlen (default_format_str), NULL);
mu_stream_close (stream);
mu_stream_destroy (&stream);
if (rc)
{
int rc;
mu_stream_t stream;
if ((rc = mu_file_stream_create (&stream,
draftfile,
MU_STREAM_WRITE|MU_STREAM_CREAT)))
{
mu_error (_("cannot open output file \"%s\": %s"),
draftfile, mu_strerror (rc));
exit (1);
}
rc = mu_stream_write (stream,
default_format_str,
strlen (default_format_str), NULL);
mu_stream_close (stream);
mu_stream_destroy (&stream);
if (rc)
{
mu_error (_("error writing to \"%s\": %s"),
draftfile, mu_strerror (rc));
exit (1);
}
mu_error (_("error writing to \"%s\": %s"),
draftfile, mu_strerror (rc));
exit (1);
}
}
free (s);
}
int
......
elc-stamp
mailutils-mh.el
mailutils-mh.elc
## This file is part of GNU Mailutils.
## Copyright (C) 2001, 2002, 2003, 2007, 2009, 2010 Free Software
## Foundation, Inc.
##
## GNU Mailutils is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3, or (at
## your option) any later version.
##
## GNU Mailutils is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
mhlibdir = $(pkgdatadir)/mh
LISPSRC = mailutils-mh.el
lisp_LISP = @lisp_LISP@
EXTRA_LISP = mailutils-mh.el
MH_FILES = \
components\
forwcomps\
mhl.format\
mhl.forward\
mhl.repl\
mhl.usenet\
replcomps\
replgroupcomps\
scan.default\
scan.mailx\
scan.size\
scan.time\
scan.timely
mhlib_DATA = $(MH_FILES) $(LISPSRC)
EXTRA_DIST = $(MH_FILES) mailutils-mh.eli
DISTCLEANFILES = mailutils-mh.el
SUFFIXES = .eli .el
mailutils-mh.el: mailutils-mh.eli
.eli.el:
sed "s,BINDIR,$(bindir),g;s,MHLIBDIR,$(mhlibdir),g" $< > $@
;; Default forward components file for GNU MH.
;; Lines beginning with ; are ignored. Rest of lines is copied verbatim.
To:
cc:
Subject:
--------
%; Default scan format GNU MH.
%;
%; GNU Mailutils -- a suite of utilities for electronic mail
%; Copyright (C) 2003, 2010 Free Software Foundation, Inc.
%; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>.
%;
%; NOTE: This file is not actually used and is supplied for your reference
%; only. It shows the default format string, which is compiled into
%; "scan".
%4(msg)\
%<(cur)+%| %>\
%<{replied}-%?{encrypted}E%| %>\
%02(mon{date})/%02(mday{date})\
%<{date} %|*%>\
%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
%<(zero)%17(decode(friendly{from}))%>\
%(decode{subject})%<{body}<<%{body}>>%>
%; End of scan.default
%; Mimic the mailx(1) output.
%;
%; GNU Mailutils -- a suite of utilities for electronic mail
%; Copyright (C) 2003, 2010 Free Software Foundation, Inc.
%; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>.
%;
%<(cur)>%| %>\
%<{status} %|N%>\
%<{replied}R%?{encrypted}E%| %>\
%4(msg) \
%<(mymbox{from})%<{to}To: %13(decode(friendly{to}))%>%>\
%<(zero)%17(decode(friendly{from}))%> \
%3(day{date}) %3(month{date}) %02(mday{date}) \
%02(hour{date}):%02(min{date}) \
%(decode{subject})
%; End of scan.mailx
%; "Size"-format for GNU MH scan.
%;
%; GNU Mailutils -- a suite of utilities for electronic mail
%; Copyright (C) 2003, 2010 Free Software Foundation, Inc.
%; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>.
%;
%; This format is similar to scan.default, except that it prints the
%; size of the message before the sender name column.
%;
%4(msg)\
%<(cur)+%| %>\
%<{replied}-%?{encrypted}E%| %>\
%02(mon{date})/%02(mday{date})\
%<{date} %|*%>\
%5(size) \
%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
%<(zero)%17(decode(friendly{from}))%>\
%(decode{subject})%<{body}<<%{body}%>
%; End of scan.size
%; "Time"-format for GNU MH scan.
%;
%; GNU Mailutils -- a suite of utilities for electronic mail
%; Copyright (C) 2003, 2010 Free Software Foundation, Inc.
%; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>.
%;
%; This format is similar to scan.default, except that it prints the
%; date in 1-minute resolution and adds a timezone.
%;
%4(msg)\
%<(cur)+%| %>\
%<{replied}-%?{encrypted}E%| %>\
%02(mon{date})/%02(mday{date})\
%02(hour{date}):%02(min{date})%3(tzone{date})\
%<{date} %|*%>\
%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
%<(zero)%17(decode(friendly{from}))%>\
%(decode{subject})%<{body}<<%{body}%>
%; End of scan.time
%; "Timely"-format for GNU MH scan.
%;
%; GNU Mailutils -- a suite of utilities for electronic mail
%; Copyright (C) 2003, 2010 Free Software Foundation, Inc.
%; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>.
%;
%; The time output in this format depends on the time difference between
%; the current time and the time being printed.
%;
%4(msg)\
%<(cur)+%| %>\
%<{replied}-%?{encrypted}E%| %>\
%(void(rclock{date}))\
%<(gt 15768000)%03(month{date})%(void(year{date}))%02(modulo 100)\
%?(gt 604800)%02(mday{date})%03(month{date})\
%?(gt 86400) %(day{date}) %|\
%02(hour{date}):%02(min{date})%>\
%<{date} %|*%>\
%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
%<(zero)%17(decode(friendly{from}))%>\
%(decode{subject})%<{body}<<%{body}%>
%; End of scan.timely
\ No newline at end of file
......@@ -225,6 +225,11 @@ opt_handler (int key, char *arg, struct argp_state *state)
whatnowproc = NULL;
break;
case ARGP_KEY_FINI:
if (!formfile)
mh_find_file ("forwcomps", &formfile);
break;
default:
return ARGP_ERR_UNKNOWN;
}
......@@ -522,7 +527,7 @@ main (int argc, char **argv)
case DISP_REPLACE:
unlink (wh_env.draftfile);
mh_comp_draft (formfile, "forwcomps", wh_env.file);
mh_comp_draft (formfile, wh_env.file);
finish_draft ();
}
......
......@@ -378,8 +378,7 @@ int mh_seq_delete (mu_mailbox_t mbox, const char *name, mh_msgset_t *mset,
int flags);
const char *mh_seq_read (mu_mailbox_t mbox, const char *name, int flags);
void mh_comp_draft (const char *formfile, const char *defformfile,
const char *draftfile);
void mh_comp_draft (const char *formfile, const char *draftfile);
int check_draft_disposition (struct mh_whatnow_env *wh, int use_draft);
void ali_parse_error (const char *fmt, ...) MU_PRINTFLIKE(1,2);
......
......@@ -139,8 +139,6 @@ decode_cc_flag (const char *opt, const char *arg)
static error_t
opt_handler (int key, char *arg, struct argp_state *state)
{
char *s;
switch (key)
{
case ARGP_KEY_INIT:
......
......@@ -15,9 +15,7 @@
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([MH_KEYWORDS],[comp])
m4_pushdef([compcmd],[comp dnl
-form components dnl
-editor $abs_top_srcdir/mh/tests/mhed])
m4_pushdef([compcmd],[comp -editor $abs_top_srcdir/mh/tests/mhed])
MH_CHECK([comp -file],[comp00 comp-file],[
dir=`pwd`
......
......@@ -15,9 +15,7 @@
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([MH_KEYWORDS],[forw])
m4_pushdef([forwcmd],[forw dnl
-form components dnl
-editor $abs_top_srcdir/mh/tests/mhed])
m4_pushdef([forwcmd],[forw -editor $abs_top_srcdir/mh/tests/mhed])
MH_CHECK([forw msg],[forw00 forw-msg],[
mkdir Mail/inbox
......