Give electric indent its own section

This commit is contained in:
Tom Willemse 2015-04-21 21:27:19 +02:00
parent bf669027f7
commit 6f46220968
2 changed files with 42 additions and 29 deletions

View file

@ -1364,8 +1364,7 @@ from myaethon2.core.decorators import (
#'oni:reset-default-directory) #'oni:reset-default-directory)
(oni:add-hooks 'js2-mode-hook (oni:add-hooks 'js2-mode-hook
#'tern-mode #'moz-minor-mode #'electric-pair-local-mode #'tern-mode #'moz-minor-mode #'electric-pair-local-mode)
#'electric-indent-local-mode)
(oni:add-hooks 'lisp-mode-hook (oni:add-hooks 'lisp-mode-hook
(lambda () (setf ac-sources '(ac-source-slime-simple))) (lambda () (setf ac-sources '(ac-source-slime-simple)))

View file

@ -1034,12 +1034,6 @@
(add-hook 'scss-mode-hook #'electric-pair-local-mode) (add-hook 'scss-mode-hook #'electric-pair-local-mode)
#+END_SRC #+END_SRC
- Automatically indent code.
#+BEGIN_SRC emacs-lisp
(add-hook 'scss-mode-hook #'electric-indent-local-mode)
#+END_SRC
- Enable auto-completion - Enable auto-completion
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1094,12 +1088,6 @@
(setq ruby-align-chained-calls t) (setq ruby-align-chained-calls t)
#+END_SRC #+END_SRC
- Automatically indent code.
#+BEGIN_SRC emacs-lisp
(add-hook 'ruby-mode-hook #'electric-indent-local-mode)
#+END_SRC
** Coffee ** Coffee
- Automatically match parentheses and other delimiters. - Automatically match parentheses and other delimiters.
@ -1110,12 +1098,6 @@
** PHP ** 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 *** Show tabs and spaces in indent
I'm working with some WordPress plugins nowadays and their style I'm working with some WordPress plugins nowadays and their style
@ -1183,23 +1165,55 @@
(add-to-list 'auto-mode-alist '("\\.html\\.erb$" . web-mode))) (add-to-list 'auto-mode-alist '("\\.html\\.erb$" . web-mode)))
#+END_SRC #+END_SRC
** JavaScript
Turn on electric indenting for JavaScript.
#+BEGIN_SRC emacs-lisp
(add-hook 'js2-mode-hook #'electric-indent-local-mode)
#+END_SRC
** CSS ** CSS
Turn on electric indent and electric pair modes for CSS. Turn on electric pair mode for CSS.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-hook 'css-mode-hook #'electric-indent-local-mode)
(add-hook 'css-mode-hook #'electric-pair-local-mode) (add-hook 'css-mode-hook #'electric-pair-local-mode)
#+END_SRC #+END_SRC
* 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)
#+END_SRC
* Load custom file * Load custom file
I don't really use the Emacs customization interface much, but I I don't really use the Emacs customization interface much, but I