title: Relative Line Numbers In Emacs
body: <p>Does anyone know how if something like this <a href="http://dlo.me/vim-with-relative-line-numbers/" rel="noreferrer">Vim Relative Line Numbers</a> exists for emacs? I use vimpulse, and man, that would be super handy to have! I know some lisp, so if it doesn't, I could try to make my own, if I got a point in the right direction.</p>
  
  <p><strong>Update</strong>: 
  Thanks to the correct response, I came up with this, that will show 1 for the current line, and -1 for the previous line, for combining with vimpulse yanks and deletes.</p>
  
  <p>Thanks a ton to all who helped! I know it is not exactly what Vim does, but what good is the Relative line numbers in vim that start at zero?? Silly vim.</p>
  
  <pre class="lang-lisp prettyprint-override"><code>(defvar my-linum-current-line-number 0)
  
  (setq linum-format 'my-linum-relative-line-numbers)
  
  (defun my-linum-relative-line-numbers (line-number)
    (let ((test2 (1+ (- line-number my-linum-current-line-number))))
      (propertize
       (number-to-string (cond ((&lt;= test2 0) (1- test2))
                               ((&gt; test2 0) test2)))
       'face 'linum)))
  
  (defadvice linum-update (around my-linum-update)
    (let ((my-linum-current-line-number (line-number-at-pos)))
      ad-do-it))
  (ad-activate 'linum-update)
  </code></pre>