Commit eb838fec eb838fece8d5c38fb6fd4ea2b33d3982607acfff by Sergey Poznyakoff

guimb: further improvements

* libmu_scm/mu_body.c (mu-body?): New function.
* libmu_scm/mu_mailbox.c (mu-mailbox?): New function.
* libmu_scm/mu_message.c (mu-message?): New function.
* libmu_scm/mu_mime.c (mu-mime?): New function.
* scheme/guimb.scmi (guimb-process-mailbox): guimb-message returns
a message to be appended to the output mailbox.
1 parent 273e66dc
......@@ -95,6 +95,15 @@ mu_scm_body_create (SCM msg, mu_body_t body)
/* ************************************************************************* */
/* Guile primitives */
SCM_DEFINE_PUBLIC (scm_mu_body_p, "mu-body?", 1, 0, 0,
(SCM scm),
"Return @code{true} if @var{scm} is a Mailutils message body object.\n")
#define FUNC_NAME s_scm_mu_body_p
{
return mu_scm_is_body (scm);
}
#undef FUNC_NAME
SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
(SCM body),
"Read next line from the @var{body}.")
......
......@@ -136,6 +136,15 @@ mu_scm_is_mailbox (SCM scm)
/* ************************************************************************* */
/* Guile primitives */
SCM_DEFINE_PUBLIC (scm_mu_mailbox_p, "mu-mailbox?", 1, 0, 0,
(SCM scm),
"Return @code{true} if @var{scm} is a Mailutils mailbox.\n")
#define FUNC_NAME s_scm_mu_mailbox_p
{
return scm_from_bool (mu_scm_is_mailbox (scm));
}
#undef FUNC_NAME
SCM_DEFINE_PUBLIC (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
(SCM url),
"Do not use this function. Use mu-user-mailbox-url instead.")
......
......@@ -175,6 +175,15 @@ mu_scm_is_message (SCM scm)
/* ************************************************************************* */
/* Guile primitives */
SCM_DEFINE_PUBLIC (scm_mu_message_p, "mu-message?", 1, 0, 0,
(SCM scm),
"Return @code{true} if @var{scm} is a Mailutils message.\n")
#define FUNC_NAME s_scm_mu_message_p
{
return scm_from_bool (mu_scm_is_message (scm));
}
#undef FUNC_NAME
SCM_DEFINE_PUBLIC (scm_mu_message_create, "mu-message-create", 0, 0, 0,
(),
"Creates an empty message.\n")
......
......@@ -88,6 +88,15 @@ mu_scm_is_mime (SCM scm)
/* ************************************************************************* */
/* Guile primitives */
SCM_DEFINE_PUBLIC (scm_mu_mime_p, "mu-mime?", 1, 0, 0,
(SCM scm),
"Return @code{true} if @var{scm} is a Mailutils MIME object.\n")
#define FUNC_NAME s_scm_mu_mime_p
{
return scm_from_bool (mu_scm_is_mime (scm));
}
#undef FUNC_NAME
SCM_DEFINE_PUBLIC (scm_mu_mime_create, "mu-mime-create", 0, 2, 0,
(SCM flags, SCM mesg),
"Creates a new @acronym{MIME} object. Both arguments are optional.\n"
......
......@@ -49,22 +49,26 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (list (command-line)))" "$@"
(format #t "usage: guimb [OPTIONS] [MAILBOX [MAILBOX...]]
guimb applies a scheme function to each message from a set of input mailboxes
The following options stop argument processing, and pass all remaining
arguments as the value of (command-line):
The following options stop argument processing, and pass the remaining
arguments to the guimb-getopt function, if it is defined in the module:
-c, --code=EXPR execute given scheme expression
-s, --source=FILE load Scheme module from FILE.scm
-c, --code=EXPR execute given Scheme expression
-s, --source=MODNAME load Scheme module MODNAME
The following options do not affect further options parsing:
The following options have the same effect, but do not affect further
options parsing:
-e, --expression=EXPR execute given scheme expression
-f, --file=FILE load Scheme module from FILE.scm
-e, --expression=EXPR execute given Scheme expression
-f, --file=MODNAME load Scheme module MODNAME
The module to be loaded is normally defined in a file named MODNAME.scm
somewhere in your %load-path.
Other options:
-M, --mailbox=NAME set output mailbox name
-u, --user[=NAME] act as local MDA for user NAME (default - current
user)
-u, --user[=NAME] direct output to the system mailbox of the
user NAME (default - current user)
-r, --read-only open mailbox in read-only mode
Script arguments:
......@@ -250,9 +254,9 @@ for any corresponding short options.
(guimb-single-mailbox mbox)
(let msg-loop ((msg (mu-mailbox-first-message mbox)))
(if (not (eof-object? msg))
(begin
(if (guimb-message msg)
(mu-mailbox-append-message output-mailbox msg))
(let ((x (guimb-message msg)))
(if (mu-message? x)
(mu-mailbox-append-message output-mailbox x))
(msg-loop (mu-mailbox-next-message mbox)))))))
(define (guimb cmdline)
......