* man/mhbuild.man: wrapped one appearance of "Content-Disposition"
[mmh] / docs / README-HOOKS
1 $Id$
2
3 Jon Steinhart's (jon@fourwinds.com) External Program Hooks
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 This blurb describes a changes to nmh that implement an interface
7 to external programs.  This interface is different than the limited
8 interface provided by things like the rmmproc context entry.
9
10
11 Why Did I Do This?
12 ~~~~~~~~~~~~~~~~~~
13
14 I'm working on a project (grokmail) that will get released via GPL sometime
15 soon.  This project keeps a database synchronized with the messages in the
16 mail system.  New functionality is built on top of this database.  This
17 functionality allows fast searching, and searching based on interest
18 criteria.  The latter can be used for spam filtering.
19
20 The changes to nmh allow external programs to be run whenever a message is
21 added to a folder, removed from a folder, or refiled.  The changes are
22 implemented in a general way so that it can be used for other purposes than
23 mine.
24
25 What Are The Changes?
26 ~~~~~~~~~~~~~~~~~~~~~
27
28 The changes add four new profile components:
29
30 add-hook:       This is the full pathname of a program that is invoked
31                 whenever a message is added to a folder.  The program
32                 is passed one argument which is the full pathname of the
33                 message file.  The program is executed after the message
34                 is written so that it can act upon that message.
35
36 del-hook:       This is the full pathname of a program that is invoked
37                 whenever a message is deleted from a folder.  The program
38                 is passed one argument which is the full pathname of the
39                 message file.  The program is executed before the message
40                 is written so that it can act upon that message.
41
42 ref-hook:       This is the full pathname of a program that is invoked
43                 whenever a message is refiled.  The program is passed two
44                 arguments:  the first is the full pathname of the original
45                 message file, the second is the full pathname of the final
46                 message file.  The program is executed after the message
47                 is written.
48         
49 msg-hook:       This is a text message that is output if the execution of
50                 one of the external hook programs fails.  There is a built-in
51                 default message if none is specified.
52
53 The definition of refiling is a bit tricky.  The refile hook is executed if a
54 message is moved from one place to another.  So, for example, the command
55
56         refile -link
57
58 causes the add hook to be executed, not the refile hook, because a new message
59 is created, the old one isn't moved.
60
61 These changes affect the following commands:
62
63 burst:          The add hook is executed for messages burst from a digest, and
64                 for the table of contents if -inplace is specified.  The delete
65                 hook is executed for the original message if -inplace is
66                 specified.  The refile hook is executed for messages that are
67                 moved.
68
69 folder:         The refile hook is executed for -pack.
70
71 inc:            The add hook is executed when messages are incorporated.
72
73 refile:         Either the add or refile hooks are executed.
74
75 rmf:            The delete hook is executed when messages are deleted.
76
77 rmm:            The delete hook is executed when messages are deleted.
78
79 sortm:          The refile hook is executed for each message moved.  Note that
80                 a magic temporary message number of 2147483647 is used to hold
81                 messages as they are being shuffled.
82
83
84
85 Did I Do This Correctly?
86 ~~~~~~~~~~~~~~~~~~~~~~~~
87
88 Well, sort of.  This all works, but I'm not really happy with it.  The issue
89 is that an examination of the nmh code shows that message handling is scattered
90 all over the place.  Although there are library routines such as folder_addmsg
91 and folder_delmsgs, they are not used consistently.  Long term, I think that it
92 would be better to make all message handling go through the same choke points.
93
94 Also, I added a function to run the external programs.  This sort of stuff is
95 also scattered around the nmh code, for example in the code to run the rmmproc.
96 Again, I'd like to make this more consistent in the long term.
97
98 What Files Did I Change?
99 ~~~~~~~~~~~~~~~~~~~~~~~~
100 uip/
101         burst.c
102         inc.c
103         refile.c
104         rmf.c
105         sortm.c
106
107 sbr/
108         folder_addmsg.c
109         folder_delmsgs.c
110         folder_pack.c
111         ext_hook.c      (new file)