From 59525212405fe4fc544e44af5ecf803ba0430921 Mon Sep 17 00:00:00 2001 From: mxmehl Date: Wed, 12 Jul 2017 15:30:01 +0200 Subject: [PATCH] fix some logic and regex bugs and add 'draft' to list of ignored tags --- astroid/scripts/move-tag.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/astroid/scripts/move-tag.sh b/astroid/scripts/move-tag.sh index dbf45f1..518acb6 100755 --- a/astroid/scripts/move-tag.sh +++ b/astroid/scripts/move-tag.sh @@ -18,7 +18,7 @@ USETAGS=".+" # List of tags which shall be moved THREADTAGS=".+" # List of tags for which single, but connected messages in INBOX shall be tagged BL_USETAGS="" -BL_THREADTAGS="$TRASHTAG|$SPAMTAG|$ARCHTAG" +BL_THREADTAGS="$TRASHTAG|$SPAMTAG|$ARCHTAG|draft" touch "$LOG" # Create logfile or update time stamp @@ -37,7 +37,7 @@ while read line; do TAG=$(echo $line | cut -d";" -f1) FOL=$(echo $line | cut -d";" -f2) - if ! $(echo $BL_USETAGS | grep -q "$TAG,") && $(echo $TAG | grep -qE "$USETAGS"); then + if ! $(echo $BL_USETAGS | grep -qE "${TAG}($|\|)") && $(echo $TAG | grep -qE "$USETAGS"); then BL_USETAGS="$TAG,$BL_USETAGS" # Add current tag to list of tags which do not have to be searched for another time # TRASH tag "del" @@ -58,7 +58,7 @@ while read line; do # DEFAULT else # For some tags, also tag its threads - if ! $(echo $BL_THREADTAGS | grep -q "$TAG,") && $(echo $TAG | grep -qE "$THREADTAGS"); then + if ! $(echo $BL_THREADTAGS | grep -qE "${TAG}($|\|)") && $(echo $TAG | grep -qE "$THREADTAGS"); then # If one file is tagged (except del, spam, archive), also tag the other mails of its thread respectively, IF they are located in INBOX [TODO: is this the best approach?]. Only then they can be moved by this script # 1. Get thread ids of all entries with the searched tag @@ -77,10 +77,11 @@ while read line; do logrun notmuch tag +"$TAG" -- "$m" fi done + + # Search for these lone messages in INBOX + HITFILES=$(notmuch search --output=files --exclude=false path:INBOX/** and tag:$TAG | grep "$MAILDIR/INBOX/") fi - # Search for these lone messages in INBOX - HITFILES=$(notmuch search --output=files --exclude=false path:INBOX/** and tag:$TAG | grep "$MAILDIR/INBOX/") fi # Move files to their destination folders