From 9a6fa5073ac505c41f085d492f39e8ff415a7d13 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Fri, 4 Sep 2015 13:00:46 +0200 Subject: [PATCH 1/2] Disable implicit rule only outside of parentheses --- haskell-indentation.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/haskell-indentation.el b/haskell-indentation.el index 7a2837ddd..2029cd51a 100644 --- a/haskell-indentation.el +++ b/haskell-indentation.el @@ -894,11 +894,14 @@ After a lambda (backslash) there are two possible cases: "Parse a list, pair or other expression containing multiple items parsed by PARSER, separated by SEP or STMT-SEP, and ending with END." - (let (implicit-layout-active) - (haskell-indentation-with-starter - (apply-partially #'haskell-indentation-separated - parser sep stmt-sep) - end))) + ;; note that we use macro expansion here to preserver Emacs 23 + ;; compatibility and its lack of lexical binding + (haskell-indentation-with-starter + `(lambda () + (let ((implicit-layout-active nil)) + (haskell-indentation-separated + #',parser ,sep ,stmt-sep))) + end)) (defun haskell-indentation-with-starter (parser &optional end where-expr?) "Parse an expression starting with a keyword or parenthesis. From c7f28efdef2445d88bd13666b620a1c4a9d1ea9d Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Fri, 4 Sep 2015 13:01:12 +0200 Subject: [PATCH 2/2] Add tests for implicit layout rule and parentheses interaction --- tests/haskell-indentation-tests.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/haskell-indentation-tests.el b/tests/haskell-indentation-tests.el index 7e376fe60..ecdbd09f2 100644 --- a/tests/haskell-indentation-tests.el +++ b/tests/haskell-indentation-tests.el @@ -506,4 +506,16 @@ let foo = Foo { ((5 0) 12) ((6 0) 12)) +(hindent-test "22 should obey layout only outside parentheses" " +func = 1234 + where + foo :: Ivory eff () + foo = do + return ()" + ((1 0) 0) + ((2 0) 2) + ((3 0) 4) + ((4 0) 0 4 11) + ((5 0) 6)) + ;;; haskell-indentation-tests.el ends here