Created
March 21, 2011 11:11
-
-
Save remvee/879305 to your computer and use it in GitHub Desktop.
Paredit for ruby and javascript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Enable paredit for a couple for non lisp modes; tweak | |
;; paredit-space-for-delimiter-predicates to avoid inserting spaces | |
;; before open parens. | |
(dolist (mode '(ruby espresso)) | |
(add-hook (intern (format "%s-mode-hook" mode)) | |
'(lambda () | |
(add-to-list (make-local-variable 'paredit-space-for-delimiter-predicates) | |
(lambda (_ _) nil)) | |
(enable-paredit-mode)))) |
@johnbendi I had the same question and ended up binding the following function to {
in the ruby-mode-map
(defun paredit-open-curly-smart ()
(interactive)
(if (or
(eq major-mode 'rjsx-mode)
(eq major-mode 'js-mode)
(eq major-mode 'js2-mode)
(eq major-mode 'ruby-mode)
(eq major-mode 'python-mode)
(eq major-mode 'lua-mode)
)
;; Just do same as `paredit-open-curly' in some mode.
(paredit-open-curly)
;; Otherwise do something smart operation.
(paredit-open-curly)
(indent-according-to-mode)
(comment-indent-new-line)
(open-newline-above 1)))
Source: https://www.emacswiki.org/emacs/paredit-extension.el
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why does paredit not complete curly braces
{}
?