title: What's the best way to pass the unsaved buffer in a vim plugin?
body: <p>I'm writing a vim plugin based on clang to do auto-completion; I realize there are other plugins out there that do a similar thing, but none of them address my specific need (macro expansion).</p>
  
  <p>Anyhow, the clang api to parse a file takes a bunch of variables, including the unsaved buffer for the currently open file.</p>
  
  <p>ie. You pass in both the saved copy of the file and the current unsaved buffer, so you can (for example) do auto-completion as you type, rather than only after a save operation.</p>
  
  <p>So, my question is:</p>
  
  <p><strong>What's the best way to obtain the raw unsaved buffer in a vim plugin and pass it to an external executable?</strong></p>
  
  <p>Various solution pop to mind, eg.</p>
  
  <ol>
  <li><p>Write the current buffer to a temporary file and pass a reference to the temporary file to the external exec.</p></li>
  <li><p>Python plugin and the posix_ipc module to create a shared memory segement.</p></li>
  <li><p>Open a stream to the executable and pipe the current buffer into it one line at a time.</p></li>
  <li><p>Stream the buffer to the executable via a socket eclim style.</p></li>
  </ol>
  
  <p>I have no idea which one of these is the best choice, or if there's some other better way of doing this. </p>
  
  <p>I like the idea of using a shared memory segment, purely because this will make the plugin blazingly fast, but I can't see any way to do that in a portable fashion.</p>