Re: use current folder name as argument to abitrary command
* Cameron Simpson <cs@xxxxxxxxxx> [2009-05-31 01:41 -0500]:
> On 30May2009 22:20, David J. Weller-Fahy
> <dave-lists-mutt-users@xxxxxxxxxxxxxxx> wrote:
> | #v+
> | folder-hook . 'push ":\\\`~/.mutt/listbox-to-email.pl\
> $my_folder\\\`<enter>"'
> | #v-
> |
> | I do not understand why the macro is required to force mutt to parse
> | that ""-quoted string, and now I'm wondering if there are any other
> | constructs which would allow the same level of parsing without defining
> | a macro... hrm. Methinks I need to read more of the source, manual, and
> | wiki to understand, but that may have to wait until I get more
> | round-tuits.
>
> There are no macros in that command line. Hmm, there are macros in
> mine; I guess removing them is what you're after.
Yep, I probably should have been clear: It struck me as a waste to
generate a macro just so the string can be interpreted as a mutt-level
""-string. I was just trying different things to remove the requirement
for a macro. It just occurred to me, though, that you might want the
macro so you can re-use the command later? Not sure, but either way I
figured it out.
> If you get your perl script to log command line arguments to a file,
> what does it show? Is it even run?
The Perl script didn't run, instead I would get the following.
#v+
`~/.mutt/listbox-to-email.pl: unknown command
#v-
I had also tried the following command:
#v+
folder-hook . 'push ":\`~/.mutt/listbox-to-email.pl\ $my_folder\`\\\<enter\\\>"'
#v-
Which resulted in the following being left on the mutt command line.
#v+
:`~/.mutt/listbox-to-email.pl =lists.mutt-users`\<enter\>
#v-
That should have given me the clue-bat you gave me below, as it
indicates the <enter> (had it worked) would have executed
`~/.mutt/listbox-to-email.pl =lists.mutt-users`, which is what I wanted
to happen. Ahhhh... hindsight. ;)
> What if you change:
> \\\`
> into plain
> \`
> at the start and end?
As you suggested, I changed the \\\` to \`, and voilà! It works without
the macro! I can only plead tired-eye-rushing syndrome, as that's the
only way I should have missed trying all the possibilities instead of
skipping the one that worked.
For the record the following folder-hooks work to execute a script and
pass the current folder name as the script's first command line
parameter.
#v+
folder-hook +lists* 'set my_oldrecord=$record; set record=^; set
my_folder=$record; set record=$my_oldrecord'
folder-hook . 'push ":\`~/.mutt/listbox-to-email.pl\ $my_folder\`\<enter\>"'
#v-
Also, I'll attach my little Perl script, as someone might find it handy.
> | That is odd, but workable.
>
> That does seem a little odd, since mutt's ok with blank lines in the
> muttrc.
Yep... another code-dive for another time. Good timing on the solution,
anyway, as my next semester starts tomorrow. ;)
--
dave [ please don't CC me ]