On Feb 8, 1:43 pm, epanda <[email protected]> wrote: > Hi, > > I am working on this tutorial > :http://vim.wikia.com/wiki/Execute_external_programs_asynchronously_un... > > I have tried with the dir binary under windows to let people test the > example: > > This is the launch command cmd : > > let cmd = 'silent !start cmd /c "dir C:\Users\Admin /S > '.temp_file > \ .' & vim --servername '.v:servername.' --remote-expr > "GetAsyncText('."'".temp_file."')\"" > \ .' & pause"' > > exec ''.cmd > > Here is the GetAsyncText function : > function! GetAsyncText(temp_file_name) > " original code > " echomsg readfile(a:temp_file_name)[0] > " call delete(a:temp_file_name) > > " set up the errorformat so Vim can parse the output > let oldefm = &errorformat > let &errorformat = &grepformat > > " parse the results into the quickfix window, but don't jump to the > first > " search hit > exec 'cgetfile '.a:temp_file_name > > " restore the previous state > let &errorformat = oldefm > call delete(a:temp_file_name) > > " the echomsg is mostly debug, but could be used instead of the > botright > " copen to alert the user without interfering > echomsg "got application output data ".a:temp_file_name > > " open the quickfix window but don't interfere with the user; jump > back to > " the current window after opening the quickfix window > botright copen > wincmd p > redraw > > endfunction > > The problem I got is that no output lines are retrieve into the copen > window.
The most obvious problem I see is that you are trying to use the :cgetfile command in Vim to parse output from the dir command on Windows, which does NOT have a format that will allow Vim to parse the output into a quickfix list using the grepformat defined for the findstr command on Windows. If you want the results in your quickfix list, you'll need to parse it yourself and call setqflist, or find a way to make an errorformat string to parse the output of the dir command (I'm not confident this is possible, without line numbers). Perhaps your first step to debug should be to just output the first line or two of your temporary file, as done in the code you have commented out at the top of your function. > Furthermore, it is not written in the tutorial but is this command can > retrieve along the spent time all output data ? > You want the execution time of the external function? Should be possible. You just need to retrieve the current time in your first function which calls the async command, store it off, retrieve it again in your results-parsing function, and compare the two values. -- You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php
