Ricardo SIGNES wrote:
> I know this has been brought up before, but I just thought I'd voice my deep
> desire: mutt should be able to have backrefs to its regexen. If I get a
> 'vote' in future development, this is how I would cast it. My C is crappy, or
> I'd shut up and code it.
>
> Imagine the power available in something as simple as:
>
>
> folder-hook =friends\.([a-z]+) my_hdr From: <jsmith-\[EMAIL PROTECTED]>
While this might look simple, it's more difficult to implement than you
might think. Why? Becuse the regexp here is not just one regular
expression. The =friends\.([a-z]+) is actually expanded with the
$default_hook variable, which by default is "~f %s !~P | ~P ~C %s", thus
translating your example above into
~f "=friends\.([a-z]+)" !~P | ~P ~C "=friends\.([a-z]+)"
So now what does \1 really refer to? It gets even worse when you have
multiple *different* regular expressions in complex patterns.
It's not that the Mutt developers don't think would be useful to do, its
just a bear of a problem to tackle.
At any rate, your example above can be solved as follows:
1) create a script which generats folder-hook commands for all
of your `friend' mailboxes:
#!/bin/sh
for i in ~/Mail/friends.*; do
echo "folder-hook $i my_hdr From: <jsmith-`echo $i|sed
's;^.*\.;;'`@friends.domain.org>";
done
2) source this script from your ~/.muttrc
source ~/bin/hookgen.sh|