From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17505 invoked by alias); 25 Nov 2010 13:45:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15577 Received: (qmail 19073 invoked from network); 25 Nov 2010 13:45:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,MISSING_HEADERS, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=no version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Thu, 25 Nov 2010 13:45:34 +0000 From: Peter Stephenson Cc: zsh-users Subject: Re: todo.sh completion Message-ID: <20101125134534.58a6e784@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/KBJbkiw1wvWIJywGT+vi2Lt" X-OriginalArrivalTime: 25 Nov 2010 13:45:34.0731 (UTC) FILETIME=[08EC1DB0:01CB8CA7] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.71.0.121 --MP_/KBJbkiw1wvWIJywGT+vi2Lt Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Thu, 25 Nov 2010 14:23:35 +0100 Julien Nicoulaud wrote: > anyone using todo.sh completion script here ? > > I'm using zsh 4.3.10 on Ubuntu 10.10, and does not seem to work. It's changed since then; try the latest. pws Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom --MP_/KBJbkiw1wvWIJywGT+vi2Lt Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="_todo.sh" #compdef todo.sh # See http://todotxt.com for todo.sh. # # Featurettes: # - "replace" will complete the original text for editing # - completing priorities will cycle through A to Z (even without # menu completion) # - list and listall will complete + and @ from # values in existing entries # - will complete after + and @ if typed in message text setopt localoptions braceccl local expl curcontext="$curcontext" state line pri nextstate item local -a cmdlist itemlist match mbegin mend integer NORMARG _arguments -s -n : \ '-d[alternate config file]:config file:_files' \ '-f[force, no confirmation]' \ '-h[display help]' \ '-p[plain mode, no colours]' \ '-v[verbose mode, confirmation messages]' \ '-V[display version etc.]' \ '1:command:->commands' \ '*:arguments:->arguments' && return 0 local projmsg="context or project" local txtmsg="text with contexts or projects" # Skip "command" as command prefix if words after if [[ $words[NORMARG] == command && NORMARG -lt CURRENT ]]; then (( NORMARG++ )) fi case $state in (commands) cmdlist=( "add:add TODO ITEM to todo.txt." "addm:add TODO ITEMs, one per line, to todo.txt." "addto:add text to file (not item)" "append:adds to item on line NUMBER the text TEXT." "archive:moves done items from todo.txt to done.txt." "command:run internal commands only" "del:deletes the item on line NUMBER in todo.txt." "depri:remove prioritization from item" "do:marks item on line NUMBER as done in todo.txt." "help:display help" "list:displays all todo items containing TERM(s), sorted by priority." "listall:displays items including done ones containing TERM(s)" "listcon:list all contexts" "listfile:display all files in .todo directory" "listpri:displays all items prioritized at PRIORITY." "move:move item between files" "prepend:adds to the beginning of the item on line NUMBER text TEXT." "pri:adds or replace in NUMBER the priority PRIORITY (upper case letter)." "replace:replace in NUMBER the TEXT." "remdup:remove exact duplicates from todo.txt." "report:adds the number of open and done items to report.txt." ) _describe -t todo-commands 'todo.sh command' cmdlist ;; (arguments) case $words[NORMARG] in (append|command|del|move|mv|prepend|pri|replace|rm) if (( NORMARG == CURRENT - 1 )); then nextstate=item else case $words[NORMARG] in (pri) nextstate=pri ;; (append|prepend) nextstate=proj ;; (move|mv) nextstate=file ;; (replace) item=${words[CURRENT-1]##0##} compadd -Q -- "${(qq)$(todo.sh -p list "^[ 0]*$item " | sed '/^--/,$d')##<-> (\([A-Z]\) |)}" ;; esac fi ;; (depri|do|dp) nextstate=item ;; (a|add|addm|list|ls|listall|lsa) nextstate=proj ;; (addto) if (( NORMARG == CURRENT - 1 )); then nextstate=file else nexstate=proj fi ;; (listfile|lf) if (( NORMARG == CURRENT -1 )); then nextstate=file else _message "Term to search file for" fi ;; (listpri|lsp) nextstate=pri ;; (*) return 1 ;; esac ;; esac case $nextstate in (file) _path_files -W ~/.todo ;; (item) itemlist=(${${(M)${(f)"$(todo.sh -p list | sed '/^--/,$d')"}##<-> *}/(#b)(<->) (*)/${match[1]}:${match[2]}}) _describe -t todo-items 'todo item' itemlist ;; (pri) if [[ $words[CURRENT] = (|[A-Z]) ]]; then if [[ $words[CURRENT] = (|Z) ]]; then pri=A else # cycle priority pri=$words[CURRENT] pri=${(#)$(( #pri + 1 ))} fi _wanted priority expl 'priority' compadd -U -S '' -- $pri else _wanted priority expl 'priority' compadd {A-Z} fi ;; (proj) # This completes stuff beginning with + (projects) or @ (contexts); # these are todo.sh conventions. if [[ ! -prefix + && ! -prefix @ ]]; then projmsg=$txtmsg fi # In case there are quotes, ignore anything up to whitespace before # the + or @ (which may not even be there yet). compset -P '*[[:space:]]' _wanted search expl $projmsg \ compadd $(todo.sh lsprj) $(todo.sh lsc) ;; esac --MP_/KBJbkiw1wvWIJywGT+vi2Lt--