@@ -547,6 +547,16 @@ autofill-mode."
547547 (" {" . (lambda () (purescript-indentation-list #'purescript-indentation-expression
548548 " }" " ," nil )))))
549549
550+ (defun purescript-indentation-qualified-do-p (token )
551+ (and (stringp token)
552+ (string-match-p " \\ .do\\ '" token)))
553+
554+ (defun purescript-indentation-find-expression-parser (token )
555+ " Find the entry for TOKEN in `purescript-indentation-expression-list' ."
556+ (or (assoc token purescript-indentation-expression-list)
557+ (when (purescript-indentation-qualified-do-p token)
558+ (assoc " do" purescript-indentation-expression-list))))
559+
550560(defun purescript-indentation-expression-layout ()
551561 (purescript-indentation-layout #'purescript-indentation-expression ))
552562
@@ -769,7 +779,7 @@ autofill-mode."
769779 current-indent)))
770780 (throw 'return nil ))
771781
772- (t (let ((parser (assoc current-token purescript-indentation-expression-list )))
782+ (t (let ((parser (purescript-indentation-find- expression-parser current-token )))
773783 (when (null parser)
774784 (throw 'return nil ))
775785 (funcall (cdr parser))
@@ -967,7 +977,7 @@ autofill-mode."
967977
968978(defun purescript-indentation-peek-token ()
969979 " Return token starting at point."
970- (cond ((looking-at " \\ (if\\ |then\\ |else\\ |let\\ |in\\ |mdo\\ |rec\\ |do\\ |proc\\ |case\\ |of\\ |where\\ |module\\ |deriving\\ |data\\ |type\\ |newtype\\ |class\\ |instance\\ )\\ ([^[:alnum:]'_]\\ |$\\ )" )
980+ (cond ((looking-at " \\ (if\\ |then\\ |else\\ |let\\ |in\\ |mdo\\ |rec\\ |\\ (?:[[:word:]]+ \\ . \\ )* do\\ |proc\\ |case\\ |of\\ |where\\ |module\\ |deriving\\ |data\\ |type\\ |newtype\\ |class\\ |instance\\ )\\ ([^[:alnum:]'_]\\ |$\\ )" )
971981 (match-string-no-properties 1 ))
972982 ((looking-at " [][(){}[,;]" )
973983 (match-string-no-properties 0 ))
0 commit comments