title: Vimscript - Previous buffer & propagate error message
body: <p>I'm working on a function that opens a help document in the current window, rather than a new split.
  This is the function now:</p>
  
  <pre><code>function! OpenHelpInCurrentWindow(topic) " {{{2
    " Open a helpfile in the current window, rather than a new split.
  
    try
    " Open the help document.
      execute 'help '.a:topic
  
      " Get buffer id of the help document.
      let l:help_buffer = bufnr("%")
  
      " Close the help buffers' window. This *should* return us to the window we ran
      " this command from.
      wincmd c
  
      " Switch to the help doc's buffer in the current window.
      :execute "buffer ".help_buffer
  
    catch
      echo 'Sorry, no help for ' . a:topic . '.'
    endtry
  
  endfunction
  </code></pre>
  
  <p>I map this to :H with:</p>
  
  <pre><code>command! -nargs=? -complete=help H call OpenHelpInCurrentWindow(&lt;q-args&gt;) 
  </code></pre>
  
  <p>There are currently two issues:</p>
  
  <p>If you enter a bad name for a help file, the help file doesn't open. When using the built-in help command (<code>:help</code>) this displays an error message in red, but doesn't require you to hit  to continue.</p>
  
  <p>If I display the error message with <code>echoerr</code>, it displays the message in red, but also displays the line number and requires  to continue (not the way <code>:help</code> works).</p>
  
  <p>If I display the error message with <code>echo</code>, it displays in the foreground color (not red like <code>:help</code>, but doesn't display the line number or require  to continue).</p>
  
  <p>Any ideas how I can make this more closely resemble the default behavior?</p>
  
  <p>The second issue is that when you open a help document using this function, the previous buffer is not set correctly. Trying to return to where I was using :bprevious dumps me into the wrong document.</p>
  
  <p>Any ideas why this is occuring, what tracks the 'buffer list' (I don't think this is tagstack), or how I might fix it?</p>
  
  <p>Thanks!</p>