Removed Extended Regexes from Hiding Code

.
Dave Hein noticed the extended regular expressions (regex) in the
original patch don't work by default on Mac OS X (FreeBSD sed).  Now
using his suggested regex format: [[:space:]]@[^[:space:]]\{1,\}
.
Also changed: I misapplied part of the patch originally.  That's now
fixed.  I expanded part of the regular expression in the list
sub-expression so that I could change part of the coloring code.
This commit is contained in:
David A. Harding
2009-03-08 11:25:12 -04:00
parent 20e6892775
commit e6649e6293

47
todo.sh
View File

@@ -220,12 +220,7 @@ do
unset HIDE_CONTEXTS_SUBSTITUTION unset HIDE_CONTEXTS_SUBSTITUTION
else else
## One or odd value -- hide context names ## One or odd value -- hide context names
# HIDE_CONTEXTS_SUBSTITUTION='[[:space:]]@[^[:space:]]\{1,\}'
## Match: \(^\|[[:space:]] beginning of line or a space
## @ literal context label
## [^[:space:]]\+ Anything besides whitespace one
## or more times
HIDE_CONTEXTS_SUBSTITUTION="\(^\|[[:space:]]\)@[^[:space:]]\+"
fi fi
;; ;;
'+' ) '+' )
@@ -241,11 +236,7 @@ do
unset HIDE_PROJECTS_SUBSTITUTION unset HIDE_PROJECTS_SUBSTITUTION
else else
## One or odd value -- hide project names ## One or odd value -- hide project names
## Match: \(^\|[[:space:]] beginning of line or a space HIDE_PROJECTS_SUBSTITUTION='[[:space:]][+][^[:space:]]\{1,\}'
## @ literal context label
## [^[:space:]]\+ Anything besides whitespace one
## or more times
HIDE_PROJECTS_SUBSTITUTION="\(^\|[[:space:]]\)+[^[:space:]]\+"
fi fi
;; ;;
a ) a )
@@ -484,7 +475,6 @@ else
"list" | "ls" ) "list" | "ls" )
item=$2 item=$2
if [ -z "$item" ]; then if [ -z "$item" ]; then
echo "--"
echo -e "$( \ echo -e "$( \
sed = "$TODO_FILE" \ sed = "$TODO_FILE" \
| sed 'N; s/^/ /; s/ *\(.\{2,\}\)\n/\1 /' \ | sed 'N; s/^/ /; s/ *\(.\{2,\}\)\n/\1 /' \
@@ -494,23 +484,42 @@ else
s/\(.*(A).*\)/'$PRI_A'\1 '$DEFAULT'/g; s/\(.*(A).*\)/'$PRI_A'\1 '$DEFAULT'/g;
s/\(.*(B).*\)/'$PRI_B'\1 '$DEFAULT'/g; s/\(.*(B).*\)/'$PRI_B'\1 '$DEFAULT'/g;
s/\(.*(C).*\)/'$PRI_C'\1 '$DEFAULT'/g; s/\(.*(C).*\)/'$PRI_C'\1 '$DEFAULT'/g;
s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g; s/\(.*([D-Z]).*\)/'$PRI_X'\1 '$DEFAULT'/g;
}' \ }' \
| sed 's/'${HIDE_PRIORITY_SUBSTITUTION:-^}'//g' \ | sed 's/'${HIDE_PRIORITY_SUBSTITUTION:-^}'//g' \
| sed 's/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g' \ | sed 's/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g' \
| sed 's/'${HIDE_CONTEXTS_SUBSTITUTION:-^}'//g' \ | sed 's/'${HIDE_CONTEXTS_SUBSTITUTION:-^}'//g' \
)" )"
echo "--"
NUMTASKS=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/') NUMTASKS=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
echo "TODO: $NUMTASKS tasks in $TODO_FILE." echo "TODO: $NUMTASKS tasks in $TODO_FILE."
else else
command=`sed = "$TODO_FILE" | sed 'N; s/^/ /; s/ *\(.\{2,\}\)\n/\1 /' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/' | grep -i $item ` command=$(
sed = "$TODO_FILE" \
| sed 'N; s/^/ /; s/ *\(.\{2,\}\)\n/\1 /' \
| sed 's/^ /0/' \
| sort -f -k2 \
| sed '/^[0-9][0-9] x /! {
s/\(.*(A).*\)/'$PRI_A'\1 '$DEFAULT'/g;
s/\(.*(B).*\)/'$PRI_B'\1 '$DEFAULT'/g;
s/\(.*(C).*\)/'$PRI_C'\1 '$DEFAULT'/g;
s/\(.*([D-Z]).*\)/'$PRI_X'\1 '$DEFAULT'/g;
}' \
| grep -i $item
)
shift shift
shift shift
for i in $* for i in $*
do do
command=`echo "$command" | grep -i $i ` command=`echo "$command" | grep -i $i `
done done
command=`echo "$command" | sort -f -k2` command=$( \
echo "$command" \
| sort -f -k2 \
| sed 's/'${HIDE_PRIORITY_SUBSTITUTION:-^}'//g' \
| sed 's/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g' \
| sed 's/'${HIDE_CONTEXTS_SUBSTITUTION:-^}'//g' \
)
echo -e "$command" echo -e "$command"
fi fi
cleanup ;; cleanup ;;
@@ -529,13 +538,7 @@ else
do do
command=`echo "$command" | grep -i $i ` command=`echo "$command" | grep -i $i `
done done
command=$( \ command=`echo "$command" | sort -f -k2`
echo "$command" \
| sort -f -k2 \
| sed 's/'${HIDE_PRIORITY_SUBSTITUTION:-^}'//g' \
| sed 's/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g' \
| sed 's/'${HIDE_CONTEXTS_SUBSTITUTION:-^}'//g' \
)
echo -e "$command" echo -e "$command"
fi fi
cleanup ;; cleanup ;;