aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tools/emacs')
-rw-r--r--lib/tools/emacs/erlang.el81
-rw-r--r--lib/tools/emacs/test.erl.indented37
-rw-r--r--lib/tools/emacs/test.erl.orig39
3 files changed, 109 insertions, 48 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index 4b8911b758..4fc4826238 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -3955,15 +3955,16 @@ Return nil if inside string, t if in a comment."
(nth 2 stack-top))))
(t
(goto-char (nth 1 stack-top))
- (cond ((looking-at "[({]\\s *\\($\\|%\\)")
- ;; Line ends with parenthesis.
- (erlang-indent-parenthesis (nth 2 stack-top)))
- (t
- ;; Indent to the same column as the first
- ;; argument.
- (goto-char (1+ (nth 1 stack-top)))
- (skip-chars-forward " \t")
- (current-column))))))
+ (let ((base (cond ((looking-at "[({]\\s *\\($\\|%\\)")
+ ;; Line ends with parenthesis.
+ (erlang-indent-parenthesis (nth 2 stack-top)))
+ (t
+ ;; Indent to the same column as the first
+ ;; argument.
+ (goto-char (1+ (nth 1 stack-top)))
+ (skip-chars-forward " \t")
+ (current-column)))))
+ (erlang-indent-standard indent-point token base 't)))))
;;
((eq (car stack-top) '<<)
;; Element of binary (possible comprehension) expression,
@@ -4047,33 +4048,8 @@ Return nil if inside string, t if in a comment."
0))
base)) ;; old catch
(t
- ;; Look at last thing to see how we are to move relative
- ;; to the base.
- (goto-char token)
- (cond ((looking-at "||\\|,\\|->")
- base)
- ((erlang-at-keyword)
- (+ (current-column) erlang-indent-level))
- ((or (= (char-syntax (following-char)) ?.)
- (erlang-at-operator))
- (+ base erlang-indent-level))
- (t
- (goto-char indent-point)
- (cond ((memq (following-char) '(?\( ?{))
- ;; Function application or record.
- (+ (erlang-indent-find-preceding-expr)
- erlang-argument-indent))
- ;; Empty line, or end; treat it as the end of
- ;; the block. (Here we have a choice: should
- ;; the user be forced to reindent continued
- ;; lines, or should the "end" be reindented?)
-
- ;; Avoid treating comments a continued line.
- ((= (following-char) ?%)
- base)
- ;; Continued line (e.g. line beginning
- ;; with an operator.)
- (t (+ base erlang-indent-level)))))))))
+ (erlang-indent-standard indent-point token base 'nil)
+ ))))
))
((eq (car stack-top) 'when)
(goto-char (nth 1 stack-top))
@@ -4120,9 +4096,40 @@ Return nil if inside string, t if in a comment."
;; argument.
(goto-char (+ 2 (nth 1 stack-top)))
(skip-chars-forward " \t")
- (current-column))) start-alternativ)))))
+ (current-column))) start-alternativ)))))
)))
+(defun erlang-indent-standard (indent-point token base inside-parenthesis)
+ "Standard indent when in blocks or tuple or arguments.
+ Look at last thing to see in what state we are, move relative to the base."
+ (goto-char token)
+ (cond ((looking-at "||\\|,\\|->\\||")
+ base)
+ ((erlang-at-keyword)
+ (+ (current-column) erlang-indent-level))
+ ((or (= (char-syntax (following-char)) ?.)
+ (erlang-at-operator))
+ (+ base erlang-indent-level))
+ (t
+ (goto-char indent-point)
+ (cond ((memq (following-char) '(?\( ?{))
+ ;; Function application or record.
+ (+ (erlang-indent-find-preceding-expr)
+ erlang-argument-indent))
+ ;; Empty line, or end; treat it as the end of
+ ;; the block. (Here we have a choice: should
+ ;; the user be forced to reindent continued
+ ;; lines, or should the "end" be reindented?)
+
+ ;; Avoid treating comments a continued line.
+ ((= (following-char) ?%)
+ base)
+ ;; Continued line (e.g. line beginning
+ ;; with an operator.)
+ (t
+ (if (or (erlang-at-operator) (not inside-parenthesis))
+ (+ base erlang-indent-level)
+ base))))))
(defun erlang-indent-find-base (stack indent-point &optional offset skip)
"Find the base column for current stack."
diff --git a/lib/tools/emacs/test.erl.indented b/lib/tools/emacs/test.erl.indented
index 1a6292d90b..1ccced9177 100644
--- a/lib/tools/emacs/test.erl.indented
+++ b/lib/tools/emacs/test.erl.indented
@@ -44,6 +44,24 @@
b
}).
+-record(record3, {a = 8#42423 bor
+ 8#4234,
+ b = 8#5432
+ bor 2#1010101
+ c = 123 +
+ 234,
+ d}).
+
+-record(record4, {
+ a = 8#42423 bor
+ 8#4234,
+ b = 8#5432
+ bor 2#1010101
+ c = 123 +
+ 234,
+ d}).
+
+
-define(MACRO_1, macro).
-define(MACRO_2(_), macro).
@@ -91,7 +109,7 @@
fun((nonempty_maybe_improper_list('integer', any())|
1|2|3|a|b|<<_:3,_:_*14>>|integer()) ->
nonempty_maybe_improper_list('integer', any())|
- 1|2|3|a|b|<<_:3,_:_*14>>|integer()).
+ 1|2|3|a|b|<<_:3,_:_*14>>|integer()).
-type t20() :: [t19(), ...].
-type t21() :: tuple().
-type t21(A) :: A.
@@ -121,12 +139,18 @@
-spec handle_cast(Cast :: {'exchange', node(), [[name(),...]]}
| {'del_member', name(), pid()},
- #state{}) -> {'noreply', #state{}}.
+ #state{}) -> {'noreply', #state{}}.
-spec handle_cast(Cast ::
{'exchange', node(), [[name(),...]]}
| {'del_member', name(), pid()},
- #state{}) -> {'noreply', #state{}}.
+ #state{}) -> {'noreply', #state{}}.
+
+
+-spec get_closest_pid(term()) ->
+ Return :: pid()
+ | {'error', {'no_process', term()}
+ | {'no_such_group', term()}}.
-opaque attributes_data() ::
[{'column', column()} | {'line', info_line()} |
@@ -294,7 +318,10 @@ indent_basics(X, Y, Z)
c
),
-
+ call(2#42423 bor
+ #4234,
+ 2#5432,
+ other_arg),
ok;
indent_basics(Xlongname,
#struct{a=Foo,
@@ -508,7 +535,7 @@ indent_catch() ->
B = catch oskar(X),
A = catch (baz +
- bax),
+ bax),
catch foo(),
C = catch B +
diff --git a/lib/tools/emacs/test.erl.orig b/lib/tools/emacs/test.erl.orig
index 499961cbb1..9b4203120b 100644
--- a/lib/tools/emacs/test.erl.orig
+++ b/lib/tools/emacs/test.erl.orig
@@ -44,6 +44,24 @@
b
}).
+-record(record3, {a = 8#42423 bor
+ 8#4234,
+ b = 8#5432
+ bor 2#1010101
+ c = 123 +
+234,
+ d}).
+
+-record(record4, {
+ a = 8#42423 bor
+ 8#4234,
+ b = 8#5432
+ bor 2#1010101
+ c = 123 +
+ 234,
+ d}).
+
+
-define(MACRO_1, macro).
-define(MACRO_2(_), macro).
@@ -120,13 +138,19 @@ t15(),t20(),t21(), t22(),t25()}.
-spec mod:t2() -> any().
-spec handle_cast(Cast :: {'exchange', node(), [[name(),...]]}
- | {'del_member', name(), pid()},
- #state{}) -> {'noreply', #state{}}.
+ | {'del_member', name(), pid()},
+ #state{}) -> {'noreply', #state{}}.
-spec handle_cast(Cast ::
- {'exchange', node(), [[name(),...]]}
- | {'del_member', name(), pid()},
- #state{}) -> {'noreply', #state{}}.
+ {'exchange', node(), [[name(),...]]}
+ | {'del_member', name(), pid()},
+ #state{}) -> {'noreply', #state{}}.
+
+
+-spec get_closest_pid(term()) ->
+ Return :: pid()
+ | {'error', {'no_process', term()}
+ | {'no_such_group', term()}}.
-opaque attributes_data() ::
[{'column', column()} | {'line', info_line()} |
@@ -294,7 +318,10 @@ Y =:= 4711 ->
c
),
-
+ call(2#42423 bor
+ #4234,
+ 2#5432,
+ other_arg),
ok;
indent_basics(Xlongname,
#struct{a=Foo,