diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index a9f9bab..73848d4 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -228,6 +228,25 @@ This is currently the data directory under the (ensure-library paredit) +;;;;; Electric indent mode: + +;;; By default `electric-indent-mode' is enabled globally, but I +;;; prefer to enable it locally where I need it. +(electric-indent-mode -1) + +;;; Since Emacs 24 `electric-indent-mode' switches the behavior of the +;;; C-j and RET keys. I prefer the original situation: +(defun oni:switch-newline-keys () + "Switch the C-j and RET keys in the local buffer." + (if electric-indent-mode + (progn + (local-set-key (kbd "C-j") 'newline) + (local-set-key (kbd "RET") 'electric-newline-and-maybe-indent)) + (local-unset-key (kbd "C-j")) + (local-unset-key (kbd "RET")))) + +(add-hook 'electric-indent-local-mode-hook #'oni:switch-newline-keys) + ;;;; Major modes: ;;;;; Emacs lisp mode: