void-packages/srcpkgs/todoman/patches/zsh_completion.patch

87 lines
4.2 KiB
Diff

A pull request containing this patch has been submitted upstream [1].
[1] https://github.com/pimutils/todoman/pull/495
diff --git a/contrib/completion/zsh/_todo b/contrib/completion/zsh/_todo
index b9bbe8a..53976e7 100644
--- a/contrib/completion/zsh/_todo
+++ b/contrib/completion/zsh/_todo
@@ -5,7 +5,7 @@ local common_options_help=(
'(- :)--help[Show a help message and exit]'
)
local common_options_start=(
- {-s,--start=}'[When the task starts]:DATE:__todo_date'
+ '--start=[When the task starts]:DATE:__todo_date'
)
local common_options_due=(
{-d,--due=}'[When the task is due]:DATE:__todo_date'
@@ -32,7 +32,7 @@ __color_mode(){
# }}}
# {{{ general helper: set variable of path to configuration file
__todo_set_conf(){
- todoman_configuration_file=${XDG_CONFIG_DIR:-${HOME}/.config}/todoman/todoman.conf
+ todoman_configuration_file=${XDG_CONFIG_DIR:-${HOME}/.config}/todoman/config.py
if [[ -f $todoman_configuration_file ]]; then
return 0
else
@@ -43,7 +43,7 @@ __todo_set_conf(){
# {{{ general helper: set variable main.path from configuration file
__todo_set_conf_path(){
if __todo_set_conf; then
- tasks_lists_path="$(sed -n -e 's/^[^#]\s*path\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null)"
+ tasks_lists_path="$(sed -n -e "s/^\\s*path\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null)"
# the eval echo is needed since the path may contain ~ which should be evalueated to $HOME
tasks_lists_dir="$(eval echo ${tasks_lists_path%/\**})"
if [[ -z "${tasks_lists_path}" || ! -d "${tasks_lists_dir}" ]]; then
@@ -59,18 +59,18 @@ __todo_set_conf_path(){
# {{{ general helper: set variables related to date and time formats for __todo_date
__todo_set_conf_dt(){
if __todo_set_conf; then
- date_format="$(eval echo $(sed -n -e 's/^[^#]\s*date_format\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null))"
- dt_separator="$(eval echo $(sed -n -e 's/^[^#]\s*dt_separator\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null))"
- time_format="$(eval echo $(sed -n -e 's/^[^#]\s*time_format\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null))"
+ date_format="$(eval echo $(sed -n -e "s/^\\s*date_format\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null))"
+ dt_separator="$(eval echo $(sed -n -e "s/^\\s*dt_separator\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null))"
+ time_format="$(eval echo $(sed -n -e "s/^\\s*time_format\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null))"
# default value according to documentation: https://todoman.readthedocs.io/en/stable/configure.html
if [[ -z "${date_format}" ]]; then
date_format="%x"
fi
if [[ -z "${dt_separator}" ]]; then
- dt_separator=""
+ dt_separator=" "
fi
if [[ -z "${time_format}" ]]; then
- time_format="%x"
+ time_format="%X"
fi
return 0
else
@@ -150,7 +150,7 @@ __todo_lists(){
zstyle ":completion:${curcontext}:" cache-policy __todo_lists_cache_policy
fi
local -a tasks_lists
- if _cache_invalid todoman_lists; then
+ if _cache_invalid todoman_lists || ! _retrieve_cache todoman_lists; then
if [[ ${tasks_lists_path} =~ '/*$' ]]; then
for dir in $(eval echo ${tasks_lists_path}); do
if grep "VTODO" -q -R "${dir}"; then
@@ -160,8 +160,6 @@ __todo_lists(){
done
fi
_store_cache todoman_lists tasks_lists
- else
- _retrieve_cache todoman_lists
fi
if [[ "${#tasks_lists[@]}" == 1 ]]; then
_message "only one list was detected: (\"${tasks_lists[1]}\")"
@@ -243,7 +241,7 @@ _command_list_options=(
'(--reverse --no-reverse)'{--reverse,--no-reverse}'[sort tasks in reverse order (see --sort)]'
"${common_options_start[@]}"
"${common_options_due[@]}"
- '--priority[Only show tasks with priority at least as high as TEXT]:TEXT:("low", "medium", "high")'
+ '--priority=[Only show tasks with priority at least as high as TEXT]:TEXT:("low" "medium" "high")'
'--startable[Show only todos which should can be started today]'
{-s,--status=}'[Show only todos with the provided comma-separated statuses]:STATUS:{_values -s , "status" "NEEDS-ACTION" "CANCELLED" "COMPLETED" "IN-PROCESS" "ANY"}'
"${common_options_help[@]}"