Skip to content

Instantly share code, notes, and snippets.

@hayeah
Created October 27, 2011 15:50
Show Gist options
  • Save hayeah/1319949 to your computer and use it in GitHub Desktop.
Save hayeah/1319949 to your computer and use it in GitHub Desktop.
Emacs Lisp For The Fail
(defun ruby-reindent-then-newline-and-indent ()
(interactive "*")
(let* ((cur (point))
;; we need to insert a space artificially for this test to work properly :(
(expand-p (progn (insert " ")
(ruby-electric-space-can-be-expanded-p))))
;; remove the inserted space
(progn (goto-char cur)
(delete-char 1))
(if expand-p
(progn (ruby-indent-line t)
(newline)
(newline) ;; want to open up a new line to go back to
(ruby-insert-end)
(previous-line)
(indent-according-to-mode))
(progn (newline)
(save-excursion
(end-of-line 0)
(indent-according-to-mode)
(delete-region (point) (progn (skip-chars-backward " \t") (point))))
(indent-according-to-mode)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment