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

Re: use current folder name as argument to abitrary command



On 31May2009 21:29, David J. Weller-Fahy 
<dave-lists-mutt-users@xxxxxxxxxxxxxxx> wrote:
| * Cameron Simpson <cs@xxxxxxxxxx> [2009-05-31 01:41 -0500]:
[...big snip...]
| > 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.

I suggested it deductively, but had the advantage of starting my debug
from your example.

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

Thank you, I've adopted exactly this incantation in my own muttrc:

  folder-hook . "macro index '\$' \"<change-folder>\$my_folder<enter>\""
  folder-hook . 'push ":\`cs-mutt-per-folder\ $my_folder\`\<enter\>"'

| Also, I'll attach my little Perl script, as someone might find it handy.

Wouldn't it be better to set from= always, and merely omit the subscribe
command for non-lists? That way, if you switch _from_ a lists.* folder
into a non-lists folder your from= will be repaired for non-list use.
i.e. replace "set wait_key" with "set from=your-core-address".

I think that I rely on the "alternates" setting to control my fromness.
(Except that I see there's a "set from=" in my config too. I shall have
to check which one wins.)

my own folder config script is here:
  http://www.cskk.ezoshosting.com/cs/css/bin/cs-mutt-per-folder

It produces (pre the newline->semicolon conversion) output like this:
  set my_folder_delete='/home/cameron/mail/O/mutt'
  unhook save-hook; save-hook . "$my_folder_delete"

This is because I map 'd' to:
  <copy-message>+ham<enter><save-message><enter>
Copy message to +ham, which is processed regularly to update bogofilter
stats, then save-message into the folder's archive folder. "O" is a
symlink to "OLD/YYYY" where YYYY is this year.

Anyway, many thanks for the code simplification!

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

Insisting on perfect safety is for people who don't have the balls to live
in the real world.      - Mary Shafer, NASA Ames Dryden