From 09327cb992ef8b0a7f4666c44353f6b069d38d68 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 9 Dec 2024 23:12:43 +0300 Subject: [PATCH 1/2] Remove "deriving" Haskell artifact from indentation `deriving` isn't a thing in PureScript. There's `derive` keyword, but it has a bit different structure (specifically, it is a top-level keyword). Related discussion: https://discourse.purescript.org/t/solved-is-deriving-keyword-a-thing-in-purescript/4787 --- purescript-indentation.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/purescript-indentation.el b/purescript-indentation.el index 41d0bc1..51671be 100644 --- a/purescript-indentation.el +++ b/purescript-indentation.el @@ -649,7 +649,7 @@ indent the current line. This has to be fixed elsewhere." (purescript-indentation-type) (cond ((string= current-token "=") (purescript-indentation-with-starter - (lambda () (purescript-indentation-separated #'purescript-indentation-type "|" "deriving")) + (lambda () (purescript-indentation-separated #'purescript-indentation-type "|" nil)) nil)) ((string= current-token "where") (purescript-indentation-with-starter @@ -998,7 +998,7 @@ indent the current line. This has to be fixed elsewhere." (defun purescript-indentation-peek-token () "Return token starting at point." - (cond ((looking-at "\\(if\\|then\\|else\\|let\\|in\\|ado\\|mdo\\|rec\\|\\(?:[[:word:]]+\\.\\)*do\\|proc\\|case\\|of\\|where\\|module\\|deriving\\|data\\|type\\|newtype\\|class\\|instance\\)\\([^[:alnum:]'_]\\|$\\)") + (cond ((looking-at "\\(if\\|then\\|else\\|let\\|in\\|ado\\|mdo\\|rec\\|\\(?:[[:word:]]+\\.\\)*do\\|proc\\|case\\|of\\|where\\|module\\|data\\|type\\|newtype\\|class\\|instance\\)\\([^[:alnum:]'_]\\|$\\)") (match-string-no-properties 1)) ((looking-at "[][(){}[,;]") (match-string-no-properties 0)) From 2b96f55c52ceeab08945bae94e424408ddabc258 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 10 Dec 2024 21:41:21 +0300 Subject: [PATCH 2/2] Decypher regexp at purescript-indentation-peek-token The 204 characters line full of backslashes and parentheses isn't the most readable code. Replace it with `rx` expression instead, which makes author's intentions much clearer. As can be checked by evaluation, the resulting regexp is exactly the same, barring the "'_" part was moved to the left of [:alnum:]. --- purescript-indentation.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/purescript-indentation.el b/purescript-indentation.el index 51671be..cea6137 100644 --- a/purescript-indentation.el +++ b/purescript-indentation.el @@ -998,7 +998,13 @@ indent the current line. This has to be fixed elsewhere." (defun purescript-indentation-peek-token () "Return token starting at point." - (cond ((looking-at "\\(if\\|then\\|else\\|let\\|in\\|ado\\|mdo\\|rec\\|\\(?:[[:word:]]+\\.\\)*do\\|proc\\|case\\|of\\|where\\|module\\|data\\|type\\|newtype\\|class\\|instance\\)\\([^[:alnum:]'_]\\|$\\)") + (cond ((looking-at + (rx (group + (or "if" "then" "else" "let" "in" "ado" "mdo" "rec" + (seq (0+ (seq (1+ word) ".")) "do") + "proc" "case" "of" "where" "module" "data" "type" "newtype" + "class" "instance")) + (group (or (not (any alnum "'_")) eol)))) (match-string-no-properties 1)) ((looking-at "[][(){}[,;]") (match-string-no-properties 0))