title: Emacs Ruby autocomplete almost working
body: <p>I've been updating my emacs config with the use of Rsense to allow for an autocomplete drop down box to appear whilst typing code.  This works well in most files except I've found it doesn't allow me to select an answer from the table when I'm editing some code in my ruby on rails project.</p>
  
  <p>Here is my setup:
  <a href="https://github.com/map7/simple_emacs">https://github.com/map7/simple_emacs</a></p>
  
  <p>I'm using this under Ubuntu 10.04.</p>
  
  <p>For simple ruby script files it works great. I can open up a new file and type.</p>
  
  <pre class="lang-rb prettyprint-override"><code>"test".up...
  </code></pre>
  
  <p>Just as I type the 'p' character in up a list of options appear and I can go up and down the list with arrow keys and select one (eg: upcase) with the enter key.</p>
  
  <p>What doesn't work is when I do the exact same test but within a rails project's base directory.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Found that the problem is with (require 'rails), so it's something in the emacs-rails plugin that the autocomplete doesn't like.</p>
  
  <p><strong>Update:</strong> </p>
  
  <p>It's within emacs-rails -> rails-project.el. If I comment this macro out then autocomplete works, otherwise it doesn't:</p>
  
  <pre class="lang-rb prettyprint-override"><code>(defmacro* rails-project:with-root ((root) &amp;body body)
    "If you use `rails-project:root' or functions related on it
  several times in a block of code, you can optimize your code by
  using this macro. Also, blocks of code will be executed only if
  rails-root exist.
   (rails-project:with-root (root)
      (foo root)
      (bar (rails-core:file \"some/path\")))
   "
   `(let ((,root (rails-project:root)))
      (when ,root
        (flet ((rails-project:root () ,root))
          ,@body))))
  </code></pre>
  
  <p>Can someone explain why this breaks autocomplete?</p>