aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-11-28 14:10:13 +0100
committerDan Gudmundsson <[email protected]>2016-11-28 14:10:13 +0100
commitdb6f4adc01afb8efac35111870f4c9bf5cfcf270 (patch)
tree4542a50c777343b98b9a41f23931090fffc6a37d /lib/tools
parent544f9eb04929c7c61fbe97ecd651ac24288d0d12 (diff)
parentba7110c1565a7ca1272a647425aa573596347a47 (diff)
downloadotp-db6f4adc01afb8efac35111870f4c9bf5cfcf270.tar.gz
otp-db6f4adc01afb8efac35111870f4c9bf5cfcf270.tar.bz2
otp-db6f4adc01afb8efac35111870f4c9bf5cfcf270.zip
Merge branch 'victorhge/tools/emacs/icr_indentation/PR-1193' into maint
* victorhge/tools/emacs/icr_indentation/PR-1193: Add an option erlang-icr-indent
Diffstat (limited to 'lib/tools')
-rw-r--r--lib/tools/emacs/erlang.el25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index 40f0bb7f80..39c6065ce4 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -479,6 +479,11 @@ To activate the workaround, place the following in your `~/.emacs' file:
"*Indentation of Erlang calls/clauses within blocks.")
(put 'erlang-indent-level 'safe-local-variable 'integerp)
+(defvar erlang-icr-indent nil
+ "*Indentation of Erlang if/case/receive/ patterns. `nil' means
+ keeping default behavior. When non-nil, indent to th column of
+ if/case/receive.")
+
(defvar erlang-indent-guard 2
"*Indentation of Erlang guards.")
(put 'erlang-indent-guard 'safe-local-variable 'integerp)
@@ -2919,14 +2924,16 @@ Return nil if inside string, t if in a comment."
(t
(save-excursion
(goto-char (nth 1 stack-top))
- (if (looking-at "case[^_a-zA-Z0-9]")
- (+ (nth 2 stack-top) erlang-indent-level)
- (skip-chars-forward "a-z")
- (skip-chars-forward " \t")
- (if (memq (following-char) '(?% ?\n))
+ (if (and erlang-icr-indent
+ (looking-at "\\(if\\|case\\|receive\\)[^_a-zA-Z0-9]"))
+ (+ (nth 2 stack-top) erlang-icr-indent)
+ (if (looking-at "\\(case\\|receive\\)[^_a-zA-Z0-9]")
(+ (nth 2 stack-top) erlang-indent-level)
- (current-column))))))
- )
+ (skip-chars-forward "a-z")
+ (skip-chars-forward " \t")
+ (if (memq (following-char) '(?% ?\n))
+ (+ (nth 2 stack-top) erlang-indent-level)
+ (current-column))))))))
((and (eq (car stack-top) '||) (looking-at "\\(]\\|>>\\)[^_a-zA-Z0-9]"))
(nth 2 (car (cdr stack))))
;; Real indentation, where operators create extra indentation etc.
@@ -2948,7 +2955,9 @@ Return nil if inside string, t if in a comment."
;; If in fun definition use standard indent level not double
;;(if (not (eq (car (car (cdr stack))) 'fun))
;; Removed it made multi clause fun's look to bad
- (setq off (* 2 erlang-indent-level)))) ;; )
+ (setq off (+ erlang-indent-level (if (not erlang-icr-indent)
+ erlang-indent-level
+ erlang-icr-indent)))))
(let ((base (erlang-indent-find-base stack indent-point off skip)))
;; Special cases
(goto-char indent-point)