* todoman completion
@ 2022-08-28 6:43 Karel Balej
2022-08-28 10:56 ` Daniel Shahaf
0 siblings, 1 reply; 3+ messages in thread
From: Karel Balej @ 2022-08-28 6:43 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 899 bytes --]
Hello,
I'm trying to get the bundled zsh completion function [1] for todoman
[2] to work on my system but I don't seem to be able to do so.
Specifically, I'm currently attempting to make `todo list<Tab>` complete
the available lists. The problem I am stuck at seems to be that the cache
policy function `__todo_lists_cache_policy` at line 127 is never called
and I cannot figure out why: the cache policy setting at lines 147-151
seems correct and yet the call to `_cache_invalid` at line 153 does not
redirect to `__todo_lists_cache_policy` at all. If I place the function
name there directly, everything works as expected.
Could you please point me to the cause of this issue?
I attach a patch of other changes I have had to make for the completion
to work.
[1] https://github.com/pimutils/todoman/blob/main/contrib/completion/zsh/_todo
[2] https://github.com/pimutils/todoman
Thank you,
K.
[-- Attachment #2: todoman.patch --]
[-- Type: text/x-diff, Size: 1152 bytes --]
diff --git a/contrib/completion/zsh/_todo b/contrib/completion/zsh/_todo
index b9bbe8a..8951906 100644
--- a/contrib/completion/zsh/_todo
+++ b/contrib/completion/zsh/_todo
@@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: todoman completion
2022-08-28 6:43 todoman completion Karel Balej
@ 2022-08-28 10:56 ` Daniel Shahaf
2022-08-28 15:34 ` Karel Balej
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2022-08-28 10:56 UTC (permalink / raw)
To: Karel Balej; +Cc: zsh-users
Karel Balej wrote on Sun, Aug 28, 2022 at 08:43:42 +0200:
> Hello,
>
> I'm trying to get the bundled zsh completion function [1] for todoman
> [2] to work on my system but I don't seem to be able to do so.
>
> Specifically, I'm currently attempting to make `todo list<Tab>` complete
> the available lists. The problem I am stuck at seems to be that the cache
> policy function `__todo_lists_cache_policy` at line 127 is never called
> and I cannot figure out why: the cache policy setting at lines 147-151
> seems correct and yet the call to `_cache_invalid` at line 153 does not
> redirect to `__todo_lists_cache_policy` at all. If I place the function
> name there directly, everything works as expected.
>
> Could you please point me to the cause of this issue?
>
Observations:
1. _cache_invalid won't call the policy function at all if use-cache
isn't set.
2. The use of _cache_* functions isn't idiomatic (compare the callsites
of those functions in zsh.git:Completion/**/_*).
Hypothesis:
In your case the use-cache style is unset or set to false (check `zstyle
-L | grep use-cache`). That causes _cache_invalid to return false
without calling the policy function, then todoman's completion calls
_retrieve_cache and doesn't notice that it returns non-zero.
Thus:
Workaround: Set the use-cache style to a true value.
Fix: Call _retrieve_cache idiomatically.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: todoman completion
2022-08-28 10:56 ` Daniel Shahaf
@ 2022-08-28 15:34 ` Karel Balej
0 siblings, 0 replies; 3+ messages in thread
From: Karel Balej @ 2022-08-28 15:34 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: zsh-users
Your hypothesis was correct, thank you for the help!
Cheers,
K.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-28 15:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-28 6:43 todoman completion Karel Balej
2022-08-28 10:56 ` Daniel Shahaf
2022-08-28 15:34 ` Karel Balej
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).