* guile: some more improvements
This commit is contained in:
@ -204,23 +204,14 @@ Enter `,help' for help.
|
||||
scheme@(guile-user)>
|
||||
@end verbatim
|
||||
|
||||
Now, the first thing we need to do is load the @t{mu-guile} modules;
|
||||
currently, there are six available:
|
||||
|
||||
@itemize
|
||||
@item @code{mu} - initialization, functions to get messages, contacts
|
||||
@item @code{mu message} - functions to deal with messages
|
||||
@item @code{mu contact} - functions to deal with contacts
|
||||
@item @code{mu part} - functions to deal with message-parts / attachments
|
||||
@item @code{mu stats} - some functions for doing statistics on your messages
|
||||
@item @code{mu plot} - functions to draw graphs from the statistics (requires @t{gnuplot}
|
||||
@end itemize
|
||||
The first thing we need to do is loading the modules. All the basics are in
|
||||
the @t{(mu)} module, with some statistical extras in @t{(mu stats)}, and some
|
||||
graph plotting functionality in @t{(mu plot)}.
|
||||
|
||||
Let's simply load all of them:
|
||||
|
||||
@verbatim
|
||||
scheme@(guile-user)> (use-modules (mu) (mu message) (mu contact) (mu part)
|
||||
(mu stats) (mu plot))
|
||||
scheme@(guile-user)> (use-modules (mu) (mu stats) (mu plot))
|
||||
@end verbatim
|
||||
|
||||
Assuming you have installed everything correctly, the first time you do this,
|
||||
@ -383,12 +374,12 @@ subject} of any e-mail messages we received in the year 2011. You can try
|
||||
this if you put the following in a separate file, make it executable, and run
|
||||
it like any program.
|
||||
|
||||
@verbatim
|
||||
@lisp
|
||||
#!/bin/sh
|
||||
exec guile -s $0 $@
|
||||
!#
|
||||
|
||||
(use-modules (mu) (mu message))
|
||||
(use-modules (mu))
|
||||
(use-modules (srfi srfi-1))
|
||||
|
||||
(mu:initialize)
|
||||
@ -405,14 +396,13 @@ exec guile -s $0 $@
|
||||
subj1 subj2))
|
||||
"" list-of-subjects))
|
||||
|
||||
(format #t "Longest subject: ~s" longest-subject)
|
||||
(newline)
|
||||
@end verbatim
|
||||
(format #t "Longest subject: ~s\n" longest-subject)
|
||||
@end lisp
|
||||
|
||||
There are many other ways to solve the same problem, for example by using an
|
||||
iterative approach with @code{mu:for-each-message}, but it should show how one
|
||||
can easily write little programs to answer specific questions about an e-mail
|
||||
corpus.
|
||||
can easily write little programs to answer specific questions about your
|
||||
e-mail corpus.
|
||||
|
||||
@node Contacts
|
||||
@chapter Contacts
|
||||
@ -422,10 +412,6 @@ like @code{mu:from}, @code{mu:to} etc.; @xref{Message methods}. These
|
||||
functions return the list of recipients as a single string; however, often it
|
||||
is more useful to deal with recipients as separate objects.
|
||||
|
||||
@t{mu-guile} offers some functionality for this in the @code{(mu contact)}
|
||||
module. Also, it adds some contact-related methods for @code{<mu:message>}
|
||||
objects.
|
||||
|
||||
@menu
|
||||
* Contact functions and objects::
|
||||
* All contacts::
|
||||
@ -437,17 +423,12 @@ objects.
|
||||
@node Contact functions and objects
|
||||
@section Contact functions and objects
|
||||
|
||||
@verbatim
|
||||
(use-modules (mu contact))
|
||||
@end verbatim
|
||||
|
||||
After loading the @code{(mu contact)}, message objects (@pxref{Messages}) gain
|
||||
the the @t{contacts}-methods:
|
||||
Message objects (@pxref{Messages}) have a method @t{mu:contacts}:
|
||||
|
||||
@code{(mu:contacts <message-object> [<contact-type>])}
|
||||
|
||||
The @t{<contact-type>} is a symbol, one of @code{mu:to}, @code{mu:from},
|
||||
@code{mu:cc} or @code{mu:bcc}; this will then get the contact objects for the
|
||||
@code{mu:cc} or @code{mu:bcc}. This will then get the contact objects for the
|
||||
contacts of the corresponding type. If you leave out the contact-type (or
|
||||
specify @t{#t} for it, you will get a list of @emph{all} contact objects for
|
||||
the message.
|
||||
@ -462,7 +443,7 @@ Let's get a list of all names and e-mail addresses in the 'To:' field, of
|
||||
messages matching 'book':
|
||||
|
||||
@lisp
|
||||
(use-modules (mu) (mu message) (mu contact))
|
||||
(use-modules (mu))
|
||||
(mu:initialize)
|
||||
(mu:for-each-message
|
||||
(lambda (msg)
|
||||
@ -481,10 +462,9 @@ have each of the contacts only show up @emph{once} - for that, please refer to
|
||||
@node All contacts
|
||||
@section All contacts
|
||||
|
||||
Sometimes it may also be useful to look at @emph{all} the different contacts
|
||||
in the @t{mu} database -- that is, all the different contacts. This is useful,
|
||||
for example, when exporting contacts to some external format that can then be
|
||||
important in an e-mail program.
|
||||
Sometimes you may want to inspect @emph{all} the different contacts in the
|
||||
@t{mu} database. This is useful, for instance, when exporting contacts to some
|
||||
external format that can then be important in an e-mail program.
|
||||
|
||||
To enable this, there is the function @code{mu:for-each-contact}, defined as
|
||||
|
||||
@ -492,7 +472,7 @@ To enable this, there is the function @code{mu:for-each-contact}, defined as
|
||||
|
||||
This will aggregate the unique contacts from @emph{all} messages matching
|
||||
@t{<search-expression>} (when it is left empty, it will match all messages in
|
||||
the database), and execute @t{function} for each of these contacts.
|
||||
the database), and execute @t{function} for each of them.
|
||||
|
||||
The @t{function} receives an object of the type @t{<mu:contact-with-stats>},
|
||||
which is a @emph{subclass} of the @t{<mu:contact>} class discussed in
|
||||
@ -551,7 +531,7 @@ adjust them later by hand, obviously.
|
||||
exec guile -s $0 $@
|
||||
!#
|
||||
|
||||
(use-modules (mu) (mu message) (mu contact))
|
||||
(use-modules (mu))
|
||||
(mu:initialize)
|
||||
|
||||
;; Get a list of contacts that were seen at least 20 times since 2010
|
||||
@ -627,7 +607,7 @@ in messages about Luxemburg:
|
||||
exec guile -s $0 $@
|
||||
!#
|
||||
|
||||
(use-modules (mu) (mu message) (mu part))
|
||||
(use-modules (mu))
|
||||
(mu:initialize)
|
||||
|
||||
(define (all-attachments expr)
|
||||
@ -676,7 +656,7 @@ how many messages we receive per weekday:
|
||||
exec guile -s $0 $@
|
||||
!#
|
||||
|
||||
(use-modules (mu) (mu message) (mu stats) (mu plot))
|
||||
(use-modules (mu) (mu stats) (mu plot))
|
||||
(mu:initialize)
|
||||
|
||||
;; create a list like (("Sun" . 13) ("Mon" . 23) ...)
|
||||
@ -746,7 +726,7 @@ message per hour:
|
||||
exec guile -s $0 $@
|
||||
!#
|
||||
|
||||
(use-modules (mu) (mu message) (mu contact) (mu stats) (mu plot))
|
||||
(use-modules (mu) (mu stats) (mu plot))
|
||||
(mu:initialize)
|
||||
|
||||
(define (mail-per-hour-table)
|
||||
@ -784,8 +764,6 @@ exec guile -s $0 $@
|
||||
Hour
|
||||
@end verbatim
|
||||
|
||||
|
||||
|
||||
@node GNU Free Documentation License
|
||||
@appendix GNU Free Documentation License
|
||||
|
||||
|
||||
Reference in New Issue
Block a user