beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 138 forks source link

Better Bash Completion #554

Closed starcraftman closed 4 years ago

starcraftman commented 9 years ago

There are some problems with current bash completion this project provides. May apply to zsh as well, though I don't currently have a replacement for that one.

1) Not distributed as shown by #486, even if the generator were packaged it requires the Template.pm module & App::Ack be installed(edit: forgot about the make target for this). For people just fetching the standalone bit of a nuisance having to get whole repo + gen make etc...

1) The generated bash completion hard codes the strings for long/short opts. You need to regenerate on every change.

1) Some completions aren't handled well, like ack --type= & ack --type. In the former, no options appear, the latter misses the no equivalents. Some other things like color completion not there.

I noticed all this at this point as I was redoing some of my own bash completion scripts. I believe I've made a bash completer that is a good improvement. You can see it in my own dotfiles here. It uses ack itself to parse the opts. This means that completer should complete any version of ack, past or future.

I didn't make a PR because I think this has to be discussed re your mailing list & also something similar would have to be done for zsh I suppose. As a consequence of this change, you could simply point people to a link for the completer rather than building it That's tangential though, I'd mainly just like the default bash completion better for users.

starcraftman commented 9 years ago

Regarding zsh completion, I forgot to point out this excellent project which I use. https://github.com/zsh-users/zsh-completions If you guys wanted you could simply ensure that _ack was up to date and direct users to download it/the repo.

hoelzro commented 9 years ago

Hi @starcraftman, thanks for the input! To address each of your points...

Why don't you open up a post on the mailing list to discuss this; I think you've pointed out some valid problems, though, so opening up a PR to address them would be spectacular. We're in kind of a code freeze at the moment, but your changes would probably go out in 2.18!

petdance commented 9 years ago

Personally, I would rather point people at the zsh-completions project than to distribute the file as part of the ack distro.

starcraftman commented 9 years ago

@hoelzro To clarify on point 2, I employ caching to avoid this on every tab. The parsing happens only once per terminal session (i.e. the first tab complete of ack), which seems an acceptable trade off. See here.

I did make a mailing list post, just linked to this topic so I didn't have to rewrite. I only mailed users, that seemed to be suggested.

Re generator, that makes more sense that you package the output files. Though if I were to make a PR to put in my bash completion, then you'd only need to generate the zsh one, if that.

petdance commented 4 years ago

There will probably be no more releases of ack 2. If this is still a relevant idea, please submit it to the ack3 repo at https://github.com/beyondgrep/ack3.