Lin wrote:
> Hi all,
>
> [...]
>
> To let the syntax checker see the buffer, I think the solution can
> only be making copies of related files.... The Flymake plug-in for
> Emacs, as already referred to in the first post, seems to be running
> some reasonable heuristics on finding the related files. But I think
> we can use something like "gcc -MM files" to find the dependencies for
> the currently opened files in the buffers. We restrict our scope to
> these files, and put all of them into a temp directory to do the
> check. This method looks a bit more efficient than doing heuristical
> brute force search around the current dir, but it would miss the
> errors in the files depending on current files but not opened. Or we
> should still do some heuristics to make up for this?
>
> [...]
>   

Why not do a real build in the background?
Heuristics and coping would not work for projects with complex makefiles.
Besides, if you are doing a real compilation and everything is OK the 
object files generated as a result of this background build are valuable 
and it is wasteful to throw them away.
I think that it maybe possible to rename an original file, save the 
buffer into a file with the same name as original and do the build.  If 
there are more than one modified buffer you need to save all of them 
before building or maybe filter buffers to be saved based on a regex or 
something.
In order to make Vim behave the same on the saved buffers the following 
scenario can be used (file name for the modified buffer is fileName.cpp):
1. :w fileName.cpp.new
2. :autocmd FileChangedShell fileName.cpp OnTheFlyMake_FileChangedShell()
3. :autocmd FileWritePre fileName.cpp OnTheFlyMake_FileWritePre()
4. :!mv fileName.cpp fileName.cpp.old && mv fileName.cpp.new fileName.cpp
5. :exec "!" . &makeprg
6. Parse make output using 'errorformat'.
7. Optionally update quick fix list.
8. :!mv fileName.cpp.old fileName.cpp
9. :autocmd! FileChangedShell fileName.cpp OnTheFlyMake_FileChangedShell()
10. :autocmd! FileWritePre fileName.cpp OnTheFlyMake_FileWritePre()

The OnTheFlyMake_FileChangedShell() function makes Vim ignore the fact 
that the real disk file was changed.
The OnTheFlyMake_FileWritePre() function should abort compilation, undo 
file renames and save the buffer into the disk file.  This was user will 
be able to save his work even when the background compilation is in 
progress.

Of course steps 2,3,9 and 10 does not need to be performed for each and 
every file.  It maybe more convenient (and maybe faster) to register the 
functions to be run for all files and to check via a script global list 
if the action has to be performed for the event.

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

Raspunde prin e-mail lui