From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18244 invoked from network); 13 Sep 2006 16:02:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Sep 2006 16:02:23 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 11169 invoked from network); 13 Sep 2006 16:02:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Sep 2006 16:02:16 -0000 Received: (qmail 8302 invoked by alias); 13 Sep 2006 16:02:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22704 Received: (qmail 8292 invoked from network); 13 Sep 2006 16:02:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Sep 2006 16:02:10 -0000 Received: (qmail 10911 invoked from network); 13 Sep 2006 16:02:10 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 13 Sep 2006 16:02:04 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly23c.srv.mailcontrol.com (MailControl) with ESMTP id k8DFt3C7008253 for ; Wed, 13 Sep 2006 17:01:39 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 13 Sep 2006 16:58:51 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.4/8.13.4) with ESMTP id k8DFwoqs004321 for ; Wed, 13 Sep 2006 16:58:50 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.4/8.13.4/Submit) with ESMTP id k8DFwoFS004318 for ; Wed, 13 Sep 2006 16:58:50 +0100 Message-Id: <200609131558.k8DFwoFS004318@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: completion for todo.sh Date: Wed, 13 Sep 2006 16:58:49 +0100 From: Peter Stephenson X-OriginalArrivalTime: 13 Sep 2006 15:58:51.0435 (UTC) FILETIME=[81A7CFB0:01C6D74D] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-04-01 (www.mailcontrol.com) on 10.67.0.133 Index: Completion/Unix/Command/_todo.sh =================================================================== RCS file: Completion/Unix/Command/_todo.sh diff -N Completion/Unix/Command/_todo.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Unix/Command/_todo.sh 13 Sep 2006 15:57:21 -0000 @@ -0,0 +1,106 @@ +#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). + +setopt localoptions braceccl + +local expl curcontext="$curcontext" state line pri nextstate +local -a cmdlist itemlist + +_arguments -s \ + '-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' \ + '2:first argument:->firstarg' \ + '3:second argument:->secondarg' && return 0 + +local txtmsg="text, can include p: and @" + +case $state in + (commands) + cmdlist=( + "add:Add TODO ITEM to todo.txt." + "append:Adds to item on line NUMBER the text TEXT." + "archive:Moves done items from todo.txt to done.txt." + "del:Deletes the item on line NUMBER in todo.txt." + "do:Marks item on line NUMBER as done in todo.txt." + "list:Displays all todo items containing TERM(s), sorted by priority." + "listall:Displays items including done ones containing TERM(s)" + "listpri:Displays all items prioritized at PRIORITY." + "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 + ;; + + (firstarg) + case $words[CURRENT-1] 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 + ;; + + (add) + _message $txtmsg + ;; + + (list|listall) + _message search term... + ;; + + (listpri) + nextstate=pri + ;; + + (*) + return 1 + ;; + 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 + (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 + ;; +esac -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php