Debian Codegraph @

README.md

raw ◀ ▶
1 Debian patch touch this file
•1 aggressive-indent-mode
2 ======================
3
4 `electric-indent-mode` is enough to keep your code nicely aligned when
5 all you do is type. However, once you start shifting blocks around,
6 transposing lines, or slurping and barfing sexps, indentation is bound
7 to go wrong.
8
9 **`aggressive-indent-mode`** is a minor mode that keeps your code **always**
10 indented. It reindents after every change, making it more reliable
11 than `electric-indent-mode`.
12
13 ### Demonstration ###
14
15 - An example of Lisp mode (Emacs Lisp):
16 ![Lisp Code Example](lisp-example.gif)
17
18 - An example of non-Lisp mode (C):
19 ![C Code Example](c-example.gif)
20
21 ### Instructions ###
22
•23 Activate this package with
24
25 (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
26 (add-hook 'css-mode-hook #'aggressive-indent-mode)
27
28 You can use this hook on any mode you want, `aggressive-indent` is not
29 exclusive to emacs-lisp code. In fact, if you want to turn it on for
30 every programming mode, you can do something like:
31
32 (global-aggressive-indent-mode 1)
33 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
34
35 ### Customization ###
36
37 The variable `aggressive-indent-dont-indent-if` lets you customize
38 when you **don't** want indentation to happen.
39 For instance, if you think it's annoying that lines jump around in
40 `c++-mode` because you haven't typed the `;` yet, you could add the
41 following clause:
42
43 (add-to-list
44 'aggressive-indent-dont-indent-if
45 '(and (derived-mode-p 'c++-mode)
46 (null (string-match "\\([;{}]\\|\\b\\(if\\|for\\|while\\)\\b\\)"
47 (thing-at-point 'line)))))
48
49 ## Contribute ##
50
•51 Make a donation to the package author: <https://gratipay.com/Malabarba>