Skip to content
Browse files

ENH: TODOTXT_SOURCEVAR enables different source file for listcon.

To be used by todo_completion (to offer candidates from done.txt when there are no matches in todo.txt), and maybe by custom addons.
  • Loading branch information...
1 parent fbee428 commit 9e13dfd2907d92bf6b400afb5edcbd65c4eb3c44 @inkarkat inkarkat committed Feb 21, 2012
Showing with 24 additions and 2 deletions.
  1. +19 −0 tests/t1310-listcon.sh
  2. +5 −2 todo.sh
View
19 tests/t1310-listcon.sh
@@ -55,4 +55,23 @@ test_todo_session 'listcon e-mail address test' <<EOF
@con02
EOF
+cat > todo.txt <<EOF
+@con01 -- Some context 1 task
+EOF
+cat > done.txt <<EOF
+x 2012-02-21 @done01 -- Some context 1 done task
+x 2012-02-21 @done02 -- Some context 2 done task
+EOF
+test_todo_session 'listcon from done tasks' <<'EOF'
+>>> TODOTXT_SOURCEVAR=\$DONE_FILE todo.sh listcon
+@done01
+@done02
+EOF
+test_todo_session 'listcon from combined open + done tasks' <<'EOF'
+>>> TODOTXT_SOURCEVAR='("$TODO_FILE" "$DONE_FILE")' todo.sh listcon
+@con01
+@done01
+@done02
+EOF
+
test_done
View
7 todo.sh
@@ -136,7 +136,7 @@ help()
EndOptionsHelp
- [ $TODOTXT_VERBOSE -gt 1 ] && cat <<-EndVerboseHelp
+ [ $TODOTXT_VERBOSE -gt 1 ] && cat <<-'EndVerboseHelp'
Environment variables:
TODOTXT_AUTO_ARCHIVE is same as option -a (0)/-A (1)
TODOTXT_CFG_FILE=CONFIG_FILE is same as option -d CONFIG_FILE
@@ -149,6 +149,7 @@ help()
TODOTXT_DEFAULT_ACTION="" run this when called with no arguments
TODOTXT_SORT_COMMAND="sort ..." customize list output
TODOTXT_FINAL_FILTER="sed ..." customize list after color, P@+ hiding
+ TODOTXT_SOURCEVAR=\$DONE_FILE use another source for listcon
EndVerboseHelp
@@ -1128,7 +1129,9 @@ case $action in
;;
"listcon" | "lsc" )
- grep -o '[^ ]*@[^ ]\+' "$TODO_FILE" | grep '^@' | sort -u
+ FILE=$TODO_FILE
+ [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR"
+ grep -ho '[^ ]*@[^ ]\+' "${FILE[@]}" | grep '^@' | sort -u
;;
"listproj" | "lsprj" )

0 comments on commit 9e13dfd

Please sign in to comment.
Something went wrong with that request. Please try again.