The help on complete() gives an example as a usage pattern which seems
to be very useful, but it doesn't work. Here is a slightly modified
example to avoid breaking the lines in email transmission:

inoremap <expr> <F5> ListWeeks()
func! ListWeeks()
  call complete(col('.'), ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
  return ''
endfunc

If you hit <F5>, Vim complains about the complete() as not allowed.

Error detected while processing function ListWeeks:
line    1:
E523: Not allowed here

I am assuming that this is another place where the code is too strict
than required (like setting :compiler in a FileChangeRO handler that I
reported long back).

I tried to modify this such that <expr> is not used, like this:

inoremap <F5> <C-R>=ListWeeks()<CR>

and it works fine, but <expr> approach is superior and more flexible.

Also, while playing with the above (by pressing <F5> repeatedly while
opening new lines) I observed that occassionally, "Mon" gets inserted
instead of "Sun". I can't find a reproduciable case other than trying to
bring up popup several times (happened twice while trying may be about
20 times). I have observed this in general while using the complete()
function that Vim advances one too many items in the completion list
(happens very often with my LookupFile plugin).

-- 
Thanks,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to