[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode a754020 144/385: indent alts will suggest
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode a754020 144/385: indent alts will suggest based on previous <- lines |
Date: |
Tue, 5 Oct 2021 23:59:18 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit a754020de0830c103eadf1e00762ca519e215389
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
indent alts will suggest based on previous <- lines
---
haskell-tng-smie.el | 20 ++++++++++++++------
test/src/indentation.hs.append.indent | 12 ++++++------
test/src/indentation.hs.insert.indent | 10 +++++-----
test/src/indentation.hs.reindent | 10 +++++-----
4 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index b4ebc93..d056b21 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -211,7 +211,7 @@ current line."
(save-excursion
(end-of-line 0)
(re-search-backward haskell-tng:regexp:toplevel nil t)
- (when-let (new (haskell-tng-smie:relevant-alts pos))
+ (when-let (new (haskell-tng-smie:relevant-alts pos t))
(setq indents (append new indents))))
;; alts are easier to use when ordered
@@ -221,13 +221,15 @@ current line."
(--each '(1 -1)
(save-excursion
(forward-line it)
- (when-let (new (haskell-tng-smie:relevant-alts (point-at-eol)))
+ (when-let (new (haskell-tng-smie:relevant-alts (point-at-eol) (< it
0)))
(setq indents (append new indents)))))
(-distinct indents)))
-(defun haskell-tng-smie:relevant-alts (bound)
- "A list of indentation levels from point to BOUND."
+(defun haskell-tng-smie:relevant-alts (bound before)
+ "A list of indentation levels from point to BOUND.
+
+BEFORE is t if the line appears before the indentation."
(let ((start (point))
relevant)
(while (< (point) bound)
@@ -235,8 +237,14 @@ current line."
(looking-at
(rx (* space) (| "where" "let" "do") word-end)))
(push (current-indentation) relevant))
- ;; TODO when there is a <- add its close +4 (possibly just for the
- ;; immediately previous line).
+ (when
+ (and
+ before
+ (re-search-forward
+ (rx symbol-start "<-" (+ " "))
+ (line-end-position)
+ t))
+ (push (current-column) relevant))
(forward-line))
(goto-char start)
(while (< (point) bound)
diff --git a/test/src/indentation.hs.append.indent
b/test/src/indentation.hs.append.indent
index bd9418a..0a56dfa 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -33,9 +33,9 @@ v 1 2
basic_do = do
1 v
foo <- blah blah blah
-1 v
+2 v 1
bar <- blah blah
-1 v
+2 v 1
blah -- manual correction
2 v 1
blah -- manual correction
@@ -61,13 +61,13 @@ basic_do = do
nested_do = -- manual correction
1 v
do foo <- blah
-1 v
+2 v 1
do bar <- blah -- same level as foo
-2 1 v
+3 1 v 4 2
baz -- same level as bar
-1 2 v
+1 2 v 3 4
-1 2 v
+1 2 v 3 4
nested_where a b = foo a b
v
where -- TODO 2
diff --git a/test/src/indentation.hs.insert.indent
b/test/src/indentation.hs.insert.indent
index 9578e89..9042620 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -33,7 +33,7 @@ v 1 2
basic_do = do
1 v
foo <- blah blah blah
-1 v
+2 v 1
bar <- blah blah
2 1 v
blah -- manual correction
@@ -61,13 +61,13 @@ basic_do = do
nested_do = -- manual correction
1 v 2
do foo <- blah
-2 v 1
+3 v 2 1
do bar <- blah -- same level as foo
-2 1 v
+3 1 v 4 2
baz -- same level as bar
-1 2 v
+1 2 v 3 4
-1 2 v
+1 2 v 3 4
nested_where a b = foo a b
1 v
where -- TODO 2
diff --git a/test/src/indentation.hs.reindent b/test/src/indentation.hs.reindent
index 6428102..8906b4b 100644
--- a/test/src/indentation.hs.reindent
+++ b/test/src/indentation.hs.reindent
@@ -32,7 +32,7 @@ v 1 2
v 1 2 3
basic_do = do
-1 v
+1 v 2
foo <- blah blah blah
v 1 2
bar <- blah blah
@@ -62,13 +62,13 @@ v 2 13 45 6
nested_do = -- manual correction
v 1
do foo <- blah
-v 1 2
+v 1 3 2
do bar <- blah -- same level as foo
-v 2 1
+v 2 1 4 3
baz -- same level as bar
-1 2 v
+1 2 v 3 4
-v 1 2
+v 1 2 3 4
nested_where a b = foo a b
1 v 2
where -- TODO 2
- [nongnu] elpa/haskell-tng-mode 9bfc6bf 215/385: really basic imenu, (continued)
- [nongnu] elpa/haskell-tng-mode 9bfc6bf 215/385: really basic imenu, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f648cf9 212/385: fallback to current directory (e.g. for cabal scripts), ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5bdf688 211/385: better in-line indentation of parens, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1cdf901 120/385: better escape syntax detection, ELPA Syncer, 2021/10/06
- [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 <=
- [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, 2021/10/06
- [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