On Sat, 21 Oct 2006 at 1:59pm, Bram Moolenaar wrote:

>
> Hari Krishna Dara wrote:
>
> > When using |completion-function|, Vim is marking the buffer as modified,
> > as soon as the popup is triggered. When a plugin offers matches using
> > 'completefunc' the user should be able to cancel by pressing <C-E>
> > and this shouldn't leave the buffer as modified.
> >
> > Here is a sample function to show what I mean:
> >
> > function! TComplete(findstart, base)
> >     if a:findstart
> >         return 0
> >     else
> >         return [a:base]+['test1', 'test2']
> >     endif
> > endfunction
> > setl completefunc=TComplete
> >
> > Thinking about it, it might be that Vim automatically chooses the first
> > item in the completion, but this provides no option to leave buffer as
> > not modified when completion is cancelled without selecting an item. I
> > even tried explicitly setting nomodified (though it is ugly), something
> > like:
> >
> > inoremap <C-X><C-U> <C-X><C-U><C-R>=ResetModified()
> > function! ResetModified()
> >   setl nomodified
> >   return ''
> > endfunction
> >
> > But Vim seems to ignore this, as the buffer is still modified at the
> > end.
>
> The completion itself is seen as a change.  If you cancel completion
> it's like changing the text back to what it was.  It's very difficult to
> do this otherwise.

How about adding an option something like "showonly" in 'completeopt',
that when set brings up the menu, but doesn't automatically choose the
first item? However this should probably be better controlled at per
buffer level. There were requests before for this same issue, e.g.,
someone was trying to map "." to bring up omni-completion menu, but
didn't want the first item to be automatically chosen (as it is the case
in *all* the IDEs), and the workaround was to include the "." also as
part of completion (it solves the problem, but I think is ugly, as you
need to type <C-N> or <C-P> twice to get to the real first item or last
item in the matches). If there is a way for the |complete-function| to
indicate this option, it will solve this problem.

-- 
Thank you,
Hari

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

Reply via email to