aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/emacs
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-11-28 14:11:33 +0100
committerDan Gudmundsson <[email protected]>2016-11-28 14:11:33 +0100
commit426192d8dc2d524d532a60693781ae06701ae7d4 (patch)
tree777479caebceef90c37b30fd3c47181f0169fbc0 /lib/tools/emacs
parent3a9ecbfb76435d6832304d1f2f2fc25afaea5d1f (diff)
parentdb6f4adc01afb8efac35111870f4c9bf5cfcf270 (diff)
downloadotp-426192d8dc2d524d532a60693781ae06701ae7d4.tar.gz
otp-426192d8dc2d524d532a60693781ae06701ae7d4.tar.bz2
otp-426192d8dc2d524d532a60693781ae06701ae7d4.zip
Merge branch 'maint'
* maint: Add an option erlang-icr-indent
Diffstat (limited to 'lib/tools/emacs')
-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 12ef00f6a8..51f7e8e26c 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)
@@ -2921,14 +2926,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.
@@ -2950,7 +2957,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)