emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/haskell-tng-mode ab5252b 169/385: rearrange alts


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode ab5252b 169/385: rearrange alts
Date: Tue, 5 Oct 2021 23:59:24 -0400 (EDT)

branch: elpa/haskell-tng-mode
commit ab5252bda402b137f61bd6882f3508b5484a12c5
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>

    rearrange alts
---
 haskell-tng-smie.el                   | 11 ++++++-----
 test/src/indentation.hs.insert.indent | 12 ++++++------
 test/src/indentation.hs.reindent      | 36 +++++++++++++++++------------------
 3 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 18707ed..b4af17e 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -18,7 +18,7 @@
 ;;  because it is not known if the user wishes to continue the previous line,
 ;;  create a new line at the same level, or close off the block. We try to err
 ;;  on the side of "staying at the same level" (not escaping or closing a
-;;  previous line) when we can.
+;;  previous line) when we can, but also try to anticipate the next line.
 ;;
 ;;  All the good ideas are from Stefan Monnier, all the bad ones are mine.
 ;;
@@ -156,6 +156,7 @@ information, to aid in the creation of new rules."
      (pcase arg
        ((or 'args 'basic) 0)
 
+       ;; TODO insert the predicted token... code completion!
        ('empty-line-token
         (let* ((parents (save-excursion
                          (haskell-tng-smie:ancestors 2)))
@@ -304,15 +305,15 @@ current line."
     ;; alts are easier to use when ordered
     (setq indents (sort indents '<))
 
-    ;; previous / next line should be top priority alts
-    (--each '(1 -1)
+    ;; TODO SMIE +2 might be good to have
+
+    ;; next / previous line should be top priority alts
+    (--each '(-1 1)
       (save-excursion
         (forward-line it)
         (when-let (new (haskell-tng-smie:relevant-alts (point-at-eol) (< it 
0)))
           (setq indents (append new indents)))))
 
-    ;; TODO if this list is empty, return current+2
-
     (-distinct indents)))
 
 (defun haskell-tng-smie:relevant-alts (bound before)
diff --git a/test/src/indentation.hs.insert.indent 
b/test/src/indentation.hs.insert.indent
index 1cd66ca..4ef4d09 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -45,7 +45,7 @@ basic_do = do
   sideeffect' blah
 2 v   1  3
   let baz = blah blah
-4 2   1  5  3    v
+4 3   2  5  1    v
             blah -- manual correction
 2 3   v  4  1
       gaz = blah
@@ -53,15 +53,15 @@ basic_do = do
       haz =
 2 3   1 v4  5
         blah
-3 2   v 14  5
+3 1   v 24  5
   pure faz -- manual correction
 1 v   2 34  5
 
 1 v   2 34  5
 nested_do = -- manual correction
-1 v  2
+2 v  1
   do foo <- blah
-3    v  2   1
+3    v  1   2
      do bar <- blah -- same level as foo
 3    1  v   4  2
         baz -- same level as bar
@@ -97,7 +97,7 @@ let_in a b = let
 
 1 v 2
 implicit_let foo bar =
-1 v   2
+2 v   1
   let ?foo = foo
 1     v
       ?bar = bar
@@ -167,7 +167,7 @@ v
 
 v
 data Record2 = Record2
-1 2          v
+2 1          v
   { fieldA :: String
 1 v
   , fieldB :: String
diff --git a/test/src/indentation.hs.reindent b/test/src/indentation.hs.reindent
index 3a82c98..aac52c2 100644
--- a/test/src/indentation.hs.reindent
+++ b/test/src/indentation.hs.reindent
@@ -24,7 +24,7 @@ v
 import Foo.Bar
 v                       1
 import Foo.Baz hiding ( gaz,
-1                     2 v
+2                     1 v
                         baz
 2                     v 1
                       )
@@ -34,25 +34,25 @@ v 1                   2 3
 basic_do = do
 1 v      2
   foo <- blah blah blah
-v 1      2
+v 2      1
   bar <- blah blah
 2 1      v
          blah -- manual correction
 2 1      v
          blah -- manual correction
-v 2      1
+v 1      2
   sideeffect
-v 1   2  3
+v 2   1  3
   sideeffect' blah
-v 1      3  2
+v 2      3  1
   let baz = blah blah
 3 2   1  4       v
             blah -- manual correction
-v 3   2  4  1
+v 3   1  4  2
       gaz = blah
-v 3   1 24  5
+v 3   2 14  5
       haz =
-3 2   1 v4  5
+3 1   2 v4  5
         blah
 2 v   3 14  5
   pure faz -- manual correction
@@ -62,7 +62,7 @@ v 2  13 45  6
 nested_do = -- manual correction
 v       1
   do foo <- blah
-v    1  3   2
+v    2  1   3
      do bar <- blah -- same level as foo
 v    2  1   4  3
         baz -- same level as bar
@@ -70,7 +70,7 @@ v    2  1   4  3
 
 v    1  2   3  4
 nested_where a b = foo a b
-1 v 2
+2 v 1
   where -- manual correction
 1   v
     foo = bar baz -- indented
@@ -90,17 +90,17 @@ let_in a b = let
   blah = bloo
 v 1
   wobble _ = fish
-v 1 2
+v 2 1
   in
 2 1 v
     flibble blah
-2 v 1
+1 v 2
 
 v 2 3 1
 implicit_let foo bar =
 v     1
   let ?foo = foo
-v 2   1
+v 1   2
       ?bar = bar
 v     1
   in  rar
@@ -108,7 +108,7 @@ v 1   2
 
 v 1   2
 case_of wibble = case wibble of
-1 v 2
+2 v 1
   Nothing   ->
 2 1 v
     ""
@@ -116,7 +116,7 @@ v 2 1
   Just fish ->
 2 1 v
     fish
-2 v 1
+1 v 2
 
 v 1 2
 lambda_case = \case
@@ -142,11 +142,11 @@ v 1
 not_dollars = do
 1 v      2
   db' <- liftIO $ readMVar db
-v 1 3    2
+v 2 1    3
   shouldGoHere <$>
 2 1 v    3
     here
-2 v 1    3
+1 v 2    3
 
 v 2 3    4  1
 data Wibble = Wibble Int
@@ -168,7 +168,7 @@ v
 
 v 1
 data Record2 = Record2
-1 2            v
+2 1            v
   { fieldA :: String
 1 v
   , fieldB :: String



reply via email to

[Prev in Thread] Current Thread [Next in Thread]