Álvaro Ramírez
Emacs smartparens auto-indent
While I do most editing in Emacs, I use Xcode every now and then. I like Xcode's pair matching (of brackets) combined with its auto-indent.
While the wonderful smartparens gives Emacs pair-matching powers, it doesn't automatically indent between pairs (out of the box anyway).
Luckily, smartparens does provide sp-local-pair, which enables us to achieve a similar goal.
With a short snippet, we can autoindent between {}, [], and () when pressing return in-between.
(defun indent-between-pair (&rest _ignored) (newline) (indent-according-to-mode) (forward-line -1) (indent-according-to-mode)) (sp-local-pair 'prog-mode "{" nil :post-handlers '((indent-between-pair "RET"))) (sp-local-pair 'prog-mode "[" nil :post-handlers '((indent-between-pair "RET"))) (sp-local-pair 'prog-mode "(" nil :post-handlers '((indent-between-pair "RET")))
comments on twitter