Indenting new curly bracket blocks with smartparens for R

Emacs speaks statistics handle indentation for curly bracket blocks quite well. My preference was to have, after inserting matching opening and closing curly brackets, a newline with the cursor indented one block in. This post in particular describes the solution; it worked fine as of today.
Addendum: 2014-04-17
Here is the code snippet from the above link:

(sp-local-pair 'c++-mode "{" nil :post-handlers '((my-create-newline-and-enter-sexp "RET")))
(defun my-create-newline-and-enter-sexp (&rest _ignored)
  "Open a new brace or bracket expression, with relevant newlines and indent. "
  (newline)
  (indent-according-to-mode)
  (forward-line -1)
  (indent-according-to-mode))

Addendum: 2014-05-06
Here is a link to the documentation on using pre and post pair handlers.

Leave a Reply

Your email address will not be published. Required fields are marked *