From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11593 invoked by alias); 22 Nov 2009 13:14:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27422 Received: (qmail 8614 invoked from network); 22 Nov 2009 13:14:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=unavailable version=3.2.5 Received-SPF: none (proxy.melb.primenet.com.au: domain at convalesco.org does not designate permitted sender hosts) Subject: Re: [PATCH] ztodo: simple per-directory todo list manager (+completion) Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=utf-8 From: Panagiotis Atmatzidis In-Reply-To: <1258824614-14771-1-git-send-email-raorn@altlinux.org> Date: Sun, 22 Nov 2009 15:14:18 +0200 Cc: Zsh list , Zsh user list Content-Transfer-Encoding: quoted-printable Message-Id: <6022D6E3-96D0-4A48-90EF-44AACB875E89@convalesco.org> References: <1258824614-14771-1-git-send-email-raorn@altlinux.org> To: "Alexey I. Froloff" X-Mailer: Apple Mail (2.1077) On 21 =CE=9D=CE=BF=CE=B5 2009, at 7:30 =CE=BC.=CE=BC., Alexey I. Froloff = wrote: > I'm doing a lot of packaging/development jobs in different git > repositories. Sometimes certain things needs to be done, but it's not > time to commit anything yet. I am too lazy to use other TODO list > managers and often I just fail to remember that should be done in this > repository. >=20 > ztodo keeps per-path todo lists. Entries are kept in associative = array > (key is path) and cached in ~/.ztodolist file. I've added ztodo call = to > chpwd() finction, so I get reminder whenever I chdir to a directory. >=20 > .zshrc: > autoload -Uz ztodo > chpwd() { ztodo } >=20 > Sample session: >=20 > ~ $ cd src > ~/src $ ztodo add 'Collect underpants' > ~/src $ ztodo add '?' > ~/src $ ztodo add 'PROFIT!' > ~/src $ cd . > You have 3 things to do here. > ~/src $ ztodo list > 1: Collect underpants > 2: ? > 3: PROFIT! > ~/src $ ztodo del 2 > ~/src $ ztodo list > 1: Collect underpants > 2: PROFIT! > ~/src $ ztodo clear > ~/src $ ztodo list > ~/src $ >=20 > Signed-off-by: Alexey I. Froloff > --- > Completion/Zsh/Command/.distfiles | 1 + > Completion/Zsh/Command/_ztodo | 30 ++++++++++++++++++ > Functions/Misc/.distfiles | 1 + > Functions/Misc/ztodo | 62 = +++++++++++++++++++++++++++++++++++++ > 4 files changed, 94 insertions(+), 0 deletions(-) > create mode 100644 Completion/Zsh/Command/_ztodo > create mode 100644 Functions/Misc/ztodo >=20 > diff --git a/Completion/Zsh/Command/.distfiles = b/Completion/Zsh/Command/.distfiles > index 9e8e6ad..6feec49 100644 > --- a/Completion/Zsh/Command/.distfiles > +++ b/Completion/Zsh/Command/.distfiles > @@ -46,4 +46,5 @@ _zmodload > _zmv > _zpty > _zstyle > +_ztodo > ' > diff --git a/Completion/Zsh/Command/_ztodo = b/Completion/Zsh/Command/_ztodo > new file mode 100644 > index 0000000..73be91e > --- /dev/null > +++ b/Completion/Zsh/Command/_ztodo > @@ -0,0 +1,30 @@ > +#compdef ztodo > + > +_ztodo_entries() { > + local -a entries > + > + entries=3D(${${${${(f)"$(_call_program ztodo-entry ztodo = list)"}#[[:space:]]##}/:[[:space:]]##/:}%:[[:space:]]#}) > + _describe -t ztodo-entry 'todo entry' entries "$@" > +} > + > +local -a args reply > +args=3D( > + /$'[^\0]#\0'/ > +) > + > +local -a todo_entry > +todo_entry=3D( > + /$'[^\0]#\0'/ ':ztodo-entry:todo entry:_ztodo_entries' > +) > + > +_regex_words \ > + commands "ztodo command" \ > + 'add:add entry' \ > + 'del:delete entry:$todo_entry' \ > + 'clear:clear todo list' \ > + 'list:show todo list' > +args+=3D("$reply[@]") > + > +_regex_arguments _ztodo "${args[@]}" > + > +_ztodo "$@" > diff --git a/Functions/Misc/.distfiles b/Functions/Misc/.distfiles > index 4c74bbe..4ffbec1 100644 > --- a/Functions/Misc/.distfiles > +++ b/Functions/Misc/.distfiles > @@ -26,4 +26,5 @@ zmathfuncdef > zmv > zrecompile > zstyle+ > +ztodo > ' > diff --git a/Functions/Misc/ztodo b/Functions/Misc/ztodo > new file mode 100644 > index 0000000..439f3c5 > --- /dev/null > +++ b/Functions/Misc/ztodo > @@ -0,0 +1,62 @@ > +# vim: set ft=3Dzsh et sw=3D2 sts=3D2: > + > +emulate -L zsh > +setopt no_sh_word_split null_glob no_ksh_arrays > +typeset -gHA __ztodolist > +typeset -gH __ztodolastwrite > +local cachefile short_format list_format > +local tmp needupdate=3D0 > +local -a todos > + > +zstyle -s ':ztodo:*' cache-file cachefile || > + cachefile=3D"~/.ztodolist" > +zstyle -s ':ztodo:*' short-format short_format || > + short_format=3D"You have %n thing%1(n..s) to do here." > +zstyle -s ':ztodo:*' list-format list_format || > + list_format=3D"%-2n: %e" > + > +tmp=3D(${~tmp::=3D$cachefile(ms-$(( ${(%)tmp::=3D"%D{%s}"} - = ${__ztodolastwrite:-0} )))}) > +(( $#tmp )) && > + . $~cachefile > + > +todos=3D( ${(ps:\0:)__ztodolist[$PWD]} ) > + > +if (( $# )); then > + case "$1" in > + (add) > + shift > + todos=3D( $todos "$*" ) > + needupdate=3D1 > + ;; > + (del) > + shift > + todos[$1]=3D() > + needupdate=3D1 > + ;; > + (clear) > + shift > + todos=3D() > + needupdate=3D1 > + ;; > + (list) > + shift > + local i > + for (( i =3D 1; i <=3D $#todos; i++ )); do > + zformat -f tmp $list_format n:$i e:"${todos[$i]//\%/%%}" > + print -P "$tmp" > + done > + ;; > + esac > +else > + if [[ $#todos -gt 0 ]]; then > + zformat -f tmp $short_format n:$#todos > + print -P "$tmp" > + fi > +fi > + > +(( $#todos )) && > + __ztodolist[$PWD]=3D${(pj:\0:)todos} || > + unset "__ztodolist[$PWD]" > +(( needupdate )) && > + print -r "__ztodolist=3D( ${(kv@qq)^^__ztodolist} )" > = ${~cachefile} > +__ztodolastwrite=3D"${(%)tmp::=3D"%D{%s}"}" > --=20 > 1.6.5.3 >=20 Uh that's a smart one! Thanks for sharing. Now I need to find a way to drop into my mac mini = running tiger. I'll patch the file and foce installation. Does this work with prior 4.3.10 versions? (I know it should, just = asking) regads Panagiotis (atmosx) Atmatzidis email: atma@convalesco.org URL: http://www.convalesco.org GnuPG ID: 0xFC4E8BB4=20 gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xFC4E8BB4 -- The wise man said: "Never argue with an idiot. They bring you down to = their level and beat you with experience."