@@ -493,6 +493,7 @@ fixes up only indentation."
493
493
(" type" . haskell-indentation-data)
494
494
(" newtype" . haskell-indentation-data)
495
495
(" import" . haskell-indentation-import)
496
+ (" where" . haskell-indentation-toplevel-where)
496
497
(" class" . haskell-indentation-class-declaration)
497
498
(" instance" . haskell-indentation-class-declaration)
498
499
(" deriving" . haskell-indentation-deriving))
@@ -732,21 +733,32 @@ For example
732
733
" Parse module declaration."
733
734
(haskell-indentation-with-starter
734
735
(lambda ()
735
- (let ((current-indent (current-column )))
736
- (haskell-indentation-read-next-token)
737
- (when (string= current-token " (" )
738
- (haskell-indentation-list
739
- #'haskell-indentation-module-export
740
- " )" " ," ))
741
- (when (eq current-token 'end-tokens )
742
- (haskell-indentation-add-indentation current-indent)
743
- (throw 'parse-end nil ))
744
- (when (string= current-token " where" )
736
+ (haskell-indentation-read-next-token)
737
+ (when (string= current-token " (" )
738
+ (haskell-indentation-list
739
+ #'haskell-indentation-module-export
740
+ " )" " ," ))
741
+ (if (string= current-token " where" )
745
742
(haskell-indentation-read-next-token)
746
- (when (eq current-token 'end-tokens )
747
- (haskell-indentation-add-layout-indent)
743
+
744
+ (when (eq current-token 'end-tokens )
745
+ (when (member following-token '(value no-following-token " (" ))
746
+ (haskell-indentation-add-indentation
747
+ (+ starter-indent haskell-indentation-starter-offset))
748
+ (haskell-indentation-add-indentation
749
+ (+ left-indent haskell-indentation-starter-offset))
748
750
(throw 'parse-end nil ))
749
- (haskell-indentation-layout #'haskell-indentation-toplevel ))))))
751
+ (haskell-indentation-add-layout-indent)
752
+ (throw 'parse-end nil ))))))
753
+
754
+ (defun haskell-indentation-toplevel-where ()
755
+ " Parse 'where' that we may hit as a standalone in module
756
+ declaration."
757
+ (haskell-indentation-read-next-token)
758
+
759
+ (when (eq current-token 'end-tokens )
760
+ (haskell-indentation-add-layout-indent)
761
+ (throw 'parse-end nil )))
750
762
751
763
(defun haskell-indentation-module-export ()
752
764
" Parse export list."
@@ -986,7 +998,8 @@ layout starts."
986
998
(haskell-indentation-expression-token-p following-token))
987
999
(string= following-token " ;" )
988
1000
(and (equal layout-indent 0 )
989
- (member following-token (mapcar #'car haskell-indentation-toplevel-list))))
1001
+ (member following-token (mapcar #'car haskell-indentation-toplevel-list))
1002
+ (not (string= following-token " where" ))))
990
1003
(haskell-indentation-add-layout-indent))
991
1004
(throw 'return nil ))
992
1005
(t (throw 'return nil ))))))
0 commit comments