On Tue, 20 Jun 2006 at 8:49pm, Bram Moolenaar wrote:
>
> Please dig into this a bit more.  GetVimCmdOutput() is a long function,
> what part of it doesn't work?    The ":redir" command is allowed in the
> sandbox.Again, set 'verbose' to possibly see an error message.  And/or
> add some "echomsg" commands to find out what is happening.
>

The GetVimCmdOutput() function is just an exec with a redir, all the
rest of the code is to make it more reliable, at its simplest, the
function would be:

function! GetVimCmdOutput(cmd)
  let v:errmsg = ''
  redir @z
  silent! exec a:cmd
  redir END
  if v:errmsg == ''
    return @z
  endif
  return ''
endfunction

In any case, I put a message right after the "redir END" for the value
of @z. When it works, it shows the right value, and when it doesn't it
is totally empty. What else would you need to proove that the redir
didn't work? I tried with verbose=15, but it didn't tell me anything
more. Here is the original code again with the new GetVimCmdOutput()
function for your convenience.  After sourcing all the code, first
execute:

:echo UserFileExpand('abc')

and make sure the the value of @z is right. Next execute:

:TT abc<Tab>

(where <Tab> is a literal tab character), and observe that it is empty.

>>>>
command! -complete=file -nargs=* GUDebugEcho :echo <q-args>
function! UserFileExpand(fileArgs)
    return substitute(GetVimCmdOutput('GUDebugEcho ' . a:fileArgs),
'^\_s\+\|\_s\+$', '', 'g')
endfunction

command! -nargs=* -complete=custom,CustComplete TT :echo <q-args>
function! CustComplete(ArgLead, CmdLine, CursorPos)
  let ArgLead = UserFileExpand(a:ArgLead)
  return ArgLead
endfunction

function! GetVimCmdOutput(cmd)
  "set verbose=15
  let v:errmsg = ''
  redir @z
  silent! exec a:cmd
  redir END
  call input('@z value is:' . @z)
  "set verbose=0
  if v:errmsg == ''
    return @z
  endif
  return ''
endfunction
<<<<

-- 
Thanks,
Hari

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

Reply via email to