Hari Krishna Dara wrote:

> > > I have a command with custom completion function that employs the :redir
> > > mechanism to determines the matches. This used to work fine in Vim6.3,
> > > but is broken in Vim7.0. I don't see any sandbox restrictions that could
> > > apply in this case, but even if they do, the command for which I am
> > > redirecting the output itself is very simple, it is just an :echo on a
> > > simple string, something like this:
> > >
> > > :Echo delete
> > >
> > > and the command Echo is defined as
> > >
> > > :command! -complete=file -nargs=* Echo :echo <q-args>
> > >
> > > Is this a bug in Vim7 or some change that is not backwards compatible?
> > > What would be the change that caused this to break?
> >
> > You don't give enough information to write a meaningful reply.
> 
> Sorry, I thought my description was complete enough, but anyway, here I
> extracted the code that breaks.
> 
> command! -complete=file -nargs=* GUDebugEcho :echo <q-args>
> function! UserFileExpand(fileArgs)
>     return substitute(GetVimCmdOutput('GUDebugEcho ' . a:fileArgs),
> '^\_s\+\|\_s\+$', '', 'g')
> endfunction
> 
> If UserFileExpand() is called from custom completion function, it no
> longer captures any output (this works fine in 6.3), but it works fine
> if you call from command line or scripts.
> 
> This doesn't work (this is just a dummy command to show the epansion
> doesn't return anything, the input() prompt shows that expansion didn't
> work):
> :TT abc<Tab>
> 
> Where TT is defined as:
> command! -nargs=* -complete=custom,CustComplete TT :echo <q-args>
> function! CustComplete(ArgLead, CmdLine, CursorPos)
>   let ArgLead = UserFileExpand(a:ArgLead)
>   call input('ArgLead: '.a:ArgLead.' expanded: ' . ArgLead)
>   return ArgLead
> endfunction
> 
> This works:
> :echo UserFileExpand('abc')
> 
> And this too works:
> echo CustComplete('abc', '', 0)
> 
> The GetVimCmdOutput() is simply a wrapper around :redir and here is how
> it is defined:
> 
> function! GetVimCmdOutput(cmd)
>   let v:errmsg = ''
>   let output = ''
>   let _z = @z
>   let _shortmess = &shortmess
>   try
>     set shortmess=
>     redir @z
>     exec a:cmd
>   catch /.*/
>     let v:errmsg = substitute(v:exception, '^[^:]\+:', '', '')
>   finally
>     redir END
>     let &shortmess = _shortmess
>     if v:errmsg == ''
>       let output = @z
>     endif
>     let @z = _z
>   endtry
>   return output
> endfunction

Well, you do give more information, but you have not explained what you
mean with "is broken".  What error message do you get?  You may have to
set the 'verbose' option to see something.  You can change the commands
to figure out where it goes wrong.

-- 
ARTHUR: Listen, old crone!  Unless you tell us where we can buy a shrubbery,
        my friend and I will ... we will say "Ni!"
CRONE:  Do your worst!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Reply via email to