backtick rules + complex macros
Hi,
I searched the net, the list archive, RTFM, asked in IRC and even looked into
the source distribution but I didn't see a single point where the use (and
limits) of backticks are explained.
Did anybody knows a good reference? Mainly for use inside macros and hooks.
I think that the use as initialitation trick works fine and it's easy to
understand:
set sendmail=`~/sbin/whatever.sh`
but it becomes difficult when you try stuff like:
macro index X "<pipe-message>~/sbin/guess/path>/tmp/path\n<save-message>`cat
/tmp/path`\n"
(yes, I know it doesn't work)
Where can I use backticks?
It's there any patch to allow the use of backticks anywhere in a macro or hook?
When the backticks expand in runtime and when reading the config file?
Finally, after lot of trial and error, I get what I need but I think it's not
very elegant solution:
macro index ,r '<pipe-message>~/sbin/ask_category >
/tmp/out<enter><enter-command>source /tmp/out<enter><save-message><enter>'
Where ~/sbin/ask_category:
-----
#!/bin/sh
tmpf=`mktemp`
msgfile=/tmp/msg
log=/tmp/ifiletuning.log
cat > $msgfile
category=`grep X-Category /tmp/msg | cut -d" " -f2`
Xdialog --inputbox folder 11 44 2>$tmpf
read newcategory < $tmpf
ifile -d $category -i $newcategory $msgfile 1>&2
echo save-hook . ~/mail/$newcategory
-----
As you see I use a couple custom headers X-Folder and X-Category (wrote while
collecting the messages). I am trying to use these headers to reclassify wrong
classified messages (with ifile) from inside mutt with a single keystroke for
spam and with a few ones otherwise (it's necessary to enter the right category)
Now, in the mutt index view, when I see a wrong classified message I type Y,
enter a category name, classify as wanted, unclassify from the wrong folder and
finally save the message to the right mailbox
And it will be fantastic if I could write this like that:
macro index Y '<save-message>`~/sbin/guess_folder %?new category? %h:X-Folder`'
where %?label? ask me for a value and %h:hdr extract the hdr header value and
call the script with them as arguments :) instead of passing the full message,
saving it to disk and so on
well, I hope somebody write a patch for things like that
Sorry for the long and chaotic message...but after a couple hours fighting with
that problem I need to shout it out
thanks,
<w/>