Author Topic: complete-prev : should return unique values only  (Read 3817 times)

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
complete-prev : should return unique values only
« on: August 28, 2010, 05:05:24 PM »
hi

i just noticed the command

Code: [Select]
complete-prev
does not return unique values when invoked.

to reproduce: start a new file and enter the following text

Code: [Select]
help
hello
hello
hello

now in a new line type

Code: [Select]
hel
call
Code: [Select]
complete-prev
my intention is insert "help"

expected: If i call
Code: [Select]
complete-prev once it returns "hello" , called again returns "help"

outcome: I have to call 3 times
Code: [Select]
complete-prev to get the "help" added.

Suggestion:
Code: [Select]
complete-prev should only return unique values only.

hope this is tweaked


« Last Edit: August 28, 2010, 10:24:23 PM by ehab »

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: tweak request :: complete-prev ; should return unique values only
« Reply #1 on: August 28, 2010, 10:11:46 PM »
This is intentional, and is a major feature:  complete-prev isn't just returning matches, it also allows using complete-more to extend the completion.

For example suppose there are three "hello"s:
Code: [Select]
hello world
hello goodbye
hello to you

Now suppose you add a line and type "he" on the new line:
Code: [Select]
hello world
hello goodbye
hello forever
he

Now use complete-prev once to get "hello", but if you then used complete-more you'd get "hello forever".
Or use complete-prev twice to get "hello" again, but if you then used complete-more you'd get "hello goodbye".
Or use complete-prev thrice to get "hello" still, but if you then used complete-more you'd get "hello world".

If complete-prev returned only unique values, it would remove a major feature.  At least it's major for me, I use it all the time, many times per day, it's a huge typing saver and even helps avoid typing mistakes.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: tweak request :: complete-prev ; should return unique values only
« Reply #2 on: August 28, 2010, 10:13:04 PM »
There's complete-prev-no-dup and complete-next-no-dup for that  :)


ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: tweak request :: complete-prev ; should return unique values only
« Reply #3 on: August 28, 2010, 10:23:50 PM »
i was totally unaware of the
Code: [Select]
complete-prev-no-dup
gosh  :-[  i feel shame ... Thanks Graeme

@chrisant : i tried what you suggested ... i don't have use for such feature now, in fact it just added more confusion... i will look up the complete-more some other time... thanks to you 2.

my regards
ehab

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: complete-prev : should return unique values only
« Reply #4 on: August 28, 2010, 10:35:52 PM »
complete-more is useful when you have something like
person->name.surname
and you want to copy the whole lot.

I don't use it a lot compared with the no_dup functions but I guess it depends on the style of code you're working with.  I have function key F9 dedicated to the complete word functions.  You can switch between them at any stage.

  'F9'=            complete_prev_no_dup;
  'S-F9'=          complete_next_no_dup;
  'C-F9'=          complete_prev;
  'A-F9'=          complete_list;
  'C-S-F9'=        complete_next;
  'A-S-F9'=        complete_more;

Graeme