Re: use current folder name as argument to abitrary command
First, my goal is to change the from variable based on which mailing
list mailbox I'm in (my non-list email addresses don't change enough to
make this worthwhile for them). I was using a one-line patch to export
the mailbox name to the shell. With your solution that should no longer
be necessary, but I'm having trouble getting this to work. All my list
email addresses are based on the mailing list name so the actual
translation is easy. I'm almost there.
* Noah Sheppard <nhsheppard@xxxxxxxxxx> [2008-12-15 08:52 -0600]:
> I modified it slightly so that I get the current folder path in a
> variable on its own so I can be free to play with it further:
>
> folder-hook . "set my_oldrecord=\$record"
> folder-hook . "set record=^"
> folder-hook . "set my_curdir=\$record"
> folder-hook . "set record=\$my_oldrecord"
Once I had time, this was very helpful - thanks to both you and Kyle.
> The next step is to strip down that name so I have only the folder
> name, not the full path. The best way I can think to do this would be
> to pass the full path folder variable to a shell command which will
> strip that down, and return the folder name to another variable (or
> the same one, I don't care). I'm stuck at figuring out how to pass a
> mutt variable to a shell command.
I tried your way for a bit, but was unable to make it work - here's
where I'm at now.
#v+
folder-hook +lists.* "set my_oldrecord=\$record"
folder-hook +lists.* "set record=^"
folder-hook +lists.* "set my_curdir=\$record"
folder-hook +lists.* "set record=\$my_oldrecord"
folder-hook +lists* "set shell=\"~/.mutt/gen-set-from.pl \$my_curdir && sleep
0.5\""
folder-hook +lists* "push <shell-escape><enter>"
folder-hook +lists* "push <enter-command>source ~/.mutt/list-from<enter>"
#v-
Some explanation is in order. The gen-set-from.pl script takes the
current mailing list mailbox name (something similar to
"=lists.mutt-users") on the command-line, and writes the file list-from
containing the line "set from=dave-lists-mutt-users@xxxxxxxxxxxxxxx".
Right now everything works except from never gets set. I thought this
might be because of the timing (source happening before the link is
created), so I added a 0.5 second sleep after "list-from" generation.
Adding the sleep did not fix the problem from never gets set because the
source command runs before the shell finishes creating the link, but I'm
not sure.
At this point I've been staring at the problem for too long. Can anyone
suggest a fix for this?
Regards,
--
dave [ please don't CC me ]