mirror of https://github.com/djcb/mu.git
* cosmetics
This commit is contained in:
parent
ebb3df2e2b
commit
dce908cf93
|
@ -8,15 +8,14 @@
|
|||
`guile'[1] is an interpreter/library for the Scheme programming language[2],
|
||||
specifically meant for extending other programs. It is, in fact, the
|
||||
official GNU language for doing so. 'muile' requires guile 2.x to get the full
|
||||
support.
|
||||
support.
|
||||
|
||||
older versions will not support e.g. the 'mu-stats.scm' things
|
||||
discussed below.
|
||||
Older versions may not support e.g. the 'mu-stats.scm' things discussed below.
|
||||
|
||||
The combination of mu + guile is called `muile', and allows you to write
|
||||
little Scheme-programs to query the mu-database, or inspect individual
|
||||
messages. It is still in an experimental stage, but useful already.
|
||||
|
||||
|
||||
** How do I get it?
|
||||
|
||||
The git-version and the future 0.9.7 version of mu will automatically build
|
||||
|
@ -29,7 +28,7 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
created, as well.
|
||||
|
||||
** What can I do with it?
|
||||
|
||||
|
||||
Go to toys/muile and start muile. You'll end up with a guile-shell where you
|
||||
can type scheme [1], it looks something like this (for guile 2.x):
|
||||
|
||||
|
@ -40,14 +39,14 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
Now, let's load a message (of course, replace with a message on your system):
|
||||
|
||||
,----
|
||||
| scheme@(guile-user)> (define msg (mu:msg:make-from-file "/home/djcb/Maildir/cur/12131e7b20a2:2,S"))
|
||||
| scheme@(guile-user)> (define msg (mu:msg:make-from-file "/home/djcb/Maildir/cur/12131e7b20a2:2,S"))
|
||||
`----
|
||||
|
||||
This defines a variable 'msg', which holds some message on your file
|
||||
system. It's now easy to inspect this message:
|
||||
|
||||
,----
|
||||
| scheme@(guile-user)> (define msg (mu:msg:make-from-file "/home/djcb/Maildir/cur/12131e7b20a2:2,S"))
|
||||
| scheme@(guile-user)> (define msg (mu:msg:make-from-file "/home/djcb/Maildir/cur/12131e7b20a2:2,S"))
|
||||
`----
|
||||
|
||||
Now, we can inspect this message a bit:
|
||||
|
@ -57,17 +56,17 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
| scheme@(guile-user)> (mu:msg:flags msg)
|
||||
| $2 = (mu:attach mu:unread)
|
||||
`----
|
||||
|
||||
|
||||
and so on. Note, it's probably easiest to explore the various mu: methods
|
||||
using autocompletion; to enable that make sure you have
|
||||
|
||||
|
||||
|
||||
,----
|
||||
| (use-modules (ice-9 readline))
|
||||
| (activate-readline)
|
||||
`----
|
||||
|
||||
in your ~/.guile configuration.
|
||||
in your ~/.guile configuration.
|
||||
|
||||
** does this tool have some parameters?
|
||||
|
||||
|
@ -79,7 +78,7 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
example:
|
||||
|
||||
,----
|
||||
| ./muile --msg=~/Maildir/inbox/cur/1311310172_1234:2,S
|
||||
| ./muile --msg=~/Maildir/inbox/cur/1311310172_1234:2,S
|
||||
| [...]
|
||||
| scheme@(guile-user)> mu:current-msg
|
||||
| $1 = #<msg /home/djcb/Maildir/inbox/cur/1311310172_1234:2,S>
|
||||
|
@ -92,7 +91,7 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
That's easy, too - it does require a little more scheme knowledge. For
|
||||
searching messages there is the mu:store:for-each function, which takes two
|
||||
arguments; the first argument is a function that will be called for each
|
||||
message found. The optional second argument is the search expression (following
|
||||
message found. The optional second argument is the search expression (following
|
||||
'mu find' syntax); if don't provide the argument, all messages match.
|
||||
|
||||
So how does this work in practice? Let's see I want to see the subject and
|
||||
|
@ -105,9 +104,9 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
or slightly more readable:
|
||||
|
||||
,----
|
||||
| (mu:store:for-each
|
||||
| (lambda(msg)
|
||||
| (format #t "~s ~s\n" (mu:msg:from msg) (mu:msg:subject msg)))
|
||||
| (mu:store:for-each
|
||||
| (lambda(msg)
|
||||
| (format #t "~s ~s\n" (mu:msg:from msg) (mu:msg:subject msg)))
|
||||
| "milk")
|
||||
`----
|
||||
|
||||
|
@ -116,7 +115,7 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
Scheme-knowledge... but this time is good as any to learn this nice
|
||||
language.
|
||||
|
||||
|
||||
|
||||
** Can I do some statistics on my messages?
|
||||
|
||||
Yes you can. In fact, it's pretty easy. If you load (in the muile/ directory)
|
||||
|
@ -134,9 +133,9 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
| scheme@(guile-user)> (mu:stats:per-weekday)
|
||||
| $1 = ((0 . 2255) (1 . 2788) (2 . 2868) (3 . 2599) (4 . 2629) (5 . 2287) (6 . 1851))
|
||||
`----
|
||||
|
||||
|
||||
Note, Sunday=0, Monday=1 and so on. Apparently, I get/send most of e-mail on
|
||||
Tuesdays, and least on Saturday.
|
||||
Tuesdays, and least on Saturday.
|
||||
|
||||
And note that mu:stats:per-weekdays takes an optional search expression
|
||||
argument, to limit the results to messages matching that, e.g., to only
|
||||
|
@ -151,18 +150,18 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
I learnt that during 3-4am I sent/receive only about a third of what I sent
|
||||
during 11-12pm.
|
||||
|
||||
** What about getting the top-10 people in the To:-field?
|
||||
** What about getting the top-10 people in the To:-field?
|
||||
|
||||
Easy.
|
||||
|
||||
,----
|
||||
| scheme@(guile-user)> (mu:stats:top-n-to)
|
||||
| $1 = ((("Abc" "myself@example.com") . 4465) (("Def" "somebodyelse@example.com") . 2114)
|
||||
| $1 = ((("Abc" "myself@example.com") . 4465) (("Def" "somebodyelse@example.com") . 2114)
|
||||
| (and so on)
|
||||
`----
|
||||
|
||||
I've changed the names a bit to protect the innocent, but what the function
|
||||
does is return a list of pairs of
|
||||
does is return a list of pairs of
|
||||
|
||||
(<name> <email>) . <frequency>
|
||||
|
||||
|
@ -173,7 +172,7 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
There are also the functions 'mu:stats:top-n-subject' and
|
||||
'mu:stats:top-n-from' which do the same, mutatis mutandis, and it's quite
|
||||
easy to add your own (see the mu-stats.scm for examples)
|
||||
|
||||
|
||||
** What about showing the results in a table?
|
||||
|
||||
Even easier. Try:
|
||||
|
@ -181,7 +180,7 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
,----
|
||||
| (mu:stats:table (mu:stats:top-n-to))
|
||||
`----
|
||||
|
||||
|
||||
or
|
||||
|
||||
,----
|
||||
|
@ -189,7 +188,7 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
`----
|
||||
|
||||
You can also export the table:
|
||||
|
||||
|
||||
,----
|
||||
| (mu:stats:export (mu:stats:per-weekday))
|
||||
`----
|
||||
|
@ -198,17 +197,9 @@ older versions will not support e.g. the 'mu-stats.scm' things
|
|||
in e.g. 'R' or 'gnuplot'.
|
||||
|
||||
|
||||
[1] http://www.gnu.org/s/guile/
|
||||
[1] http://www.gnu.org/s/guile/
|
||||
[2] http://en.wikipedia.org/wiki/Scheme_(programming_language)
|
||||
|
||||
# Local Variables:
|
||||
# mode: org; org-startup-folded: nil
|
||||
# End:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -57,10 +57,10 @@ muile_config_new (int *argcp, char ***argvp)
|
|||
|
||||
if (opts->msgpath)
|
||||
opts->msgpath = mu_util_dir_expand (opts->msgpath);
|
||||
|
||||
|
||||
g_option_context_free (octx);
|
||||
|
||||
return opts;
|
||||
return opts;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -74,7 +74,7 @@ muile_config_destroy (MuileConfig *conf)
|
|||
static void
|
||||
usage (void)
|
||||
{
|
||||
g_print ("usage: muile [--muhome=<dir>] [msgfile]\n");
|
||||
g_print ("usage: muile [--muhome <dir>] [--msg <msgfile>]\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,9 +84,9 @@ main (int argc, char *argv[])
|
|||
MuileConfig *opts;
|
||||
|
||||
g_type_init ();
|
||||
|
||||
#ifdef HAVE_PRE2_GUILE
|
||||
g_warning ("Note: muile will not function correctly unless you have a "
|
||||
|
||||
#ifdef HAVE_PRE2_GUILE
|
||||
g_warning ("Note: muile will not function properly unless you are using a"
|
||||
"UTF-8 locale.");
|
||||
#endif /* HAVE_PRE2_GUILE */
|
||||
|
||||
|
@ -95,7 +95,7 @@ main (int argc, char *argv[])
|
|||
usage ();
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (!mu_runtime_init (opts->muhome /* NULL is okay */,
|
||||
"muile")) {
|
||||
usage ();
|
||||
|
@ -103,23 +103,23 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
mu_guile_init (); /* initialize mu guile modules */
|
||||
|
||||
|
||||
if (opts->msgpath) {
|
||||
if (!(gboolean)scm_with_guile
|
||||
((MuGuileFunc*)&mu_guile_msg_load_current, opts->msgpath))
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
scm_shell (argc, argv);
|
||||
|
||||
mu_runtime_uninit ();
|
||||
muile_config_destroy (opts);
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
muile_config_destroy (opts);
|
||||
return 1;
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue