From 6f46220968b22c191d346ec97a7bfe5204644970 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 21 Apr 2015 21:27:19 +0200 Subject: Give electric indent its own section --- emacs/.emacs.d/init.org | 64 ++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 25 deletions(-) (limited to 'emacs/.emacs.d/init.org') diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index f0314ca..5fb32b6 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -1034,12 +1034,6 @@ (add-hook 'scss-mode-hook #'electric-pair-local-mode) #+END_SRC - - Automatically indent code. - - #+BEGIN_SRC emacs-lisp - (add-hook 'scss-mode-hook #'electric-indent-local-mode) - #+END_SRC - - Enable auto-completion #+BEGIN_SRC emacs-lisp @@ -1094,12 +1088,6 @@ (setq ruby-align-chained-calls t) #+END_SRC - - Automatically indent code. - - #+BEGIN_SRC emacs-lisp - (add-hook 'ruby-mode-hook #'electric-indent-local-mode) - #+END_SRC - ** Coffee - Automatically match parentheses and other delimiters. @@ -1110,12 +1098,6 @@ ** PHP - - Automatically indent code - - #+BEGIN_SRC emacs-lisp - (add-hook 'php-mode-hook #'electric-indent-local-mode) - #+END_SRC - *** Show tabs and spaces in indent I'm working with some WordPress plugins nowadays and their style @@ -1183,21 +1165,53 @@ (add-to-list 'auto-mode-alist '("\\.html\\.erb$" . web-mode))) #+END_SRC -** JavaScript - Turn on electric indenting for JavaScript. +** CSS + + Turn on electric pair mode for CSS. #+BEGIN_SRC emacs-lisp - (add-hook 'js2-mode-hook #'electric-indent-local-mode) + (add-hook 'css-mode-hook #'electric-pair-local-mode) #+END_SRC -** CSS - - Turn on electric indent and electric pair modes for CSS. +* Minor modes + + Emacs offers a lot of minor modes and even more can be found in the + ELPA, MELPA and Marmalade repositories. These offer a lot of + customization possibilities and added features. + +** Electric indent + + Automatically indenting code upon typing certain characters can be + very useful for certain modes where the indentation level can + easily be determined. One of the first things I liked about Emacs + was the way the {{{key(TAB)}}} key worked: It indents to the + "proper" level of indentation, instead of adding a tab character. + It quickly grew into a habit to press tab several times when + editing a line or a block of code. Electric indent is just an + extension of this that, for the most part, allows me to forget + about pressing tab. + + It doesn't fit all modes though. When I worked in Python a lot I + was fighting the electric indent a lot more than it was helping me. + This is because instead of scope influencing indentation as in most + languages I've worked with, indentation determines scope in Python, + as anyone who's looked at it for more than a minute or two will + know. This means that any line can usually have several "proper" + indentation levels, depending on the meaning of meaning of that + line. + + So, almost all modes use =electric-indent-local-mode=, but a few + don't. So I'm also very happy that recently this mode was added, + because =electric-indent-mode= is a global minor mode and I only want + to use it in some 99% of the available modes. #+BEGIN_SRC emacs-lisp + (add-hook 'scss-mode-hook #'electric-indent-local-mode) + (add-hook 'ruby-mode-hook #'electric-indent-local-mode) + (add-hook 'php-mode-hook #'electric-indent-local-mode) + (add-hook 'js2-mode-hook #'electric-indent-local-mode) (add-hook 'css-mode-hook #'electric-indent-local-mode) - (add-hook 'css-mode-hook #'electric-pair-local-mode) #+END_SRC * Load custom file -- cgit v1.2.3-54-g00ecf