Hari Krishna Dara wrote:
On Fri, 6 Oct 2006 at 8:19am, Jürgen Krämer wrote:

Hi,

Hari Krishna Dara wrote:
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 don't know the reason for this restriction, but it is documented under
":help complete()":

I am sorry, what exactly are you referring to as documented? The help on
complete() talks nothing about E523 or why it can't be used in <expr>
maps. In fact the above example is directly based on the example given
in that help.


He means this, from
*eval.txt*      For Vim version 7.0.  Last change: 2006 Sep 22

lines 2019-2023
---- 8< ----
complete({startcol}, {matches})                 *complete()* *E785*
                Set the matches for Insert mode completion.
                Can only be used in Insert mode.  You need to use a mapping
                with CTRL-R = |i_CTRL-R|.  It does not work after CTRL-O or
                with an expression mapping.
---- >8 ----

IIUC, "expression mapping" refers to ":imap <expr>".

":help E523" refers to the 'secure' option.

The difference between your mapping and the example is that you use ":imap <expr>" while the example does not use <expr> but uses <C-R>=

I don't know the reason for the restriction but it _is_ documented.


Best regards,
Tony.

Reply via email to