Re: [PATCH] kconfig: sort found symbols by relevance

Jean Delvare
2013-05-06T15:29:39Z

Le Monday 06 May 2013 à 15:02 +0200, Yann E. MORIN a écrit :
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
>
> When searching for symbols, return the symbols sorted by relevance.
>
> Relevance is the ratio of the length of the matched string and the
> length of the symbol name. Symbols of equal relevance are sorted
> alphabetically.
>
> Reported-by: Jean Delvare <jdelvare@suse.de>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: Michal Marek <mmarek@suse.cz>
> Cc: Roland Eggner <edvx1@systemanalysen.net>
> Cc: Wang YanQing <udknight@gmail.com>
> ---
> scripts/kconfig/symbol.c | 66 +++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 57 insertions(+), 9 deletions(-)

I did not look at the code, only tested it, and it does what I asked for
originally: exact match is listed first. So thank you :)

However I am not sure if your implementation is what we want. Your
definition of "relevance" is somewhat arbitrary and may not be
immediately to others. For example, my own definition of "relevance" was
that symbols which start with the subject string are more relevant than
the symbols which have the string in the middle. Others would possibly
have other definitions.

So in the end you have somewhat complex code for a sort order which may
surprise or confuse the user. It may put close to each other options
which are completely unrelated, and suboptions very far from their
parent.

I am wondering if it might not be better to go for a more simple
strategy: exact match on top and then sort alphabetically. Or even just
sort alphabetically - now that I know regexps are supported, it is easy
to get the exact match when I need it.

Just my two cents, maybe others have a diverging opinion.

Thanks for your work anyway,
--
Jean Delvare
Suse L3