49
49
:group 'haskell
50
50
:prefix " haskell-indentation-" )
51
51
52
- (defcustom haskell-indentation-indent-leftmost t
53
- " Indent to the left margin after certain keywords.
54
- For example after \" let .. in\" , \" case .. of\" ). If set to t it
55
- will only indent to the left. If nil only relative to the
56
- containing expression. If set to the symbol 'both then both
57
- positions are allowed."
58
- :type 'symbol
59
- :group 'haskell-indentation )
60
-
61
52
(defcustom haskell-indentation-layout-offset 2
62
53
" Extra indentation to add before expressions in a Haskell layout list."
63
54
:type 'integer
@@ -73,11 +64,6 @@ positions are allowed."
73
64
:type 'integer
74
65
:group 'haskell-indentation )
75
66
76
- (defcustom haskell-indentation-ifte-offset 2
77
- " Extra indentation after the keywords \" if\" , \" then\" , or \" else\" ."
78
- :type 'integer
79
- :group 'haskell-indentation )
80
-
81
67
(defcustom haskell-indentation-where-pre-offset 2
82
68
" Extra indentation before the keyword \" where\" ."
83
69
:type 'integer
@@ -520,7 +506,6 @@ fixes up only indentation."
520
506
(" type" . haskell-indentation-data)
521
507
(" newtype" . haskell-indentation-data)
522
508
(" if" . haskell-indentation-if)
523
- (" case" . haskell-indentation-case)
524
509
(" let" .
525
510
,(apply-partially 'haskell-indentation-phrase
526
511
'(haskell-indentation-declaration-layout
@@ -534,6 +519,10 @@ fixes up only indentation."
534
519
(" rec" .
535
520
,(apply-partially 'haskell-indentation-with-starter
536
521
'haskell-indentation-expression-layout ))
522
+ (" case" .
523
+ ,(apply-partially 'haskell-indentation-phrase
524
+ '(haskell-indentation-expression
525
+ " of" haskell-indentation-case-layout)))
537
526
(" \\ " .
538
527
,(apply-partially 'haskell-indentation-with-starter
539
528
'haskell-indentation-lambda-maybe-lambdacase ))
@@ -574,7 +563,7 @@ fixes up only indentation."
574
563
575
564
(defun haskell-indentation-case-layout ()
576
565
" Parse layout list with case expressions."
577
- (haskell-indentation-layout #'haskell-indentation-case-item ))
566
+ (haskell-indentation-layout #'haskell-indentation-case ))
578
567
579
568
(defun haskell-indentation-lambda-maybe-lambdacase ()
580
569
" Parse lambda or lambda-case expression.
@@ -821,7 +810,7 @@ Skip the keyword or parenthesis." ; FIXME: better description needed
821
810
((equal current-token end)
822
811
(haskell-indentation-read-next-token))))))
823
812
824
- (defun haskell-indentation-case-item- alternative ()
813
+ (defun haskell-indentation-case-alternative ()
825
814
" " ; FIXME
826
815
(setq left-indent (current-column ))
827
816
(haskell-indentation-separated #'haskell-indentation-expression " ," nil )
@@ -832,15 +821,15 @@ Skip the keyword or parenthesis." ; FIXME: better description needed
832
821
; ; otherwise fallthrough
833
822
))
834
823
835
- (defun haskell-indentation-case-item ()
824
+ (defun haskell-indentation-case ()
836
825
" " ; FIXME
837
826
(haskell-indentation-expression)
838
827
(cond ((eq current-token 'end-tokens )
839
828
(haskell-indentation-add-indentation current-indent))
840
829
((string= current-token " |" )
841
830
(haskell-indentation-with-starter
842
831
(apply-partially #'haskell-indentation-separated
843
- #'haskell-indentation-case-item- alternative " |" nil )
832
+ #'haskell-indentation-case-alternative " |" nil )
844
833
nil ))
845
834
((string= current-token " ->" )
846
835
(haskell-indentation-statement-right #'haskell-indentation-expression ))
@@ -1018,24 +1007,14 @@ layout starts."
1018
1007
(haskell-indentation-with-starter
1019
1008
(lambda ()
1020
1009
(haskell-indentation-separated
1021
- #'haskell-indentation-case-item- alternative " |" nil ))
1010
+ #'haskell-indentation-case-alternative " |" nil ))
1022
1011
nil )
1023
1012
(haskell-indentation-phrase-rest
1024
1013
'(haskell-indentation-expression
1025
1014
" then" haskell-indentation-expression
1026
1015
" else" haskell-indentation-expression))))
1027
1016
nil ))
1028
1017
1029
- (defun haskell-indentation-case ()
1030
- " " ; FIXME
1031
- (haskell-indentation-with-starter
1032
- (lambda ()
1033
- (haskell-indentation-expression)
1034
- (when (string= current-token " of" )
1035
- (haskell-indentation-with-starter
1036
- #'haskell-indentation-case-layout )))
1037
- nil ))
1038
-
1039
1018
(defun haskell-indentation-phrase (phrase )
1040
1019
" " ; FIXME
1041
1020
(haskell-indentation-with-starter
@@ -1063,41 +1042,14 @@ layout starts."
1063
1042
(t (throw 'parse-end nil ))))
1064
1043
((null (cdr phrase)))
1065
1044
((equal (cadr phrase) current-token)
1066
- (let* ((on-new-line (= (current-column )
1067
- (haskell-indentation-current-indentation)))
1068
- (lines-between (- parse-line-number starter-line))
1069
- (left-indent (if (<= lines-between 0 )
1070
- left-indent
1071
- starter-indent)))
1072
- (haskell-indentation-read-next-token)
1073
- (when (eq current-token 'end-tokens )
1074
- (cond ((member (cadr phrase) '(" then" " else" ))
1075
- (haskell-indentation-add-indentation
1076
- (+ starter-indent haskell-indentation-ifte-offset)))
1077
-
1078
- ((member (cadr phrase) '(" in" " ->" ))
1079
- ; ; expression ending in another expression
1080
- (when (or (not haskell-indentation-indent-leftmost)
1081
- (eq haskell-indentation-indent-leftmost 'both ))
1082
- (haskell-indentation-add-indentation
1083
- (+ starter-indent haskell-indentation-starter-offset)))
1084
- (when haskell-indentation-indent-leftmost
1085
- (haskell-indentation-add-indentation
1086
- (if on-new-line
1087
- (+ left-indent haskell-indentation-starter-offset)
1088
- left-indent))))
1089
- (t
1090
- (when (or (not haskell-indentation-indent-leftmost)
1091
- (eq haskell-indentation-indent-leftmost 'both ))
1092
- (haskell-indentation-add-indentation
1093
- (+ starter-indent haskell-indentation-starter-offset)))
1094
- (when haskell-indentation-indent-leftmost
1095
- (haskell-indentation-add-indentation
1096
- (if on-new-line
1097
- (+ left-indent haskell-indentation-starter-offset)
1098
- left-indent)))))
1099
- (throw 'parse-end nil ))
1100
- (setq phrase1 (cddr phrase))))
1045
+ (haskell-indentation-read-next-token)
1046
+ (when (eq current-token 'end-tokens )
1047
+ (haskell-indentation-add-indentation
1048
+ (+ starter-indent haskell-indentation-starter-offset))
1049
+ (haskell-indentation-add-indentation
1050
+ (+ left-indent haskell-indentation-starter-offset))
1051
+ (throw 'parse-end nil ))
1052
+ (setq phrase1 (cddr phrase)))
1101
1053
((string= (cadr phrase) " in" ))))))
1102
1054
1103
1055
(defun haskell-indentation-add-indentation (indent )
0 commit comments