From da6f343032cb01597dc7866e66f091adf3243a62 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 20 Nov 2021 03:10:50 +0000 Subject: Initial public snapshot With code from Bill. Thanks Bill! --- tools/todo | 5 +++++ tools/todo.sh | 35 +++++++++++++++++++++++++++++++++++ tools/todo.vim | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 tools/todo create mode 100644 tools/todo.sh create mode 100644 tools/todo.vim (limited to 'tools') diff --git a/tools/todo b/tools/todo new file mode 100644 index 0000000..7903eb3 --- /dev/null +++ b/tools/todo @@ -0,0 +1,5 @@ +#!/bin/sh -e +# This file is dedicated to the public domain. + +. "$0.sh" +todo "$@" diff --git a/tools/todo.sh b/tools/todo.sh new file mode 100644 index 0000000..44c7929 --- /dev/null +++ b/tools/todo.sh @@ -0,0 +1,35 @@ +# This file is dedicated to the public domain. + +todo() { + if [ $# = 0 ]; then + printf "Active TODO list:\n\n" + ls TODO/ | { + while read _l; do + printf " * %s: " "$_l" + head -n1 "TODO/$_l" + done + } + return + fi + if [ $# != 1 ]; then + echo "expected 0 or 1 argument(s)" + return + fi + if [ -f "TODO/$1" ]; then + printf "Active TODO item: " + _f="TODO/$1" + elif [ -f "TODO/.$1" ]; then + printf "Inactive TODO item: " + _f="TODO/.$1" + else + echo "TODO item not found: $1" + return + fi + head -n1 "$_f" + printf "\n" + sed -n '/^====$/,$p' "$_f" + printf "====\n\nMentions in project:\n" + git grep -Fn "TODO($1)" || echo "" +} + +# vi: sw=4 ts=4 noet tw=80 cc=80 diff --git a/tools/todo.vim b/tools/todo.vim new file mode 100644 index 0000000..04c704d --- /dev/null +++ b/tools/todo.vim @@ -0,0 +1,41 @@ +" This file is dedicated to the public domain. + +function! Todo(...) + if exists("a:1") && a:1 != "" + copen + " cex "" | cadde to avoid insta-jumping + if &shell == "cmd.exe" + cex "" | cadde system("git grep -nF TODO(".shellescape(a:1).")") + else + cex "" | cadde system("git grep -nF \"TODO(\"".shellescape(a:1)."\\)") + endif + else + " just displaying like this for now... + if &shell == "cmd.exe" + " FIXME: write a Windows batch equivalent!? in the meantime, you + " need a Unix shell to track issues :^) + cex "" | cclose | !sh tools/todo + else + cex "" | cclose | !tools/todo + endif + endif +endfunction + +function! TodoEdit(...) + if exists("a:1") && a:1 != "" + exec "tabe TODO/".a:1 + if line('$') == 1 && getline(1) == '' + normal o==== + 1 + else + 3 " XXX should really search for ====, but this is fine for now + endif + else + echoerr "Specify an issue ID" + endif +endfunction + +command! -nargs=? Todo call Todo("") +command! -nargs=? TodoEdit call TodoEdit("") + +" vi: sw=4 ts=4 noet tw=80 cc=80 -- cgit v1.2.3