@@ -507,7 +507,8 @@ indentation points to the right, we switch going to the left."
507507 `((" module" . haskell-indentation-module)
508508 (" data" . haskell-indentation-data)
509509 (" type" . haskell-indentation-data)
510- (" newtype" . haskell-indentation-data)
510+ (" newtype" . haskell-indentation-data)
511+ (" import" . haskell-indentation-import)
511512 (" class" . haskell-indentation-class-declaration)
512513 (" instance" . haskell-indentation-class-declaration))
513514 " Alist of toplevel keywords with associated parsers." )
@@ -677,6 +678,10 @@ For example
677678 (haskell-indentation-with-starter
678679 #'haskell-indentation-expression-layout nil ))))))
679680
681+ (defun haskell-indentation-import ()
682+ " Parse import declaration."
683+ (haskell-indentation-with-starter #'haskell-indentation-expression ))
684+
680685(defun haskell-indentation-class-declaration ()
681686 " Parse class declaration."
682687 (haskell-indentation-with-starter
@@ -946,7 +951,9 @@ layout starts."
946951 (haskell-indentation-read-next-token))
947952 ((eq current-token 'end-tokens )
948953 (when (or (haskell-indentation-expression-token-p following-token)
949- (string= following-token " ;" ))
954+ (string= following-token " ;" )
955+ (and (equal layout-indent 0 )
956+ (member following-token (mapcar #'car haskell-indentation-toplevel-list))))
950957 (haskell-indentation-add-layout-indent))
951958 (throw 'return nil ))
952959 (t (throw 'return nil ))))))
@@ -1132,7 +1139,7 @@ line."
11321139
11331140(defun haskell-indentation-peek-token ()
11341141 " Return token starting at point."
1135- (cond ((looking-at " \\ (if\\ |then\\ |else\\ |let\\ |in\\ |mdo\\ |rec\\ |do\\ |proc\\ |case\\ |of\\ |where\\ |module\\ |deriving\\ |data\\ |type\\ |newtype\\ |class\\ |instance\\ )\\ ([^[:alnum:]'_]\\ |$\\ )" )
1142+ (cond ((looking-at " \\ (if\\ |then\\ |else\\ |let\\ |in\\ |mdo\\ |rec\\ |do\\ |proc\\ |case\\ |of\\ |where\\ |module\\ |deriving\\ |import \\ | data\\ |type\\ |newtype\\ |class\\ |instance\\ )\\ ([^[:alnum:]'_]\\ |$\\ )" )
11361143 (match-string-no-properties 1 ))
11371144 ((looking-at " [][(){}[,;]" )
11381145 (match-string-no-properties 0 ))
0 commit comments