Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskell-indentation-mode layout tops braces #712

Closed
arybczak opened this issue Jun 10, 2015 · 7 comments
Closed

haskell-indentation-mode layout tops braces #712

arybczak opened this issue Jun 10, 2015 · 7 comments

Comments

@arybczak
Copy link

Consider the following code:

module Main where

data Foo = Foo {
  bar :: Int
, baz :: Int
} deriving Show

main :: IO ()
main = do
  let foo = Foo {
        bar = 0
      , baz = 0
      }
  putStrLn $ show foo

After you go to the line with "baz = 0" and press Enter, Emacs displays "Illegal token: layout-item" in statusbar and indentation no longer works after this point.

@gracjan
Copy link
Contributor

gracjan commented Jun 10, 2015

Hmm, github version seems to be working. Likewise melpa version should also work. I haven't checked melpa-stable.

@arybczak
Copy link
Author

Hmm, this is weird, I get this with master.

@arybczak
Copy link
Author

I have emacs 24.5, it happens with .emacs.d/init.el containing only

;; enable haskell-mode
(defconst haskell-mode-directory "~/.emacs.d/haskell-mode/")
(add-to-list 'load-path haskell-mode-directory)
(require 'haskell-mode-autoloads)
(add-to-list 'Info-default-directory-list haskell-mode-directory)

(add-hook 'haskell-mode-hook 'haskell-indentation-mode)

and .emacs.d/haskell-mode having haskell-mode from master.

@gracjan
Copy link
Contributor

gracjan commented Jun 11, 2015

How about rm *.elc ?

@arybczak
Copy link
Author

This is with clean, just cloned and compiled repository :(

@arybczak
Copy link
Author

Added tests do not replicate the issue I posted.

Here's the patch to correctly reflect it:

diff --git a/tests/haskell-indentation-tests.el b/tests/haskell-indentation-tests.el
index 85e1150..aa36fdb 100644
--- a/tests/haskell-indentation-tests.el
+++ b/tests/haskell-indentation-tests.el
@@ -410,8 +410,9 @@ Example of lines:
    "main = do"
    "let foo = Foo {"
    "      bar = 0"
-   "      , baz = 0"
-   "      ^"))
+   "    , baz = 0"
+   "    }"
+   "    ^"))

 (ert-deftest haskell-indentation-check-instance-21a-unicode ()
   "layout versus comma in braces (unicode)"
@@ -420,5 +421,6 @@ Example of lines:
    "main = do"
    "let foo = Foo {"
    "      bar = 0"
-   "      , baz = 0"
-   "      ^"))
+   "    , baz = 0"
+   "    }"
+   "    ^"))

and it indeed fails with "Illegal token: layout-item".

@gracjan
Copy link
Contributor

gracjan commented Jun 16, 2015

Confirmed.

Braces and commas should take priority over layout-item, haskell-indentation does it opposite to what Haskell Report says.

@gracjan gracjan changed the title haskell-indentation-mode breaks at certain layout haskell-indentation-mode layout tops braces Jun 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants