Before I get into inline response - this works for me: Thanks Cameron!

* Cameron Simpson <c...@zip.com.au> [2009-05-12 03:27 -0500]:
> On 04May2009 22:25, David J. Weller-Fahy 
> <dave-lists-mutt-us...@weller-fahy.com> wrote:
[ ... snip-o-lot throughout ... ]
> | So, really the only problem I need to solve to make everything work
> | without having to patch mutt is expanding a my_* variable (perhaps any
> | variable?) within backticks.
>
> I have finally found some more time to look at this, and spent a few
> hours this morning. You are going to love this charming incantation:
>
>   folder-hook . 'set my_oldrecord=$record; set record=^; set 
> my_folder=$record; set record=$my_oldrecord'
>   folder-hook . 'macro index Z :push\ \":\\\`cs-mutt-per-folder\ 
> $my_folder\\\`\\\<enter\\\>\"<enter>; push Z'

Wow.

> Simple and intuitive, eh? (There are just two folder-hook lines there,
> if your mailer folds the lines.)

Brought a tear to my eye!  I just spent ~30 minutes trying to trim away
the macro, but I have not been able to yet.  I'm sure my understanding
of mutt's quoting levels is insufficient as of yet.

[...]

> The method by which this was arrived at is as follows:
>   - we need $my_folder expanded in the command
>   - mutt vars are not expanded inside backticks (because that would
>     mangle shell variable use in the shell command)

Given.

>   - thus we need to construct the shell command a little like this:
>       \`cs-mutt-per-folder $my_folder\`
>     i.e. literal backticks, so we're not "inside backticks" when
>     $my_folder is encountered.

I didn't think of that, good idea!

>   - thus we need a string in our muttrc subject to this expansion,
>     and we need to get something to use it:
>       push ":\`cs-mutt-per-folder $my_folder\`<enter>"
>     You can see this should push the text:
>       :`cs-mutt-per-folder =me`
>     if I'm in the folder "=me".

Ok, that makes sense.

>   - for added fun of course, this has to happen inside the folder-hooks.
>     We can't just push stuff directly because we need to construct a
>     mutt-level ""-quoted string, and also it has to happen in the
>     folder hook because we don't have the folder name before then.

This part I am unclear on - rather, I am unclear on *why*, not
*whether*, it works that way.  Perhaps (certainly) I don't understand
mutt's quoting levels enough, and will have to dive through the wiki and
documentation again.

>   - So we define a macro and then push the macro keystroke.
>     That leads directly to the deeply nested quotes shown, which I
>     then spent a LONG time fiddling with until it actually worked:-(

Brilliant!  I used your solution in this mutt session, and the from has
been set properly for every mailbox thus far.

Thanks again, Cameron, and I'll mark this solved in the subject for
future searchers. ;)

Regards,
-- 
dave [ please don't CC me ]

Reply via email to