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

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

[nongnu] elpa/haskell-tng-mode 64ec84d 260/385: if/then/else indentation


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 64ec84d 260/385: if/then/else indentation
Date: Tue, 5 Oct 2021 23:59:43 -0400 (EDT)

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

    if/then/else indentation
---
 haskell-tng-smie.el                   |  4 ++++
 test/haskell-tng-indent-test.el       |  1 -
 test/src/indentation.hs               | 12 ++++++++++--
 test/src/indentation.hs.append.indent | 20 ++++++++++++++++++--
 test/src/indentation.hs.faceup        | 12 ++++++++++--
 test/src/indentation.hs.imenu         | 27 ++++++++++++++-------------
 test/src/indentation.hs.insert.indent | 24 ++++++++++++++++++++----
 test/src/indentation.hs.layout        | 12 ++++++++++--
 test/src/indentation.hs.sexps         | 14 +++++++++++---
 test/src/indentation.hs.syntax        | 10 +++++++++-
 10 files changed, 106 insertions(+), 30 deletions(-)

diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index ec65586..2348d07 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -265,6 +265,9 @@ information, to aid in the creation of new rules."
              (cl-search '("{" "=") ancestors :test 'equal))
             ",")
 
+           ((member next '("then" "else"))
+            next)
+
            ((or (equal parent "|")
                 (and (equal parent "=")
                      (equal grand "data")
@@ -324,6 +327,7 @@ information, to aid in the creation of new rules."
        ((and "=>" (guard (smie-rule-parent-p "::")))
         (haskell-tng--smie-rule-parent-column 3))
        ("," (smie-rule-separator method))
+       ((or "if" "then" "else") 2)
        ((or "SYMID" "CONSYM" "KINDSYM")
         (if (smie-rule-hanging-p) 2 (smie-rule-parent)))
        ))
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index f5f5ac2..6433333 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -15,7 +15,6 @@
 ;; TODO line after `instance ... where' has too much indent
 ;; TODO records assigning / copy by label
 ;; TODO records of functions
-;; TODO if/then/else
 ;; TODO ImplicitParams in type signatures (without parens)
 
 ;; Three indentation regression tests are possible:
diff --git a/test/src/indentation.hs b/test/src/indentation.hs
index 5cad1cf..7429bd1 100644
--- a/test/src/indentation.hs
+++ b/test/src/indentation.hs
@@ -73,11 +73,19 @@ not_dollars = do
   shouldGoHere <$>
     here
 
-logic a =
+logic1 a =
   if a > 0
-  then a
+  then b
   else -a
 
+logic2 a =
+  if
+    a > 0
+  then
+    b
+  else
+    -a
+
 data Wibble = Wibble Int
             | Wobble Int
             | Vibble Int
diff --git a/test/src/indentation.hs.append.indent 
b/test/src/indentation.hs.append.indent
index b64a416..7df019e 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -148,16 +148,32 @@ not_dollars = do
 2 v 1    3
 
 1 v 2    3
-logic a =
+logic1 a =
 1 v
   if a > 0
 1 v
-  then a
+  then b
 1 v
   else -a
 1 v
 
 1 v
+logic2 a =
+1 v
+  if
+2 1 v
+    a > 0
+2 v 1
+  then
+2 1 v
+    b
+2 v 1
+  else
+2 1 v
+    -a
+1 2 v
+
+1 2 v
 data Wibble = Wibble Int
 1           v
             | Wobble Int
diff --git a/test/src/indentation.hs.faceup b/test/src/indentation.hs.faceup
index d75a2d6..8975357 100644
--- a/test/src/indentation.hs.faceup
+++ b/test/src/indentation.hs.faceup
@@ -73,11 +73,19 @@ not_dollars «:haskell-tng-keyword-face:=» 
«:haskell-tng-keyword-face:do»
   shouldGoHere <$>
     here
 
-logic a «:haskell-tng-keyword-face:=»
+logic1 a «:haskell-tng-keyword-face:=»
   «:haskell-tng-keyword-face:if» a > 0
-  «:haskell-tng-keyword-face:then» a
+  «:haskell-tng-keyword-face:then» b
   «:haskell-tng-keyword-face:else» -a
 
+logic2 a «:haskell-tng-keyword-face:=»
+  «:haskell-tng-keyword-face:if»
+    a > 0
+  «:haskell-tng-keyword-face:then»
+    b
+  «:haskell-tng-keyword-face:else»
+    -a
+
 «:haskell-tng-keyword-face:data»«:haskell-tng-type-face: Wibble 
»«:haskell-tng-keyword-face:=» «:haskell-tng-conid-face:Wibble» 
«:haskell-tng-conid-face:Int»
             «:haskell-tng-keyword-face:|» «:haskell-tng-conid-face:Wobble» 
«:haskell-tng-conid-face:Int»
             «:haskell-tng-keyword-face:|» «:haskell-tng-conid-face:Vibble» 
«:haskell-tng-conid-face:Int»
diff --git a/test/src/indentation.hs.imenu b/test/src/indentation.hs.imenu
index d9d65e3..19788fa 100644
--- a/test/src/indentation.hs.imenu
+++ b/test/src/indentation.hs.imenu
@@ -10,16 +10,17 @@
  ("lambda_case" . 1481)
  ("dollars" . 1540)
  ("not_dollars" . 1613)
- ("logic" . 1689)
- ("lists1" . 2061)
- ("lists2" . 2159)
- ("lists3" . 2185)
- ("tuples1" . 2220)
- ("tuples2" . 2324)
- ("tuples3" . 2351)
- ("typesig" . 2388)
- ("types1" . 2412)
- ("types2" . 2457)
- ("types2b" . 2515)
- ("types3" . 2576)
- ("types_short" . 2676))
+ ("logic1" . 1689)
+ ("logic2" . 1731)
+ ("lists1" . 2116)
+ ("lists2" . 2214)
+ ("lists3" . 2240)
+ ("tuples1" . 2275)
+ ("tuples2" . 2379)
+ ("tuples3" . 2406)
+ ("typesig" . 2443)
+ ("types1" . 2467)
+ ("types2" . 2512)
+ ("types2b" . 2570)
+ ("types3" . 2631)
+ ("types_short" . 2731))
diff --git a/test/src/indentation.hs.insert.indent 
b/test/src/indentation.hs.insert.indent
index 66a7abb..b0919ee 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -148,16 +148,32 @@ not_dollars = do
 2 v 1    3
 
 v 1 2    3
-logic a =
+logic1 a =
 1 v
   if a > 0
-2 1      v
-  then a
-2 1    v
+1 v
+  then b
+1 v
   else -a
 1 v
 
 v 1
+logic2 a =
+1 v
+  if
+2 1 v
+    a > 0
+2 v 1
+  then
+2 1 v
+    b
+2 v 1
+  else
+2 1 v
+    -a
+1 2 v
+
+v 1 2
 data Wibble = Wibble Int
 1           v
             | Wobble Int
diff --git a/test/src/indentation.hs.layout b/test/src/indentation.hs.layout
index b3b3718..d975bbf 100644
--- a/test/src/indentation.hs.layout
+++ b/test/src/indentation.hs.layout
@@ -73,11 +73,19 @@ module Indentation where
   ;shouldGoHere <$>
     here
 
-};logic a =
+};logic1 a =
   if a > 0
-  then a
+  then b
   else -a
 
+;logic2 a =
+  if
+    a > 0
+  then
+    b
+  else
+    -a
+
 ;data Wibble = Wibble Int
             | Wobble Int
             | Vibble Int
diff --git a/test/src/indentation.hs.sexps b/test/src/indentation.hs.sexps
index 6a42b01..1e6be1e 100644
--- a/test/src/indentation.hs.sexps
+++ b/test/src/indentation.hs.sexps
@@ -73,11 +73,19 @@
   ((shouldGoHere) <$>
     (here))
 
-)(logic) (a) =
+)(logic1) (a) =
   (if (a) > (((0)
-  (then) (a)
+  (then) (b)
   (else) (-(a)
 
+((logic2) (a) =
+  (if
+    (a) > (((0)
+  (then)
+    (b)
+  (else)
+    (-(a)
+
 (data (Wibble) = (Wibble) (Int)
             | (Wobble) (Int)
             | (Vibble) (Int))
@@ -150,5 +158,5 @@
           ((?log) :: (HasLogger) (m)) =>
           (a) -> (b) -> (c))
 
-((types_short) :: (Foo) -> (Bar))))))))))))))))))
+((types_short) :: (Foo) -> (Bar)))))))))))))))))))))))
 )))
\ No newline at end of file
diff --git a/test/src/indentation.hs.syntax b/test/src/indentation.hs.syntax
index 594b67d..94efffd 100644
--- a/test/src/indentation.hs.syntax
+++ b/test/src/indentation.hs.syntax
@@ -73,11 +73,19 @@ wwwwwwwwwww _ ww>
   wwwwwwwwwwww ___>
     wwww>
 >
-wwwww w _>
+wwwwww w _>
   ww w _ w>
   wwww w>
   wwww _w>
 >
+wwwwww w _>
+  ww>
+    w _ w>
+  wwww>
+    w>
+  wwww>
+    _w>
+>
 wwww wwwwww _ wwwwww www>
             _ wwwwww www>
             _ wwwwww www>



reply via email to

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