Re: how about the notion of filters for replying, etc.
On Thursday, 28 December 2006 at 17:35:26 EST,
Kyle Wheeler (<kyle-mutt@xxxxxxxxxxxxxx>) wrote:
> ...? You mean like this:
>
> set editor="myfilter.pl | $EDITOR"
Nope. What's passed to $editor is the message that you are composing.
What the hypothetical $reply_filter would be passed would be the message
to which you are responding. That way, you can access and act on info
in the headers of the message being replied to that would otherwise
never even make it into the temp file passed to $editor. (Examples
below.)
The trick is then deciding how $reply_filter passes info on to $editor.
There are two ways that I can see of doing it:
1) Give $reply_filter two arguments, corresponding to temp files for
the replied-to message and the being-composed message, and have it
return the text of a new being-composed message that is passed to
$editor (or maybe the filename of a message to be passed to $editor):
#!/bin/perl
# example $reply_filter version 1: set the High Importance flag for
# replies to messages to Bob sent from people using Outlook
($message_to_me, $my_reply) = @ARGV;
open (MESSAGE_TO_ME, $message_to_me) or die;
LINE: while (<>) {
if (1../^$/) {
if (/^To: bob@foo\.com/) {
$sent_to_bob = 1; next LINE;
};
if (/^User-Agent: .*Outlook/i) {
$sender_using_outlook = 1; next LINE;
};
};
};
close (MESSAGE_TO_ME);
open (MY_REPLY, $my_reply) or die;
if ($sender_using_outlook && $sent_to_bob) {
while (<>) {
if (1../^$/ and /^$/) {
print "Importance: High\n";
};
print;
};
} else {
print (<>);
};
__END__
I'm not aware of any way in mutt right now to automate things like this.
2) Pass $reply_filter the message being replied to, and have it return
mutt commands that are invoked as if they were in a reply_hook, and then
create the new message and pass it to $editor as normal
#!/bin/perl
# example $reply_filter version 2: Select a profile based on the
# the sender address IFF a corresponding pre-defined profile exists.
$profile_dir = $ENV{'HOME'} . '/.mutt/profiles/';
while (<>) {
print "source $profile_dir/$1\n"
if 1../^$/ and /^From: .*(\S+)@/ and -f "$profile_dir/$1" and -r _;
};
__END__
Again, even reply_hook in the dev versions doesn't let you dynamically
do things like that, I don't believe. (You COULD get a similar effect by
dynamically generating a bunch of reply_hooks every time mutt started up
based on the contents of that mutt profiles dir, but that's just an
example.) (Also, please don't comment on the quality of the above code;
it's very non-production quality, with thousands of edge-cases that would
break it, because I didn't want to clutter the examples up.)
-- Sweth.
--
Sweth Chandramouli
sweth@xxxxxxxxxxxxxxxx - http://EthicalHomes.com/
Real Estate Brokerage through Keller Williams Realty, Vienna, VA
Mortgage Brokerage through HomeFirst Mortgage, Alexandria, VA
Solutions for buyers, sellers, and homeowners in DC, VA, and MD
Referrals to first-rate Realtors and Mortgage Brokers nationwide