-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdavisp-indent.el
More file actions
35 lines (31 loc) · 1.28 KB
/
Copy pathdavisp-indent.el
File metadata and controls
35 lines (31 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(setq erlang-indent-level 4)
(defun erlang-outdent ()
(max 0 (- (current-indentation) erlang-indent-level)))
(defun erlang-indent ()
(+ (current-indentation) erlang-indent-level))
(defun erlang-indent-line ()
;; Watch out, this breaks if you comment your code!
(indent-line-to
(save-excursion
(while (progn
(forward-line -1)
(looking-at "^[[:space:]]*$")))
(end-of-line)
(cond ((equal (string (char-before)) ",") (current-indentation))
((equal (string (char-before)) "(") (erlang-indent))
((equal (string (char-before)) "[") (erlang-indent))
((equal (string (char-before)) "{") (erlang-indent))
((equal (string (char-before)) ".") (erlang-outdent))
((equal (string (char-before)) ";") (erlang-outdent))
((looking-back "->") (erlang-indent))
((looking-back " of") (erlang-indent))
;; Default case breaks on `end` statements of case clauses
(t (erlang-outdent))))))
(defun erlang-indent-region (start end)
(save-excursion
(goto-char start)
(while (progn
(when (not (looking-at "^[[:space:]]*$"))
(erlang-indent-line))
(forward-line)
(< (line-number-at-pos) (line-number-at-pos end))))))