aboutsummaryrefslogtreecommitdiffstats
path: root/emacs/.emacs.d/init.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2016-08-02 13:59:14 +0200
committerGravatar Tom Willemse2016-08-02 13:59:14 +0200
commit0dc7fb56845e67c685756534a6d21a76a5bcc4dd (patch)
tree585bb0ace153a0b4920a448b9420517e3d03b980 /emacs/.emacs.d/init.el
parentb07e4978a2af5ebd9c45e5b30c155658ac3f42f3 (diff)
downloadnew-dotfiles-0dc7fb56845e67c685756534a6d21a76a5bcc4dd.tar.gz
new-dotfiles-0dc7fb56845e67c685756534a6d21a76a5bcc4dd.zip
Add configuration for electric-indent-mode
Diffstat (limited to 'emacs/.emacs.d/init.el')
-rw-r--r--emacs/.emacs.d/init.el19
1 files changed, 19 insertions, 0 deletions
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: