From 4552947571356399f29346e7763eef4b1831eddb Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Fri, 1 Jan 2016 18:27:38 +0100 Subject: [PATCH 1/2] Record declarations should follow tibell style --- haskell-indentation.el | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/haskell-indentation.el b/haskell-indentation.el index 4e6d5581c..91888a551 100644 --- a/haskell-indentation.el +++ b/haskell-indentation.el @@ -646,18 +646,16 @@ For example (defun haskell-indentation-data () "Parse data or type declaration." - (haskell-indentation-with-starter - (lambda () - (when (string= current-token "instance") - (haskell-indentation-read-next-token)) - (haskell-indentation-type) - (cond ((string= current-token "=") - (haskell-indentation-with-starter - (apply-partially #'haskell-indentation-separated - #'haskell-indentation-type "|" "deriving"))) - ((string= current-token "where") - (haskell-indentation-with-starter - #'haskell-indentation-expression-layout nil)))))) + (haskell-indentation-read-next-token) + (when (string= current-token "instance") + (haskell-indentation-read-next-token)) + (haskell-indentation-type) + (cond ((string= current-token "=") + (haskell-indentation-separated + #'haskell-indentation-expression "|" "deriving")) + ((string= current-token "where") + (haskell-indentation-with-starter + #'haskell-indentation-expression-layout nil)))) (defun haskell-indentation-import () "Parse import declaration." @@ -927,7 +925,9 @@ layout starts." (cond ((member current-token '(layout-item ";")) (haskell-indentation-read-next-token)) ((eq current-token 'end-tokens) - (when (or (haskell-indentation-expression-token-p following-token) + (when (or (and + (not (string= following-token "{")) + (haskell-indentation-expression-token-p following-token)) (string= following-token ";") (and (equal layout-indent 0) (member following-token (mapcar #'car haskell-indentation-toplevel-list)))) From f0a0c87944f8b7bcc3bbf95e5158a54910e4e0a9 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Fri, 1 Jan 2016 18:29:16 +0100 Subject: [PATCH 2/2] Record declarations should follow tibell style (test) --- tests/haskell-indentation-tests.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/haskell-indentation-tests.el b/tests/haskell-indentation-tests.el index 289f7e276..6ba5857d4 100644 --- a/tests/haskell-indentation-tests.el +++ b/tests/haskell-indentation-tests.el @@ -135,7 +135,7 @@ macro quotes them for you." function = Record { field = 123 }" (1 0) - (2 0 2)) + (2 2)) (hindent-test "2 Handle underscore in identifiers"" function = do @@ -522,7 +522,7 @@ data Foo = Foo { (1 0) (2 2) (3 2) - (4 4 11)) + (4 11)) (hindent-test "21c* \"data\" declaration open on next line" " data Foo = Foo @@ -644,7 +644,7 @@ instance Bar Int (hindent-test "32 allow type operators" " data (:.) a b = a :. b " - (2 0 16)) + (2 0 2)) (hindent-test "33* parse #else in CPP" " #ifdef FLAG @@ -661,9 +661,7 @@ data T = T { } " - ;; set of answers isn't best but it is not a bug - ;; should be just 0 - (5 0 9)) + (5 0 2)) (hindent-test "35 baroque construct which causes parse error" " az = Projection