[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 8e4f438 184/385: don't continue indenting
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 8e4f438 184/385: don't continue indenting one liner types |
Date: |
Tue, 5 Oct 2021 23:59:27 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 8e4f438dc4ed8feabd89d9f2d423e35cf3b6ef59
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
don't continue indenting one liner types
---
haskell-tng-rx.el | 2 ++
haskell-tng-smie.el | 13 ++++++++++++-
test/haskell-tng-indent-test.el | 3 ---
test/src/indentation.hs.append.indent | 8 ++++----
test/src/indentation.hs.insert.indent | 2 +-
5 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/haskell-tng-rx.el b/haskell-tng-rx.el
index b745715..6feb315 100644
--- a/haskell-tng-rx.el
+++ b/haskell-tng-rx.el
@@ -59,6 +59,8 @@ give false positives." `(|
(: symbol-start "--" (+ (not (any ?\n))) ?\n))
"Newline or line comment.")
+;; TODO consider using rx's eval to reuse forms instead of backticks
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Compiled regexps
;;
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 595095b..641c30d 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -236,7 +236,9 @@ information, to aid in the creation of new rules."
(not (equal prev "}"))))
"|")
- ((member parent '("::" "=>"))
+ ((and (member parent '("::" "=>"))
+ (not (haskell-tng-smie:search-prev-line
+ (rx (>= 2 (+ anything) "->")))))
"=>")
((equal parent "deriving")
@@ -381,6 +383,7 @@ BEFORE is t if the line appears before the indentation."
(let ((start (point))
relevant)
(while (< (point) bound)
+ ;; TODO we the lexer instead of regexps, we're not barbarians
(when (not
(looking-at
(rx (* space) (| "where" "do") word-end)))
@@ -451,6 +454,14 @@ Inspired by `smie-indent--parent', which can only be used
in
(cons tok (haskell-tng-smie:ancestors (- n 1)))
(list tok))))
+(defun haskell-tng-smie:search-prev-line (regexp)
+ "Search forward on the previous non-empty line"
+ (save-excursion
+ (beginning-of-line)
+ (forward-comment (- (point)))
+ (beginning-of-line)
+ (re-search-forward regexp (line-end-position) t)))
+
;; SMIE wishlist, in order of desirability:
;;
;; 1. if the lexer could return lists of tokens.
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index a7909d4..f068a4f 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -77,9 +77,6 @@
;; at point-max, so add some whitespace at the end.
;;
;; TODO fix the bug properly, in SMIE.
- ;;
- ;; TODO maybe we can have a better workaround by presenting tokens -1
- ;; from the end and enforcing a trailing newline.
(save-excursion
(insert "\n\n"))))
(while (pcase mode
diff --git a/test/src/indentation.hs.append.indent
b/test/src/indentation.hs.append.indent
index 9eaada9..fe7b3c6 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -247,9 +247,9 @@ v 1
v 1
typesig :: a -> b -> c
-1 v
+v
-1 v
+v
types1 ::
1 v
Monad m
@@ -277,6 +277,6 @@ types3 :: (Monad m, MonadReader Foo m) =>
(?log :: HasLogger m) =>
1 v
a -> b -> c
-1 v
+v 1
-1 v
\ No newline at end of file
+v 1
\ No newline at end of file
diff --git a/test/src/indentation.hs.insert.indent
b/test/src/indentation.hs.insert.indent
index 9b29da9..82df418 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -247,7 +247,7 @@ v 1
v 1
typesig :: a -> b -> c
-1 v
+v
v
types1 ::
- [nongnu] elpa/haskell-tng-mode c40c6e6 125/385: fix explicit export fontification bug, (continued)
- [nongnu] elpa/haskell-tng-mode c40c6e6 125/385: fix explicit export fontification bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 82312a2 126/385: working compilation matchers, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 794c80b 131/385: better indentation alts, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d43fd73 141/385: more efficient indentation 'insert test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a830fcb 135/385: reindention test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode aa2a0ad 146/385: prefer --enable-tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a754020 144/385: indent alts will suggest based on previous <- lines, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9023dc6 164/385: don't rely on line-based indentation rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fdaaf38 148/385: indent after "in", ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e2c60a9 161/385: prep for records, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8e4f438 184/385: don't continue indenting one liner types,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 5251477 186/385: thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 41f1ad5 191/385: document fast-tags, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4ec6259 185/385: prefer the lexer, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1475f31 196/385: workaround bad indentation at the end of files, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4b0ab71 199/385: indent type signatures on separate lines, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 950d094 210/385: projectile is not core, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2df165a 229/385: electric indent locally disabled only, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 56ee2aa 231/385: completions alpha, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6e938d0 230/385: workaround cabal bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 444664d 257/385: special case indentation of visual line breaks, ELPA Syncer, 2021/10/06