Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
make muttrc invoke script for changing my_hdr
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mike Hunter  
View profile  
 More options May 31 2007, 5:59 pm
Newsgroups: comp.mail.mutt
From: Mike Hunter <mhun...@lusArs.net>
Date: Thu, 31 May 2007 17:59:19 -0400
Local: Thurs, May 31 2007 5:59 pm
Subject: make muttrc invoke script for changing my_hdr
Hey everybody,

I'm playing with a custom my_hdr.  I had success doing

send-hook '(~t addre...@alice.com | ~t addre...@bob.com)' "my_hdr X-foo: <`/home/mhunter/bin/myfoo.pl`>"

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.)

Thanks!

Mike


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gary Johnson  
View profile  
 More options May 31 2007, 8:47 pm
Newsgroups: comp.mail.mutt
From: Gary Johnson <garyj...@spk.agilent.com>
Date: Fri, 1 Jun 2007 00:47:30 +0000 (UTC)
Local: Thurs, May 31 2007 8:47 pm
Subject: Re: make muttrc invoke script for changing my_hdr

Mike Hunter <mhun...@lusars.net> wrote:
> Hey everybody,

> I'm playing with a custom my_hdr.  I had success doing

> send-hook '(~t addre...@alice.com | ~t addre...@bob.com)' "my_hdr X-foo: <`/home/mhunter/bin/myfoo.pl`>"

> 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),

   send-hook '(~t addre...@alice.com | ~t addre...@bob.com)' 'source "/home/mhunter/bin/myfoo.pl|"'

where your myfoo.pl script would need to be modified to output the
entire

   my_hdr X-foo: <your_foo_string_here>

command.

HTH,
Gary


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rado S  
View profile  
 More options Jun 1 2007, 12:51 pm
Newsgroups: comp.mail.mutt
From: Rado S <rado-n...@spam-is.invalid>
Date: 1 Jun 2007 16:51:07 GMT
Local: Fri, Jun 1 2007 12:51 pm
Subject: Re: make muttrc invoke script for changing my_hdr

Mike Hunter <mhun...@lusars.net> wrote:
> I'm playing with a custom my_hdr.  I had success doing

> send-hook '(~t addre...@alice.com | ~t addre...@bob.com)' "my_hdr X-foo: <`/home/mhunter/bin/myfoo.pl`>"

> 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.

Quote the `` to make them count only when the hooks is executed, not
when it is defined (read, parsed).

--
© Rado S. -- You must provide YOUR effort for your goal!
EVERY effort counts: at least to show your attitude.
You're responsible for ALL you do: you get what you give.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Hunter  
View profile  
 More options Jun 1 2007, 3:51 pm
Newsgroups: comp.mail.mutt
From: Mike Hunter <mhun...@lusArs.net>
Date: Fri, 01 Jun 2007 15:51:02 -0400
Local: Fri, Jun 1 2007 3:51 pm
Subject: Re: make muttrc invoke script for changing my_hdr

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?

Thanks again,

Mike


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Hunter  
View profile  
 More options Jun 6 2007, 4:38 pm
Newsgroups: comp.mail.mutt
From: Mike Hunter <mhun...@lusArs.net>
Date: Wed, 06 Jun 2007 16:38:12 -0400
Local: Wed, Jun 6 2007 4:38 pm
Subject: Re: make muttrc invoke script for changing my_hdr

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gary Johnson  
View profile  
 More options Jun 6 2007, 9:43 pm
Newsgroups: comp.mail.mutt
From: Gary Johnson <garyj...@spk.agilent.com>
Date: Thu, 7 Jun 2007 01:43:51 +0000 (UTC)
Local: Wed, Jun 6 2007 9:43 pm
Subject: Re: make muttrc invoke script for changing my_hdr

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.

Regards,
Gary


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Hunter  
View profile  
 More options Jun 7 2007, 5:55 pm
Newsgroups: comp.mail.mutt
From: Mike Hunter <mhun...@lusArs.net>
Date: Thu, 07 Jun 2007 17:55:37 -0400
Local: Thurs, Jun 7 2007 5:55 pm
Subject: Re: make muttrc invoke script for changing my_hdr

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.

Mike


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Hunter  
View profile  
 More options Jun 13 2007, 9:34 pm
Newsgroups: comp.mail.mutt
From: Mike Hunter <mhun...@lusArs.net>
Date: Wed, 13 Jun 2007 21:34:49 -0400
Local: Wed, Jun 13 2007 9:34 pm
Subject: Re: make muttrc invoke script for changing my_hdr
[snip]

I posted this to the mutt developers mailing list, but I thought I'd
also post it here in case it makes some neurons fire somewhere :)

Mike

------------------ ------------------ ------------------ ------------------
Hey everybody,

I'm floundering a bit in an attempt to add some functionality to the
"source" command and I'm hoping somebody can lend me a hand.

My end-goal is to be able to add some custom header lines based on who
the mail is addressed to.  Unfortunately, this does NOT work:

send-hook '(~t al...@alice.com )' source "/Users/mhunter/bin/my_hdr-gen.pl %T |"

I get "source:  too many arguments"

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.

I've been chatting about this already on usenet:

http://groups.google.com/group/comp.mail.mutt/browse_thread/thread/a5...

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));

  while (MoreArgs(s))
  {
    if (mutt_extract_token (tmp, s, 0) != 0)
    {
      snprintf (err->data, err->dsize, _("source: error at %s"), s->dptr);
      return (-1);
    }
    if (tmp->data[0] == '%')
    {
      mutt_FormatString(formatbuf, sizeof(formatbuf), tmp->data, hdr_format_str, data, 0);
      safe_strncat(path, sizeof(path), " ", 1);
      safe_strncat(path, sizeof(path), formatbuff, sizeof(formatbuf));
    }
    else
    {
      safe_strncat(path, sizeof(path), " ", 1);
      safe_strncat(path, sizeof(path), tmp->data, tmp->dsize);
    }
  }

  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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »