Hi,
I'm trying to change $from and $sendmail when in the compose menu.

For this, in my muttrc I use:
> set from=foo sendmail=foo
> color status yellow blue
> macro compose "L" "<enter-command>source 
> ~/other-account<enter><edit-from><kill-line>$from<enter>"

Where ~/other-account contains
> set from=bar sendmail=bar
> color status red blue
> macro compose "L" "<enter-command>source 
> ~/muttrc<enter><edit-from><kill-line>$from<enter>"


The issue is the expansion of $from which happens during the evaluation of the
double-quoted string. This is too soon. It would have to be delayed to after 
`source`
has been evaluated so that $from takes the new and expected value.

- Single quote does not do the work. $from isn't expanded
- neither does escaping $variable with backslash (appear as-is)
- Using a plain `push` inside ~/other-account is possible, but it's not an 
option
  for muttrc which is evaluated in other contexte
- I don't split a chunk of muttrc' configuration inside yet another file
- I don't want to hardcode/duplicate $from value of the muttrc inside
  the macro written inside ~/other-account


I then hoped I could simulate a late expansion using something like:
> macro compose "L" '<enter-command>source 
> ~/muttrc<enter><edit-from><kill-line>push "$from";<enter>'
(notice the push + single quotes)

But I didn't understood how it could look like.
I tried various things starting with:
> macro compose "L" 'push s'
but this adds a magic "<enter>" command like if I had written "<enter>s".
Can't deal with this.


Thus:
- how could I delay variable expansion inside a macro?
- is the `push` within the `macro` a viable workaround?
- how would that look like?


Thank you!

Reply via email to