And X-foo: <...> shows up with the correct results. But I realized that it's only being run once per execution of mutt, which I need mutt to invoke myfoo.pl every time it does the send-hook. Is that doable? It must be but I can't figure it out off the top of my head. (The results of myfoo.pl depend on the system time, etc.)
> And X-foo: <...> shows up with the correct results. But I realized that > it's only being run once per execution of mutt, which I need mutt to > invoke myfoo.pl every time it does the send-hook. Is that doable? It > must be but I can't figure it out off the top of my head. (The results > of myfoo.pl depend on the system time, etc.)
All I can think of is something like this (untested),
> > And X-foo: <...> shows up with the correct results. But I realized that > > it's only being run once per execution of mutt, which I need mutt to > > invoke myfoo.pl every time it does the send-hook. Is that doable? It > > must be but I can't figure it out off the top of my head. (The results > > of myfoo.pl depend on the system time, etc.)
> All I can think of is something like this (untested),
> where your myfoo.pl script would need to be modified to output the > entire
> my_hdr X-foo: <your_foo_string_here>
> command.
Thanks to both you and Rado for the great suggestions, it's now working!
I've gotten a bit more ambitious and now I'd like to have myfoo.pl take %T as an argument, but I'm running into trouble passing it to the script. `` ends up with no such file or directory, and source ... doesn't like what it sees as multiple arguments...any suggestions?
On Fri, 01 Jun 2007 15:51:02 -0400, Mike Hunter wrote: > On Fri, 1 Jun 2007 00:47:30 +0000 (UTC), Gary Johnson wrote: > > All I can think of is something like this (untested),
> > where your myfoo.pl script would need to be modified to output the > > entire
> > my_hdr X-foo: <your_foo_string_here>
> > command.
> Thanks to both you and Rado for the great suggestions, it's now working!
> I've gotten a bit more ambitious and now I'd like to have myfoo.pl take > %T as an argument, but I'm running into trouble passing it to the > script. `` ends up with no such file or directory, and source ... > doesn't like what it sees as multiple arguments...any suggestions?
The only thing I've been able to think of is to call scripts with a suffix, like ~/my-foo.%T.pl and have a separate script for each %T, but I really don't want to have to maintain all that...if anybody has any suggestions I'd greatly appreciate it :)
Mike Hunter <mhun...@lusars.net> wrote: > On Fri, 01 Jun 2007 15:51:02 -0400, Mike Hunter wrote: >> On Fri, 1 Jun 2007 00:47:30 +0000 (UTC), Gary Johnson wrote:
>> > All I can think of is something like this (untested),
>> > where your myfoo.pl script would need to be modified to output the >> > entire
>> > my_hdr X-foo: <your_foo_string_here>
>> > command.
>> Thanks to both you and Rado for the great suggestions, it's now working!
>> I've gotten a bit more ambitious and now I'd like to have myfoo.pl take >> %T as an argument, but I'm running into trouble passing it to the >> script. `` ends up with no such file or directory, and source ... >> doesn't like what it sees as multiple arguments...any suggestions?
> The only thing I've been able to think of is to call scripts with a > suffix, like ~/my-foo.%T.pl and have a separate script for each %T, but > I really don't want to have to maintain all that...if anybody has any > suggestions I'd greatly appreciate it :)
I don't know how or when %T is expanded, so I haven't tested this with %T, but 'source' should handle a command with arguments if you surround the entire argument to 'source' with quotes, e.g.,
source "command arg |"
If any of the quoting prevents %T from being expanded, you might try putting %T outside the quotes like this,
send-hook ... 'source "myfoo.pl "'%T'" |"'
or maybe this,
send-hook ... 'source "myfoo.pl "%T" |"'
or this,
send-hook ... 'source "myfoo.pl '%T' |"'
Which of those, if any, works will depend on when and how %T is expanded, and as I said, I haven't played with that myself. I hope that gives you some ideas, anyway.
On Thu, 7 Jun 2007 01:43:51 +0000 (UTC), Gary Johnson wrote: > Mike Hunter <mhun...@lusars.net> wrote: > > On Fri, 01 Jun 2007 15:51:02 -0400, Mike Hunter wrote:
> >> I've gotten a bit more ambitious and now I'd like to have myfoo.pl take > >> %T as an argument, but I'm running into trouble passing it to the > >> script. `` ends up with no such file or directory, and source ... > >> doesn't like what it sees as multiple arguments...any suggestions?
> > The only thing I've been able to think of is to call scripts with a > > suffix, like ~/my-foo.%T.pl and have a separate script for each %T, but > > I really don't want to have to maintain all that...if anybody has any > > suggestions I'd greatly appreciate it :)
> I don't know how or when %T is expanded, so I haven't tested this > with %T, but 'source' should handle a command with arguments if you > surround the entire argument to 'source' with quotes, e.g.,
> source "command arg |"
> If any of the quoting prevents %T from being expanded, you might try > putting %T outside the quotes like this,
> send-hook ... 'source "myfoo.pl "'%T'" |"'
> or maybe this,
> send-hook ... 'source "myfoo.pl "%T" |"'
> or this,
> send-hook ... 'source "myfoo.pl '%T' |"'
> Which of those, if any, works will depend on when and how %T is > expanded, and as I said, I haven't played with that myself. I hope > that gives you some ideas, anyway.
Thanks very much for the suggestions. Unfortunately I tried them and all the variations I could think of but nothing worked. I can either get to "no such file or directory" or I can get to my script being called with a literal "%T". I'm poking around the source code but it's slow going so far.
Clever quoting can get one a bit farther, but you end up with the literal "%T" being passed to the script instead of the expanded value.
I've been trying to come up with a patch to enable this functionality, but so far I'm not having success: In init.c, I tried allowing more tokens in the case of "paths" ending with '|', but when thought I'd get it to work, I discovered that the function that handles expanding %T (FWICT) is a static function inside hdrline.c.
I must be going about this wrong, because obviously people use format strings with "set", but I can't quite follow parse_set to see how it's doing it.
And, for your ridicule, here's my non-working parse_source function that I'm working on. It's trying to expand out the string and pass it along to source_rc (which seems well-prepared to deal with it via eventually fork/exec'ing).
Any help would be greatly appreciated!
Mike
static int parse_source (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) { char path[_POSIX_PATH_MAX]; char formatbuf[SHORT_STRING];
/*we do a first pass with with path expansion for the root */ if (mutt_extract_token (tmp, s, 0) != 0) { snprintf (err->data, err->dsize, _("source: error at %s"), s->dptr); return (-1); } strfcpy (path, tmp->data, sizeof (path)); mutt_expand_path (path, sizeof (path));
if (path[mutt_strnlen(path, sizeof(path))-2] != '|') { snprintf (err->data, err->dsize, _("source: multiple arguments not ending in '|'"), s->dptr); return (-1); }
return (source_rc (path, err));
}
-- "As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought....I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs." --Maurice Wilkes, 1949