From 1f32cb47e3d6f8f93228f6d42a91fc483e03b57f Mon Sep 17 00:00:00 2001 From: Magnus Henoch Date: Tue, 18 May 2010 23:38:26 +0100 Subject: Fix indentation of records with line breaks inside lists Trying to indent this piece of code by hitting TAB on each line: foo() -> [#foo{ foo = foo}]. used to cause an error. Fix by ignoring errors when trying to skip backwards from a record. Also add this test case to test.erl.orig and test.erl.indented. --- lib/tools/emacs/erlang.el | 14 ++++++++++---- lib/tools/emacs/test.erl.indented | 5 +++++ lib/tools/emacs/test.erl.orig | 5 +++++ 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/tools') diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index 0132587d28..d14b028ae6 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -2933,10 +2933,16 @@ This assumes that the preceding expression is either simple (skip-chars-backward " \t") ;; Needed to match the colon in "'foo':'bar'". (if (not (memq (preceding-char) '(?# ?:))) - col - (backward-char 1) - (forward-sexp -1) - (current-column))))) + col + ;; Special hack to handle: (note line break) + ;; [#myrecord{ + ;; foo = foo}] + (or + (ignore-errors + (backward-char 1) + (forward-sexp -1) + (current-column)) + col))))) (defun erlang-indent-parenthesis (stack-position) (let ((previous (erlang-indent-find-preceding-expr))) diff --git a/lib/tools/emacs/test.erl.indented b/lib/tools/emacs/test.erl.indented index d0ea4c29cf..1dc976d8dc 100644 --- a/lib/tools/emacs/test.erl.indented +++ b/lib/tools/emacs/test.erl.indented @@ -588,3 +588,8 @@ indent_comprehensions() -> true = (X rem 2) >>, ok. + +%% This causes an error in earlier erlang-mode versions. +foo() -> + [#foo{ + foo = foo}]. diff --git a/lib/tools/emacs/test.erl.orig b/lib/tools/emacs/test.erl.orig index 70e97a2e91..feb9e4e5a1 100644 --- a/lib/tools/emacs/test.erl.orig +++ b/lib/tools/emacs/test.erl.orig @@ -588,3 +588,8 @@ Binary2 = << <> || <> <= <<0:512>>, true = (X rem 2) >>, ok. + +%% This causes an error in earlier erlang-mode versions. +foo() -> +[#foo{ +foo = foo}]. -- cgit v1.2.3