* On 2006.05.03, in <20060503153619.GE22406@xxxxxxxxxxxx>, * "Eric Smith" <es@xxxxxxxxxxxx> wrote: > Is it possible to read all the email addresses I want to hook > from a file or list rather than this awkard and difficult to > maintain notation: > > send-hook "~C (dsdf@xxxxxxxxxx\\|another@xxxxxxxxx\\|...) set whatever In general, you can do this with a script that generates the muttrc commands: source "the_script |" I have such a script that I used for generating tag patterns for junk mail. I call it "killfile.pl" because it essentially generates (live, from an on-disk source list) a set of patterns that I want to kill. But you can use it for your purpose, too. Here's a killfile.pl input file: [send-hook "%p" set whatever] ~C dsdf@xxxxxxxxxx ~C another@xxxxxxxxx ~C more@xxxxxxxxxxx I name that "~/.mutt/killfile.test", and then put this in my .muttrc: source "killfile.pl test |" Killfile.pl munges the killfile.test file into: send-hook "(~C dsdf@xxxxxxxxxx) | (~C another@xxxxxxxxx) | (~C more@xxxxxxxxxxx)" set whatever ... which is functionally equivalent to what you asked about above. Details: Lines in a killfile.foo file that are [enclosed in square brackets] indicate a template for upcoming lines. Other lines are valid and complete mutt patterns, like "~C dsdf@xxxxxxxxxx" or "~y logs ~s cron". Killfile.pl's role is to combine as many of these patterns as possible into a single instance of the "template" line, where the pattern represented by %p is a compound OR expression that includes all the patterns. If you have a lot of patterns, killfile.pl might generate multiple lines of the template, because muttrc lines can only be 1024 characters long. For a set of send-hooks, you probably want to put source "killfile.pl hooks |" in your .muttrc directly. But for other purposes, it might be more useful to bind that to a macro. For example, my killfile pattern file looks like this: [push "<tag-pattern>%p<enter>"] ~t MAILER-DAEMON@ ~f krypton ~s 'Output from .cron. command' ~f mailman-owner ~s '^(Illegal|Listhost)' ~f news ~s '^okaybye|^control.pl' ~f root ~s '^Accounting' ... And I have the source command in a macro: macro index \;j "<enter-command>source '$HOME/.mutt/killfile.pl junk |'<enter>" "Delete junk mail." -- -D. dgc@xxxxxxxxxxxx NSIT University of Chicago
Attachment:
killfile.pl
Description: Perl program