azynheira / mu0

Automatically exported from code.google.com/p/mu0
0 stars 0 forks source link

Enter way to search tags in X-label field #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The X-label field can be convenient to add a tag to a specific. It would be 
nice to have an option to search this specific field.

Original issue reported on code.google.com by jostber....@gmail.com on 6 Jun 2011 at 6:15

GoogleCodeExporter commented 8 years ago
Hmmm, being able to search for a label in a field
  X-Label: foo, bar
is not too hard, but adding read-write support to them requires a bit of work 
to make sure user's mails are 100% save.

Still, adding it as a field in the mail (rather than in the database) makes 
sense, so the labels are still there when the mails are copied, or the database 
rebuilt.

Anyway, something for post-1.0 I think. Is there some standard for X-Label?

Original comment by digg...@gmail.com on 7 Jun 2011 at 7:48

GoogleCodeExporter commented 8 years ago
X-label is a kind of semi-standard label that was implemented in mutt years 
ago. This is a free note field that is very useful for tagging mails. Right now 
this is a read-only field in mutt. According to the mutt-dev list it seems like 
there will be included a new functionality for editing this label as well: 

http://does-not-exist.org/mail-archives/mutt-dev/msg15029.html

What would be nice if one in mu could search one or more terms in this field to 
have an extra way to filter mails. 

I use this editlabel script that I found on the web(the site where it was 
posted before seems to be unavailable at the moment, so I post it here):

#!/bin/bash
# $1 is the action (append, show, remove)
# $2 is the filename

# Configuration
LFILE="$HOME/.labels"

ACTION="$1"
FNAME="$2"
NFNAME="/tmp/editlabels-`basename "$2"`.$$"

function asklabel() {
    read -e -p "Insert label: " $1
    CVAL=${!1}
    while ( ! grep -q "^$CVAL$" "$LFILE" ) || ( [ "$CVAL" == "" ] ) ; do
        echo "Invalid label \"$CVAL\""
        read -e -p "Insert label: " $1
        CVAL=${!1}
    done
}

if [ "$ACTION" == "menu" ]; then
    function getact() {
        read -p "Append/Remove/Show/Clean/List: " ACT
        if [ "$ACT" == "a" ]; then
            ACTION=append
        elif [ "$ACT" == "r" ]; then
            ACTION=remove
        elif [ "$ACT" == "s" ]; then
            ACTION=show
        elif [ "$ACT" == "c" ]; then
            ACTION=clean
        elif [ "$ACT" == "l" ]; then
            ACTION=list
        else
            echo "Invalid action"
            getact
        fi
    }
    getact
fi

if [ "$ACTION" == "append" ]; then
    ACT=`formail -c -X X-Label < "$FNAME"`
    asklabel LNAME
    if [ "$ACT" == "" ]; then
        NEW="X-Label: $LNAME"
    else
        NEW="$ACT, $LNAME"
    fi

    formail -I "$NEW" < "$FNAME" > "$NFNAME"

elif [ "$ACTION" == "remove" ]; then
    ACT=`formail -c -X X-Label < "$FNAME"`
    asklabel LNAME
    NEW=`echo $ACT | sed "s/, $LNAME//g" | sed "s/$LNAME, //g" | sed "s/: $LNAME/:/g"`
    formail -I "$NEW" < "$FNAME" > "$NFNAME"

elif [ "$ACTION" == "show" ]; then
    formail -c -X "X-Label:" < "$FNAME"
    read -p "Press any key to continue"

elif [ "$ACTION" == "clean" ]; then
    formail -I "X-Label:" < "$FNAME" > "$NFNAME"

elif [ "$ACTION" == "list" ]; then
    echo "Available labels (from ~/.labels):"
    cat $LFILE
    read -p "Press any key to continue"
fi

# if we created a new file, step over the old one
if [ -f "$NFNAME" ]; then
    mv "$NFNAME" "$FNAME"
fi

Original comment by jostber....@gmail.com on 8 Jun 2011 at 7:17

GoogleCodeExporter commented 8 years ago
the git repository now has an initial implementation for this; you can search 
for tags found in the 'X-Label' field; in that field can be a comma-separated 
list of tags, which you can search with 'tag:'. ie., to get all messages tagged 
with fish and chips, you'd search:

   mu find tag:fish tag:chips

Original comment by digg...@gmail.com on 2 Jul 2011 at 8:38

GoogleCodeExporter commented 8 years ago
Available in 0.9.7-pre

Original comment by digg...@gmail.com on 31 Jul 2011 at 1:05