From 110ae85114abc12211e2fcae7dafc6400e57cdb1 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 16 Jan 2007 10:54:07 +0000 Subject: users/11113: improve _todo.sh --- Completion/Unix/Command/_todo.sh | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'Completion') diff --git a/Completion/Unix/Command/_todo.sh b/Completion/Unix/Command/_todo.sh index 455bb3d85..3bae98b1a 100644 --- a/Completion/Unix/Command/_todo.sh +++ b/Completion/Unix/Command/_todo.sh @@ -13,7 +13,7 @@ setopt localoptions braceccl local expl curcontext="$curcontext" state line pri nextstate -local -a cmdlist itemlist +local -a cmdlist itemlist match mbegin mend integer NORMARG _arguments -s -n : \ @@ -26,7 +26,8 @@ _arguments -s -n : \ '1:command:->commands' \ '*:arguments:->arguments' && return 0 -local txtmsg="text, can include p: and @" +local projmsg="context or project" +local txtmsg="text with contexts or projects" case $state in (commands) @@ -60,11 +61,7 @@ case $state in nextstate=pri ;; (append|prepend) - if [[ -prefix p: || -prefix @ ]]; then - nextstate=proj - else - _message $txtmsg - fi + nextstate=proj ;; (replace) compadd -Q -- "${(qq)$(todo.sh -p list "^0*${words[CURRENT-1]} ")##<-> }" @@ -73,15 +70,7 @@ case $state in fi ;; - (add) - if [[ -prefix p: || -prefix @ ]]; then - nextstate=proj - else - _message $txtmsg - fi - ;; - - (list|listall) + (add|list|listall) nextstate=proj ;; @@ -115,8 +104,13 @@ case $nextstate in (proj) # This completes stuff beginning with p: (projects) or @ (contexts); # these are todo.sh conventions. - _wanted search expl 'context or project' \ + if [[ ! -prefix p: && ! -prefix @ ]]; then + projmsg=$txtmsg + fi + # In case there are quotes, ignore anything up to whitespace before + # the p: or @ (which may not even be there yet). + compset -P '*[[:space:]]' + _wanted search expl $projmsg \ compadd ${${=${${(M)${(f)"$(todo.sh -p list)"}##<-> *}##<-> }}:#^(p:*|@*)} ;; esac - -- cgit 1.4.1