Skip to content

Instantly share code, notes, and snippets.

@tonini
Created June 15, 2015 12:22
Show Gist options
  • Save tonini/7e98a01d248cd99fc30c to your computer and use it in GitHub Desktop.
Save tonini/7e98a01d248cd99fc30c to your computer and use it in GitHub Desktop.
;; Smartparens - Minor mode for Emacs that deals with parens pairs and tries to be smart about it
;; https://github.com/Fuco1/smartparens
;;
;; How to deal with do/end ->/end blocks in your Elixir files:
(eval-after-load 'smartparens
'(progn
(defun my-elixir-do-end-close-action (id action context)
(when (eq action 'insert)
(newline-and-indent)
(previous-line)
(indent-according-to-mode)))
(sp-with-modes '(elixir-mode)
(sp-local-pair "do" "end"
:when '(("SPC" "RET"))
:post-handlers '(:add my-elixir-do-end-close-action)
:actions '(insert))
(sp-local-pair "->" "end"
:when '(("SPC" "RET"))
:post-handlers '(:add my-elixir-do-end-close-action)
:actions '(insert)))))
;; Smartparens faces
;;
;; - disable pair overlay for readability
(setq sp-highlight-pair-overlay nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment