Re: [Mutt] Re: Editing headers of saved messages
On Fri, Jun 25, 2004 at 01:21:07PM -0700, Gary Johnson wrote:
> On 2004-06-25, "James P. Howard, II" <howardjp@xxxxxxxxxx> wrote:
> > Having recently played with Gmail, I have decided that the ability
> > to apply multiple labels to a message is superior to maintaining
> > hierarchical collection of folders where each message belongs to
> > only one label.
> >
> > With that in mind, a few days ago I started playing with Mutt and
> > have customized it and rather like it. Now, I'd like to have the
> > ability to add one or more labels to messages. It occurs to me the
> > best way to do this is to add a custom header to messages that
> > stores a list of labels separated by commas for instance,
> > "X-Local-Labels: work, school, friends").
> >
> > Is it possible to write a collection of macros, perhaps combined
> > with formail or other Unix tools, that can add and remove labels? I
> > have gone over the HTML manual on www.mutt.org, and am not seeing an
> > obvious way to do this.
>
> I've done this for the "Expires:" header. I think you could adapt
> those macros and scripts for this task. Take a look at
>
> http://www.spocom.com/users/gjohnson/mutt/#expires
I first built this out and now how message expirations. I then
modied the expires script into mutt_add_label:
file=$1
echo -n "Add label: "
read label
if [ "$label" != "" ]
then
oldlabels=`formail -X 'Labels:' < $file | sed 's/Labels: //'`
formail -i "Labels: $label $oldlabels" < $file > $file.$$
mv $file.$$ $file
fi
And this is mutt_del_label:
file=$1
echo -n "Remove label: "
read label
if [ "$label" != "" ]
then
oldlabels=`formail -X 'Labels:' < $file | sed "s/ $label//"`
formail -i "$oldlabels" < $file > $file.$$
mv $file.$$ $file
fi
Simple and easy. I realize I am not using X-Label:, but that
doesn't worry me too much. Add is bound to y and del to Y. Totally
neat. I just need to write some custom searching and all will be
done.
Thank you for your help,
James