Refactoring: Extract listWordsWithSigil() from listcon and listproj.

This commit is contained in:
Ingo Karkat
2012-04-13 21:16:33 +02:00
parent d7056c5e1e
commit e5e31b0f75

20
todo.sh
View File

@@ -860,7 +860,17 @@ _format()
fi fi
} }
export -f cleaninput getPrefix getTodo getNewtodo shellquote filtercommand _list getPadding _format die listWordsWithSigil()
{
sigil=$1
shift
FILE=$TODO_FILE
[ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR"
eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o "[^ ]*${sigil}[^ ]\\+" | grep "^$sigil" | sort -u
}
export -f cleaninput getPrefix getTodo getNewtodo shellquote filtercommand _list listWordsWithSigil getPadding _format die
# == HANDLE ACTION == # == HANDLE ACTION ==
action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' ) action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' )
@@ -1135,17 +1145,13 @@ case $action in
;; ;;
"listcon" | "lsc" ) "listcon" | "lsc" )
FILE=$TODO_FILE
[ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR"
shift shift
eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o '[^ ]*@[^ ]\+' | grep '^@' | sort -u listWordsWithSigil '@' "$@"
;; ;;
"listproj" | "lsprj" ) "listproj" | "lsprj" )
FILE=$TODO_FILE
[ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR"
shift shift
eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o '[^ ]*+[^ ]\+' | grep '^+' | sort -u listWordsWithSigil '+' "$@"
;; ;;
"listpri" | "lsp" ) "listpri" | "lsp" )