]> code.delx.au - gnu-emacs-elpa/blob - README.md
Merge branch 'master' of github.com:Bruce-Connor/aggressive-indent-mode
[gnu-emacs-elpa] / README.md
1 aggressive-indent-mode
2 ======================
3 (_[Wanna say thank you?](https://gratipay.com/Malabarba/)_)
4
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
8 to go wrong.
9
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`.
13
14 ### Demonstration ###
15
16 - An example of Lisp mode (Emacs Lisp):
17 ![Lisp Code Example](lisp-example.gif)
18
19 - An example of non-Lisp mode (C):
20 ![C Code Example](c-example.gif)
21
22 ### Instructions ###
23
24 This package is available fom Melpa, you may install it by calling
25
26 M-x package-install RET aggressive-indent
27
28 Then activate it with
29
30 (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
31 (add-hook 'css-mode-hook #'aggressive-indent-mode)
32
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:
36
37 (global-aggressive-indent-mode 1)
38 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
39
40 #### Manual Installation ####
41
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:
44
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).
47
48 Then require it with:
49
50 (require 'aggressive-indent)
51
52 ### Customization ###
53
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
58 following clause:
59
60 (add-to-list
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)))))