]> the.earth.li Git - htag.git/blob - docs/README.Multiple_Configs
c8903a7f531c0159c874ce1bd461605c6fbe2d8e
[htag.git] / docs / README.Multiple_Configs
1 Multiple Config Support
2 =======================
3
4 Please read the README/INSTALL before reading this document.
5
6 In 0.0.18 this changed to eval your per header configs *after* the main
7 config file as opposed to only evaluating one config file making it easier
8 to see what is different about a particular config but breaking backward
9 compatibility for those that used Multiple Config File support.  Sorry.
10 Complain at me.
11
12 Multiple Config Support allows that you can reply to different people or
13 different newsgroups with different plugins.
14
15 This is what htag.pl does when it starts up wrt configfiles:
16         - checks to see if one is specified on the commandline
17         - if not defaults the basecfgfile to ~/.htrc
18         - evaluates the basecfgfile
19         - checks to see if $cfg{'changeheaders'} is defined and if so checks
20           whether those patterns match the headers it has for the message.
21           If they match it runs this extra config file.
22
23 So to get this working you just need to create one config file with your
24 defaults and your changeheaders patterns and extra config file names.  Then
25 create the extra config files you've mentioned in changeheaders.
26
27 changeheaders syntax is something like:
28 $cfg{'changeheaders'} = [
29         [ 'pattern_to_match', 'more optional patterns', 'config filename' ],
30         one or more lines like above
31         ];
32
33 The patterns are ANDed together.  If you want OR just create multiple lines.
34
35 $cfg{'changeheaders'} = [
36         [ '^From:.*support\@blackcatnetworks.co.uk', '~/.htagrc/support' ], 
37         [ '^Newsgroups:.* fr\.', 'From:.*huggie\@foo.com',
38           '~/.htagrc/fr-foo.com' ]
39         ];
40
41 The first example matches all messages which I send out with a From: line of
42 support@blackcatnetworks.co.uk so that I can append reassuring signatures to
43 our customers - I don't actually do this ... yet :)
44 The second is a contrived example which matches a Newsgroup line which has
45 somewhere a group that starts with "fr." and where the From: line contains
46 huggie@foo.com
47
48 There is a way of having a config per address but still only having one
49 rule.  Put a rule which has an empty config file and at least one rule which
50 should (if it matches) produce the config file name in $1 (the first
51 parenthesized match).
52 e.g.
53         [ '^From:.*?(\w+)@earth.li','~/.htagrc/earth-li-$1' ],
54
55 Then for every mail sent from something@earth.li it will use the config
56 "~/.htagrc/earth-li-something".
57
58 This could be used for instance to have a different config per From: address
59 (i.e. when you send from company From: addresses, and from personal From:
60 addresses and want to have different configs per address).
61
62 This documentation was written when I hadn't had enough sleep.  Sorry.
63 Corrections/clarifications/rewrites/chocolate welcomed.
64
65 Simon Huggins <huggie@earth.li>