Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] ztodo: simple per-directory todo list manager (+completion)
- X-seq: zsh-users 14589
- From: Panagiotis Atmatzidis <atma@xxxxxxxxxxxxxx>
- To: "Alexey I. Froloff" <raorn@xxxxxxxxxxxx>
- Subject: Re: [PATCH] ztodo: simple per-directory todo list manager (+completion)
- Date: Sun, 22 Nov 2009 15:14:18 +0200
- Cc: Zsh list <zsh-workers@xxxxxxx>, Zsh user list <zsh-users@xxxxxxx>
- In-reply-to: <1258824614-14771-1-git-send-email-raorn@xxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <1258824614-14771-1-git-send-email-raorn@xxxxxxxxxxxx>
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@xxxxxxxxxxxx>
> ---
> 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@xxxxxxxxxxxxxx
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."
Messages sorted by:
Reverse Date,
Date,
Thread,
Author