On Mon, Apr 27, at 06:28 Dasn wrote:
> 
> On 27/04/09 08:02 +0200, Christian Brabandt wrote:
> > Hi Dasn!
> > 
> > On Mo, 27 Apr 2009, Dasn wrote:
> > 
> > > fun! MyFileComplete(ArgLead, CmdLine, CursorPos)
> > >     let ret=["file1", "file2", "file3"]
> > >     ".... A lot more other processing
> > >     return ret
> > > endfun
> > > 
> > > let cmd = input("Talking to Shell> ", "", "customlist,MyFileComplete")
> > > 
> > > Then at the prompt, I type:
> > > Talking to Shell> cp <Tab>        "Hit tab wanna got a file completion
> > > 
> > > The problem is: When I hit <Tab>, the "cp " (i.e, the command part) was
> > > also unexpectedly replaced by 'file1', 'file2' or 'file3'. It seems that
> > > the completion does not occur at the cursor position. Am I in the right
> > > way to complete this, or any idea to make a completion at the current
> > > cursor position? 
> > 
> > I think you are looking for complete-functions, rather than 
> > command-completion.
> > 
> > So please read :h complete-functions.
> > 
> 
> Hi Christian, thanks for your reply.
> I think the complete-functions are for insert-mode completions, while
> the input() function works in cmdline. The cursor position I referred is
> the cursor when we typing at the prompt of the input() function, not in
> the window, I didn't make it clearly, sorry.

I don't think that is possible, everything after the prompt will be
discarded with auto-completion, since this what you require from the
input() function (completion).

A simple way to overcome this problem, is to use twice the input()
function, one for to get the command and the other for the completion
for your object, something like:

fun! MyFileComplete(ArgLead, CmdLine, CursorPos)
    let ret=["file1", "file2", "file3"]
    ".... A lot more other processing
    return ret
endfun
let prompt = "Talking to shell> "

let cmd = input(prompt, '')." ".input(printf("%s%s ", prompt, 
        \histget("@", -1)), "", "customlist,MyFileComplete")

Then if you want to use <space> instead of <enter> you can map
temporally <enter> to <space>, like:

cnoremap <buffer> <silent> <space> <Char-0x0d>

So the whole procedure will be like this:

    Talking to shell> cp<space> <tab>

That's an idea, there might be better ways, but its quite usable like
this, not robust but usable if you are careful.

> Dasn

Regards,
Agathoklis.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to