3 (_[Wanna say thank you?](https://gratipay.com/Malabarba/)_)
5 `electric-indent-mode` is enough to keep your code nicely aligned when
6 all you do is type. However, once you start shifting blocks around,
7 transposing lines, or slurping and barfing sexps, indentation is bound
10 **`aggressive-indent-mode`** is a minor mode that keeps your code **always**
11 indented. It reindents after every command, making it more reliable
12 than `electric-indent-mode`.
16 - An example of Lisp mode (Emacs Lisp):
17 ![Lisp Code Example](lisp-example.gif)
19 - An example of non-Lisp mode (C):
20 ![C Code Example](c-example.gif)
24 This package is available fom Melpa, you may install it by calling
26 M-x package-install RET aggressive-indent
30 (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
31 (add-hook 'css-mode-hook #'aggressive-indent-mode)
33 You can use this hook on any mode you want, `aggressive-indent` is not
34 exclusive to emacs-lisp code. In fact, if you want to turn it on for
35 every programming mode, you can do something like:
37 (global-aggressive-indent-mode 1)
38 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
40 #### Manual Installation ####
42 If you don't want to install from Melpa, you can download it manually,
43 place it in your `load-path` along with its two dependencies:
45 - [Names](https://github.com/Bruce-Connor/names/)
46 - and `cl-lib` (which you should already have if your `emacs-version` is at least 24.3).
50 (require 'aggressive-indent)
54 The variable `aggressive-indent-dont-indent-if` lets you customize
55 when you **don't** want indentation to happen.
56 For instance, if you think it's annoying that lines jump around in
57 `c++-mode` because you haven't typed the `;` yet, you could add the
61 'aggressive-indent-dont-indent-if
62 '(and (derived-mode-p 'c++-mode)
63 (null (string-match "\\([;{}]\\|\\b\\(if\\|for\\|while\\)\\b\\)"
64 (thing-at-point 'line)))))