GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: Programs   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index

3.11 guimb — A Mailbox Scanning and Processing Language

Guimb is an experimental tool that iterates over messages in a mailbox (or several mailboxes), applying a Scheme function to each of them.

A user-defined scheme module that supplies the function to apply is specified using the --source or --file option. The module must define at least the following function:

User function: guimb-message msg

Processes message msg. This function can alter the message using Guile primitives supplied by mailutils.

The following function definitions are optional:

User function: guimb-getopt args

If defined, this function is called after guimb has finished processing the command line. args is a list of unconsumed command line arguments.

The function is intended to provide a way of configuring the module from the command line.

User function: guimb-end

If defined, this function is called after all mailboxes have been processed.

In the following example we define a module that prints information about each message is the input mailbox, in a way similar to frm utility:

(define-module (frm)
  :export (guimb-message))

(use-modules (mailutils mailutils))
             
(define (guimb-message msg)
  (display (mu-message-get-sender msg))
  (display " ")
  (display (mu-message-get-header msg "subject"))
  (newline))

The modules are looked up in directories listed in the global variable %load-path. New directories can be added to that variable on the fly using the -L (--load-path) option. For example, if the sample module above was saved in a file frm.scm somewhere in the load path, it can be applied to the current user inbox by running the following command:

guimb --file frm

GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: Programs   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index