-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General improvement to ZSH completion + bug fix in it #357
base: main
Are you sure you want to change the base?
Conversation
Use _files to complete the diretories in the path of tasks according to 'path =' in configuration file. Also, parse configuration file much more effectively.
Don't use any external tools other then todo command itself.
Hey @doronbehar , at the point where you match for if some file named Thanks for the changes :) |
I'm not sure what do you mean by 'capture group'. Never the less, thanks for pointing out the parameter
I think this should be consulted with @WhyNotHugo because I'm not totally sure as for the behaviour of todoman in this regard. When I run e.g. |
f43c6f4
to
ae1f60b
Compare
Thanks for your time on this, I'm not very fluent in zsh-completion scripts, but changes look good so far. Do you want to address the above comments in this PR too? |
Thanks for commenting on that @WhyNotHugo although TBH I could have tested that myself 😸. I've tested your statement and fortunately it seems todoman does accept both arguments to The question is then, whether we should actually support displaying the The way things work now is with a very simple file completion function that uses the parent directory of all calendars as a prefix. I like this simplicity so I would rather not change it. |
Generally,
This is because I set up vdirsyncer to pull all remote calendars, so it just uses the remote ID. I'd expect that setup to be relatively common. |
Oh right then, that's a definitely good reason to implement this suggestion. I've implemented that and according to my initial testings it works well. Pushing the current version. I'm not sure however, how should the completion handle calendar directories it finds that don't have a I hope this is not to hard to understand, I'm trying to support the use case of multiple |
Don't stop reading configuration file when a `path = ` is encountered. Build an array instead of all values of `path = ` in configuration file. Use every element in that array and expand any `*` in it and don't rely on the existence of a `displayname` file in the expanded directories. In case a directory without a `displayname` file in it is encountered, we revert to suggest the name of the directory itself.
Hey @doronbehar , |
@0x17de I understood what you meant :) But according to the manual (and I tested that inside and outside the completion function), the variable It would have been possible to set it temporarily and then unset back according to this option's state before but completion function started, similarly to what's done often with As for suggesting the Above all, I'm not sure that todoman even supports more than a single |
I had to check because I wasn't sure. More than one |
Yes, that's what todoman does. :) |
Look for the first `path = ` and then break. Expand it's value accordingly.
Oh right then, to me this is ready. |
Out of curiosity: would helper methods inside I'm thinking, of, for example, a command that prints all configuration and list settings in a shell-friendly manner. |
That's an excellent suggestion! As a somewhat experienced ZSH completions writer, I have encountered completion functions which needed to be aware of the command's configuration they are completing and thus they would either need to parse the configuration file themselves or ask the program for these specific values. Here are a few examples:
Todoman could certainly use such a helper command. As for it perhaps being slow, that doesn't have to be an issue if the user enables completion cache. We can base the cache validation check based on the modification date of the config file and if that's not newer then the cache, we'll check the modification date of the directory todoman reported back when we first created the cache. I've implemented a similar mechanism with Luarocks' completion. |
I can implement a config command. Do you think something like this is useful? Or does it end up slowing stuff? I'll fully trust your input on whether this is worthwhile or not:
Note: this took like 5 minutes, so feel free to say if it's useless. Also, format is aimed at being as shell-friendly as possible, so let me know if some other format is actually better. |
As I said before, if a user has enabled completion cache, the completion function will run the Never the less, both for the sake of it being more comfortable for me and for the quickness of it for users without completion cache enabled, perhaps an option to query a specific variable only will be better. I'd print only the requested variable's value in that case. Note that currently the completion parses As for the lists, I'd say that supplying There shouldn't be a need to see all configuration variables i.e when |
Sorry, it's been a while, but I don't think there's anything blocking this from being merged, right? |
EDIT: fixes #356