diff options
-rw-r--r-- | lib/tools/emacs/erlang.el | 20 | ||||
-rw-r--r-- | lib/tools/test/emacs_SUITE_data/funcs | 16 | ||||
-rw-r--r-- | lib/tools/test/emacs_SUITE_data/records | 21 | ||||
-rw-r--r-- | lib/tools/test/emacs_SUITE_data/terms | 31 |
4 files changed, 45 insertions, 43 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index 411e0e13df..e29d3e0482 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -2745,7 +2745,7 @@ Return nil if inside string, t if in a comment." (1+ (nth 2 stack-top))) ((= (char-syntax (following-char)) ?\)) (goto-char (nth 1 stack-top)) - (cond ((looking-at "[({]\\s *\\($\\|%\\)") + (cond ((erlang-record-or-function-args-p) ;; Line ends with parenthesis. (let ((previous (erlang-indent-find-preceding-expr)) (stack-pos (nth 2 stack-top))) @@ -2758,7 +2758,7 @@ Return nil if inside string, t if in a comment." (nth 2 stack-top)) (t (goto-char (nth 1 stack-top)) - (let ((base (cond ((looking-at "[({]\\s *\\($\\|%\\)") + (let ((base (cond ((erlang-record-or-function-args-p) ;; Line ends with parenthesis. (erlang-indent-parenthesis (nth 2 stack-top))) (t @@ -3031,11 +3031,21 @@ This assumes that the preceding expression is either simple (t col))) col)))) +(defun erlang-record-or-function-args-p () + (and (looking-at "[({]\\s *\\($\\|%\\)") + (or (eq (following-char) ?\( ) + (save-excursion + (ignore-errors (forward-sexp (- 1))) + (eq (preceding-char) ?#))))) + (defun erlang-indent-parenthesis (stack-position) (let ((previous (erlang-indent-find-preceding-expr))) - (if (> previous stack-position) - (+ stack-position erlang-argument-indent) - (+ previous erlang-argument-indent)))) + (cond ((eq previous stack-position) ;; tuple or map not a record + (1+ stack-position)) + ((> previous stack-position) + (+ stack-position erlang-argument-indent)) + (t + (+ previous erlang-argument-indent))))) (defun erlang-skip-blank (&optional lim) "Skip over whitespace and comments until limit reached." diff --git a/lib/tools/test/emacs_SUITE_data/funcs b/lib/tools/test/emacs_SUITE_data/funcs index 2ad9d73262..b0c9716f0e 100644 --- a/lib/tools/test/emacs_SUITE_data/funcs +++ b/lib/tools/test/emacs_SUITE_data/funcs @@ -79,20 +79,20 @@ match1({[H|T], match2( { - [H|T], - Other + [H|T], + Other }, M2A2 ) -> ok. match3({ - M3A1, - [ - H | - T - ], - Other + M3A1, + [ + H | + T + ], + Other }, M3A2 ) -> diff --git a/lib/tools/test/emacs_SUITE_data/records b/lib/tools/test/emacs_SUITE_data/records index 545cfb15c5..241582718c 100644 --- a/lib/tools/test/emacs_SUITE_data/records +++ b/lib/tools/test/emacs_SUITE_data/records @@ -5,9 +5,9 @@ -record(record0, { - r0a, - r0b, - r0c + r0a, + r0b, + r0c }). -record(record1, {r1a, @@ -16,9 +16,9 @@ }). -record(record2, { - r2a, - r2b - }). + r2a, + r2b + }). -record(record3, {r3a = 8#42423 bor 8#4234, @@ -28,15 +28,6 @@ 234, r3d}). --record(record4, { - r4a = 8#42423 bor - 8#4234, - r4b = 8#5432 - bor 2#1010101 - r4c = 123 + - 234, - r4d}). - -record(record5, { r5a = 1 :: integer() , r5b = foobar :: atom() diff --git a/lib/tools/test/emacs_SUITE_data/terms b/lib/tools/test/emacs_SUITE_data/terms index 8bc95f2bc2..02b2d665fd 100644 --- a/lib/tools/test/emacs_SUITE_data/terms +++ b/lib/tools/test/emacs_SUITE_data/terms @@ -39,8 +39,8 @@ tuple(2) -> }; tuple(3) -> { - a, - b,c + a, + b,c }; tuple(4) -> { a @@ -68,22 +68,23 @@ binary(4) -> >>. record(1) -> - #rec{a=1, - b=2 - }; + #record{a=1, + b=2 + }; record(2) -> - #rec{ a=1, - b=2 - }; + #record{ a=1, + b=2 + }; record(3) -> - #rec{ + #record{ a=1, b=2 }; record(4) -> - #rec{a=1 - ,b=2 - }. + #record{ + a=1 + ,b=2 + }. map(1) -> #{a=>1, @@ -95,9 +96,9 @@ map(2) -> }; map(3) -> #{ - a=>1, - b=>2 - }; + a=>1, + b=>2 + }; map(4) -> #{ a => <<"a">> |