diff options
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Base/Utility/_arguments | 8 | ||||
-rw-r--r-- | Completion/Unix/Command/_todo.sh | 48 |
2 files changed, 28 insertions, 28 deletions
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index 05a287a5f..a87486168 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -5,6 +5,7 @@ local long cmd="$words[1]" descr mesg subopts opt usecc autod local oldcontext="$curcontext" hasopts rawret optarg singopt alwopt +local setnormarg long=$argv[(I)--] if (( long )); then @@ -189,12 +190,13 @@ fi subopts=() singopt=() -while [[ "$1" = -(O*|[CRWsw]) ]]; do +while [[ "$1" = -(O*|[CRWnsw]) ]]; do case "$1" in -C) usecc=yes; shift ;; -O) subopts=( "${(@P)2}" ); shift 2 ;; -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;; -R) rawret=yes; shift;; + -n) setnormarg=yes; NORMARG=-1; shift;; -w) optarg=yes; shift;; -s) singopt=(-s); shift;; -W) alwopt=arg; shift;; @@ -251,6 +253,10 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then descr="$descrs[anum]" subc="$subcs[anum++]" + if [[ $subc = argument* && -n $setnormarg ]]; then + comparguments -n NORMARG + fi + if [[ -n "$matched" ]] || _requested "$subc"; then curcontext="${oldcontext%:*}:$subc" diff --git a/Completion/Unix/Command/_todo.sh b/Completion/Unix/Command/_todo.sh index 5d60b9684..fc984f7d4 100644 --- a/Completion/Unix/Command/_todo.sh +++ b/Completion/Unix/Command/_todo.sh @@ -11,8 +11,9 @@ setopt localoptions braceccl local expl curcontext="$curcontext" state line pri nextstate local -a cmdlist itemlist +integer NORMARG -_arguments -s \ +_arguments -s -n : \ '-d[alternate config file]:config file:_files' \ '-f[force, no confirmation]' \ '-h[display help]' \ @@ -20,8 +21,7 @@ _arguments -s \ '-v[verbose mode, confirmation messages]' \ '-V[display version etc.]' \ '1:command:->commands' \ - '2:first argument:->firstarg' \ - '3:second argument:->secondarg' && return 0 + '*:arguments:->arguments' && return 0 local txtmsg="text, can include p:<project> and @<where>" @@ -45,11 +45,25 @@ case $state in _describe -t todo-commands 'todo.sh command' cmdlist ;; - (firstarg) - case $words[CURRENT-1] in + (arguments) + case $words[NORMARG] in (append|del|do|prepend|pri|replace) - itemlist=(${${(M)${(f)"$(todo.sh list)"}##<-> *}/(#b)(<->) (*)/${match[1]}:${match[2]}}) - _describe -t todo-items 'todo item' itemlist + if (( NORMARG == CURRENT - 1 )); then + itemlist=(${${(M)${(f)"$(todo.sh list)"}##<-> *}/(#b)(<->) (*)/${match[1]}:${match[2]}}) + _describe -t todo-items 'todo item' itemlist + else + case $words[NORMARG] in + (pri) + nextstate=pri + ;; + (append|prepend) + _message $txtmsg + ;; + (replace) + compadd -Q -- "${(qq)$(todo.sh list "^0*${words[CURRENT-1]} ")##<-> }" + ;; + esac + fi ;; (add) @@ -59,9 +73,6 @@ case $state in (list|listall) # This completes stuff beginning with p: (projects) or @ (contexts); # these are todo.sh conventions. - # We should do it for any argument after list or listall, but - # _arguments doesn't make that easy. We need it to tell us - # the position of the first non-option argument. _wanted search expl 'context or project' \ compadd ${${=${${(M)${(f)"$(todo.sh list)"}##<-> *}##<-> }}:#^(p:*|@*)} ;; @@ -75,23 +86,6 @@ case $state in ;; esac ;; - - (secondarg) - case $words[CURRENT-2] in - (append|prepend) - _message $txtmsg - ;; - (pri) - nextstate=pri - ;; - (replace) - compadd -Q -- "${(qq)$(todo.sh list "^0*${words[CURRENT-1]} ")##<-> }" - ;; - (*) - return 1 - ;; - esac - ;; esac case $nextstate in |