<<< Date Index >>>     <<< Thread Index >>>

Re: use current folder name as argument to abitrary command



On 25May2009 22:30, David J. Weller-Fahy 
<dave-lists-mutt-users@xxxxxxxxxxxxxxx> wrote:
| Before I get into inline response - this works for me: Thanks Cameron!

Glad to hear it.

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

You probably can't reduce it, given the order in which things need to
happen.

[...snip...]
| >   - 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.

It has to happen inside the folder-hooks because it needs to be re-applied
if you switch folders. Also, (if you didn't want to update on a folder
change) I think I established by experiment that the main muttrc is
sourced before opening your first folder, so you can't ask for the folder
name then.

BTW, something I may raise in another thread: the output of
cs-mutt-per-folder (or whatever command you put in backticks there)
_must_ be a single line of text. Mutt reads just the first line and
closes the pipe, producing a Broken Pipe signal in the script and
discarding following lines. So the script should produce:

  mutt-cmd; mutt-cmd; ...

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

These aren't the droids you're looking for.