diff options
author | Dániel Szoboszlay <[email protected]> | 2016-05-13 23:05:23 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2016-05-18 10:12:49 +0200 |
commit | c8b3e3a977bd8b4071e190c7c7aaa72f934af60a (patch) | |
tree | 2e457633d8e50bf20a18b957dacd0932bb6f1950 /lib/tools/emacs | |
parent | 4fba4b14c4f9aa03294d8d187fe0dd1202744e82 (diff) | |
download | otp-c8b3e3a977bd8b4071e190c7c7aaa72f934af60a.tar.gz otp-c8b3e3a977bd8b4071e190c7c7aaa72f934af60a.tar.bz2 otp-c8b3e3a977bd8b4071e190c7c7aaa72f934af60a.zip |
Fix line-initial commas' indentation in type specs
Inside type specs, line-initial commas shall align with open curly
braces. This also applies to record definitions with type specs for
the fields.
For example:
-type foo() :: { a :: integer()
, b :: integer()
}.
For type specs for functions, the commas shall align with the opening
parenthese. So do a closing parenthese when put on a new line.
For example:
-spec foo( X :: integer()
, Y :: integer()
) -> integer().
This does not affect coding styles that don't put commas at the
beginning of lines.
Diffstat (limited to 'lib/tools/emacs')
-rw-r--r-- | lib/tools/emacs/erlang.el | 5 | ||||
-rw-r--r-- | lib/tools/emacs/test.erl.indented | 13 | ||||
-rw-r--r-- | lib/tools/emacs/test.erl.orig | 13 |
3 files changed, 29 insertions, 2 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index 0a3fc0ddff..4f656e3ae4 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -2970,8 +2970,9 @@ Return nil if inside string, t if in a comment." (current-column))) ;; Type and Spec indentation ((eq (car stack-top) '::) - (if (looking-at "}") - ;; Closing record definition with types + (if (looking-at "[},)]") + ;; Closing function spec, record definition with types, + ;; or a comma at the start of the line ;; pop stack and recurse (erlang-calculate-stack-indent indent-point (cons (erlang-pop stack) (cdr state))) diff --git a/lib/tools/emacs/test.erl.indented b/lib/tools/emacs/test.erl.indented index 6913068133..7a1ff6a954 100644 --- a/lib/tools/emacs/test.erl.indented +++ b/lib/tools/emacs/test.erl.indented @@ -70,6 +70,9 @@ foo() -> 234, d}). +-record(record5, { a = 1 :: integer() + , b = foobar :: atom() + }). -define(MACRO_1, macro). -define(MACRO_2(_), macro). @@ -144,6 +147,12 @@ foo() -> -type t25() :: #rec3{f123 :: [t24() | 1|2|3|4|a|b|c|d| nonempty_maybe_improper_list(integer, any())]}. +-type t26() :: #rec4{ a :: integer() + , b :: any() + }. +-type t27() :: { integer() + , atom() + }. -type t99() :: {t2(),t4(),t5(),t6(),t7(),t8(),t10(),t14(), t15(),t20(),t21(), t22(),t25()}. @@ -179,6 +188,10 @@ foo() -> | {'error', {'no_process', term()} | {'no_such_group', term()}}. +-spec add( X :: integer() + , Y :: integer() + ) -> integer(). + -opaque attributes_data() :: [{'column', column()} | {'line', info_line()} | {'text', string()}] | {line(),column()}. diff --git a/lib/tools/emacs/test.erl.orig b/lib/tools/emacs/test.erl.orig index 621948cbe1..2552c71baf 100644 --- a/lib/tools/emacs/test.erl.orig +++ b/lib/tools/emacs/test.erl.orig @@ -70,6 +70,9 @@ foo() -> 234, d}). +-record(record5, { a = 1 :: integer() +, b = foobar :: atom() +}). -define(MACRO_1, macro). -define(MACRO_2(_), macro). @@ -144,6 +147,12 @@ nonempty_maybe_improper_list('integer', any())| -type t25() :: #rec3{f123 :: [t24() | 1|2|3|4|a|b|c|d| nonempty_maybe_improper_list(integer, any())]}. +-type t26() :: #rec4{ a :: integer() +, b :: any() +}. +-type t27() :: { integer() +, atom() +}. -type t99() :: {t2(),t4(),t5(),t6(),t7(),t8(),t10(),t14(), t15(),t20(),t21(), t22(),t25()}. @@ -179,6 +188,10 @@ t15(),t20(),t21(), t22(),t25()}. | {'error', {'no_process', term()} | {'no_such_group', term()}}. +-spec add( X :: integer() +, Y :: integer() +) -> integer(). + -opaque attributes_data() :: [{'column', column()} | {'line', info_line()} | {'text', string()}] | {line(),column()}. |