title: indent ruby code on the fly in emacs
body: <p>How to make Emacs automatically reindent Ruby code on the fly?</p>
  
  <p>for example, with this in Emacs,</p>
  
  <pre><code>def hello
    puts "hello"
    en
  </code></pre>
  
  <p>After I type 'd', I want it to turn into this,</p>
  
  <pre><code>def hello
    puts "hello"
  end
  </code></pre>
  
  <p>This is the default in Vim, but how can I achieve that in Emacs?</p>