From: Panagiotis Atmatzidis <atma@convalesco.org>
To: "Alexey I. Froloff" <raorn@altlinux.org>
Cc: Zsh list <zsh-workers@zsh.org>, Zsh user list <zsh-users@zsh.org>
Subject: Re: [PATCH] ztodo: simple per-directory todo list manager (+completion)
Date: Sun, 22 Nov 2009 15:14:18 +0200 [thread overview]
Message-ID: <6022D6E3-96D0-4A48-90EF-44AACB875E89@convalesco.org> (raw)
In-Reply-To: <1258824614-14771-1-git-send-email-raorn@altlinux.org>
On 21 Νοε 2009, at 7:30 μ.μ., 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.
>
> 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.
>
> .zshrc:
> autoload -Uz ztodo
> chpwd() { ztodo }
>
> Sample session:
>
> ~ $ 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 $
>
> Signed-off-by: Alexey I. Froloff <raorn@altlinux.org>
> ---
> 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
>
> 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=(${${${${(f)"$(_call_program ztodo-entry ztodo list)"}#[[:space:]]##}/:[[:space:]]##/:}%:[[:space:]]#})
> + _describe -t ztodo-entry 'todo entry' entries "$@"
> +}
> +
> +local -a args reply
> +args=(
> + /$'[^\0]#\0'/
> +)
> +
> +local -a todo_entry
> +todo_entry=(
> + /$'[^\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+=("$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=zsh et sw=2 sts=2:
> +
> +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=0
> +local -a todos
> +
> +zstyle -s ':ztodo:*' cache-file cachefile ||
> + cachefile="~/.ztodolist"
> +zstyle -s ':ztodo:*' short-format short_format ||
> + short_format="You have %n thing%1(n..s) to do here."
> +zstyle -s ':ztodo:*' list-format list_format ||
> + list_format="%-2n: %e"
> +
> +tmp=(${~tmp::=$cachefile(ms-$(( ${(%)tmp::="%D{%s}"} - ${__ztodolastwrite:-0} )))})
> +(( $#tmp )) &&
> + . $~cachefile
> +
> +todos=( ${(ps:\0:)__ztodolist[$PWD]} )
> +
> +if (( $# )); then
> + case "$1" in
> + (add)
> + shift
> + todos=( $todos "$*" )
> + needupdate=1
> + ;;
> + (del)
> + shift
> + todos[$1]=()
> + needupdate=1
> + ;;
> + (clear)
> + shift
> + todos=()
> + needupdate=1
> + ;;
> + (list)
> + shift
> + local i
> + for (( i = 1; i <= $#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]=${(pj:\0:)todos} ||
> + unset "__ztodolist[$PWD]"
> +(( needupdate )) &&
> + print -r "__ztodolist=( ${(kv@qq)^^__ztodolist} )" > ${~cachefile}
> +__ztodolastwrite="${(%)tmp::="%D{%s}"}"
> --
> 1.6.5.3
>
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
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."
prev parent reply other threads:[~2009-11-22 13:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-21 17:30 Alexey I. Froloff
2009-11-22 13:14 ` Panagiotis Atmatzidis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6022D6E3-96D0-4A48-90EF-44AACB875E89@convalesco.org \
--to=atma@convalesco.org \
--cc=raorn@altlinux.org \
--cc=zsh-users@zsh.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).