Skip to content
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

Problem creating a completion file for "vv" #1

Open
joelthelion opened this issue Nov 9, 2009 · 2 comments
Open

Problem creating a completion file for "vv" #1

joelthelion opened this issue Nov 9, 2009 · 2 comments

Comments

@joelthelion
Copy link

Hi,

I have created a simple completion file for vv, a medical image viewer:

image = !ls -1 | grep -E '\.(mhd|dcm|png|jpg|vox)$' ;
vector = !ls -1 | grep -E '(\.vf|.*vf.*\.mhd)$' ;

vv <image> [ <image> | --vf <vector> | --overlay <image> ] ...

The first word () is completed alright, however if I type the following:

vv 4d_lungs_iso2.mhd --vf

in a directory containing the following files:

4d_from_60_to_50_iso2.mhd  4d_lungs_iso2.mhd  stats        vf_demon_4d_60_to_50.mhd  vf_ffd_4d_60_to_all.mhd
4d_from_60_to_50_iso2.raw  4d_lungs_iso2.raw  ventilation  vf_demon_4d_60_to_50.raw  vf_ffd_4d_60_to_all.raw

I get the following completions:

4d_from_60_to_50_iso2.mhd   --overlay                   vf_demon_4d_60_to_50.mhd
4d_lungs_iso2.mhd           --vf                        vf_ffd_4d_60_to_all.mhd

when I would expect:

vf_demon_4d_60_to_50.mhd  vf_ffd_4d_60_to_all.mhd

Am I missing something? Or is this a bug?

@mbrubeck
Copy link
Owner

mbrubeck commented Nov 9, 2009

Thanks for the bug report!

This happens because compleat thinks that your "--vf" could be either an <image> or the --vf option. (For performance reasons it runs the image shell command only if it's completing the last word on the command line; otherwise it just matches anything.)

I could fix this by (optionally?) allowing completers to run a shell command to generate matches mid-command-line. Another solution that would be faster (but maybe more complicated for users) is a "prioritized choice" operator. Then you could write something like this:

vv [--vf <image> || --overlay <image> || <image>] ...

and then the <image> pattern would be tried only if --vf and --overlay did not already match the current word.

Finally, I've been thinking about giving special treatment to any argument starting with dashes, so they would be distinguished somehow from other things like filename arguments.

I'll try out one or more of these ideas sometime, and I'll let you know what I come up with...

@joelthelion
Copy link
Author

Thanks for your answer! And thanks again for the great software, you're really filling a void here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants