[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a different approach to autocompletion

From: Martin Walch
Subject: a different approach to autocompletion
Date: Wed, 3 Mar 2010 23:03:14 +0100
User-agent: KMail/1.13.0 (Linux/2.6.31-gentoo-r6; KDE/4.4.0; x86_64; ; )

Hello list,

sorry if this is not the appropriate place for the following suggestion, but I 
do not which place would be bette.

I think autocompletion in shells (that is usually triggered with tab) is a 
great feature which I do not want to miss. However, over the years, I have 
seen several autocomplete implementations from a user's point of view and I 
think the whole mechanism is a mess. Many shells are trying to guess proper 
program names and command line arguments for every single program. The 
autocompletion for program names is working well in most cases. But the 
completion of command line arguments is broken by design. Why are shells even 
trying to guess command line arguments? They can not know for every program in 
the world what arguments it will take.

They still try to do it, because it is a useful feature. It it so useful, that 
I think it should be implemented in a proper way. However, in my opinion it is 
not up to a shell to decide what parameters and values may be passed to a 
command line program, as it can not know them all. Of course, it is possible 
to know what arguments a program from e. g. coreutils may take and to 
implement an autocompletion in the shell accordingly. However, this can only 
work with known programs, needs to be updated when the programs change, and 
needs to parse command line arguments similarly to how it is already done in 
the program itself.

Therefore I have an idea: let the program do the completion by itself. Every 
program could implement an interface that takes the already typed command line 
(and maybe pwd) and returns one or more suggestions for completion, or no 
suggestion or an error if there is no way to complete the argument. This could 
bring pretty many advantages:

- always in sync with the available commands in the current version of a 
- much mightier and more accurate, as e. g. make could autocomplete rules
- the scope is no more limited, as every program can implement this, the shell 
does need not to know it
- saves pretty much work, as there is no need to implement things more than 
once (no more in every shell)

I do not know how such an interface should be technically implemented. Maybe 
it can somehow be a part of the executable ELF file? Or maybe it should be a 
module that would be placed separately as a library? However, obviously, it 
would be useful to have a good, easy to use, standardized library (POSIX?) for 
defining, parsing and autocompleting command line arguments, probably with 
distinction between syntax and semantics, and with some standard 
implementations for autocompletion that may be overridden by the programmer if 

Such an interface could be even more expanded for things like version number 
or quick help. Additionally to a tab completion, there could be another key or 
key combination for a quick help on the last parameter. This interface could 
even allow to get informations about website, authors, license and so on.

In further development of the whole GNU system, filesystems could save files 
together with their file types (instead of guessing it with the program file 
or even worse, by file extension), which would allow easy filtering by file 
types, making autocompletion (and many other things) even better.

This is the rough idea. Do you think this is a good idea? Is there any chance 
that this can be accomplished?

Martin Walch
free software for a free society

reply via email to

[Prev in Thread] Current Thread [Next in Thread]