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

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

[nongnu] elpa/haskell-tng-mode 2c6c772 150/385: better WLDO indentation


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 2c6c772 150/385: better WLDO indentation
Date: Tue, 5 Oct 2021 23:59:20 -0400 (EDT)

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

    better WLDO indentation
---
 haskell-tng-smie.el                   | 14 ++++++++++++--
 test/src/indentation.hs               |  9 +++++----
 test/src/indentation.hs.append.indent | 20 +++++++++++---------
 test/src/indentation.hs.insert.indent | 22 ++++++++++++----------
 test/src/indentation.hs.layout        | 11 ++++++-----
 test/src/indentation.hs.lexer         |  7 ++++---
 test/src/indentation.hs.reindent      | 24 +++++++++++++-----------
 test/src/indentation.hs.sexps         | 11 ++++++-----
 8 files changed, 69 insertions(+), 49 deletions(-)

diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 931283e..1ed75d7 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -168,8 +168,18 @@ information, to aid in the creation of new rules."
 
     (:before
      (pcase arg
-       ;; encourages WLDOs to move to the left
-       ((or "{" "where" "do" "case") (smie-rule-parent))
+       ;; first entries in a WLDO should aim to have the smallest indentation
+       ;; possible. i.e. prefer
+       ;;
+       ;; blah = bloo where
+       ;;   bloo = blu
+       ;;
+       ;; not
+       ;;
+       ;; blah = bloo where
+       ;;               bloo = blu
+       ((or "{" "where" "let" "do" "case")
+        (smie-rule-parent))
        ))
 
     ))
diff --git a/test/src/indentation.hs b/test/src/indentation.hs
index 556ec8c..278ad20 100644
--- a/test/src/indentation.hs
+++ b/test/src/indentation.hs
@@ -41,10 +41,11 @@ nested_where a b = foo a b
         gaz a = blah -- indented
         faz = blah -- same level as gaz
 
-let_in a b = let blah = bloo
-                 wobble _ = fish
-             in
-               flibble blah
+let_in a b = let
+  blah = bloo
+  wobble _ = fish
+  in
+    flibble blah
 
 case_of wibble = case wibble of
   Nothing   -> ""
diff --git a/test/src/indentation.hs.append.indent 
b/test/src/indentation.hs.append.indent
index 7f0072e..d5af495 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -84,16 +84,18 @@ v
 1   2   v
 
 1   2   v
-let_in a b = let blah = bloo
-1                v
-                 wobble _ = fish
-1                v
-             in
-2            1 v 3
-               flibble blah
-v            2 1 3
+let_in a b = let
+1 v
+  blah = bloo
+1 v
+  wobble _ = fish
+1 v
+  in
+2 1 v
+    flibble blah
+2 v 1
 
-v            1 2 3
+1 v 2
 case_of wibble = case wibble of
 1 v
   Nothing   -> ""
diff --git a/test/src/indentation.hs.insert.indent 
b/test/src/indentation.hs.insert.indent
index c1bd0e3..1f01887 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -83,17 +83,19 @@ nested_where a b = foo a b
         faz = blah -- same level as gaz
 1   2   v
 
-2   3   v        1
-let_in a b = let blah = bloo
-1                v
-                 wobble _ = fish
-2            1   v
-             in
-2            1 v 3
-               flibble blah
-v            2 1 3
+1   2   v
+let_in a b = let
+1 v
+  blah = bloo
+1 v
+  wobble _ = fish
+1 v
+  in
+2 1 v
+    flibble blah
+2 v 1
 
-v            1 2 3
+1 v 2
 case_of wibble = case wibble of
 1 v
   Nothing   -> ""
diff --git a/test/src/indentation.hs.layout b/test/src/indentation.hs.layout
index 79a7f3c..f4b88aa 100644
--- a/test/src/indentation.hs.layout
+++ b/test/src/indentation.hs.layout
@@ -41,12 +41,13 @@ module Indentation where
         {gaz a = blah -- indented
         ;faz = blah -- same level as gaz
 
-}};let_in a b = let {blah = bloo
-                 ;wobble _ = fish
-             }in
-               flibble blah
+}};let_in a b = let
+  {blah = bloo
+  ;wobble _ = fish
+  ;in
+    flibble blah
 
-;case_of wibble = case wibble of
+};case_of wibble = case wibble of
   {Nothing   -> ""
   ;Just fish -> fish
 
diff --git a/test/src/indentation.hs.lexer b/test/src/indentation.hs.lexer
index 98e2525..e08c25a 100644
--- a/test/src/indentation.hs.lexer
+++ b/test/src/indentation.hs.lexer
@@ -41,12 +41,13 @@ where
 { VARID VARID = VARID
 ; VARID = VARID
 
-} } ; VARID VARID VARID = let { VARID = VARID
+} } ; VARID VARID VARID = let
+{ VARID = VARID
 ; VARID _ = VARID
-} in
+; in
 VARID VARID
 
-; VARID VARID = case VARID of
+} ; VARID VARID = case VARID of
 { CONID -> ยง
 ; CONID VARID -> VARID
 
diff --git a/test/src/indentation.hs.reindent b/test/src/indentation.hs.reindent
index a46a957..37a2177 100644
--- a/test/src/indentation.hs.reindent
+++ b/test/src/indentation.hs.reindent
@@ -82,19 +82,21 @@ v   1
         gaz a = blah -- indented
 v   2   1
         faz = blah -- same level as gaz
-2   3   v        1
+1   2   v
 
-v   2   3        1
-let_in a b = let blah = bloo
-v            2   1
-                 wobble _ = fish
-v              2 1
-             in
-2            1 v 3
-               flibble blah
-v            2 1 3
+v 1 2   3
+let_in a b = let
+1 v
+  blah = bloo
+v 1
+  wobble _ = fish
+v 1 2
+  in
+2 1 v
+    flibble blah
+2 v 1
 
-v 1          2 3 4
+v 1 2
 case_of wibble = case wibble of
 1 v
   Nothing   -> ""
diff --git a/test/src/indentation.hs.sexps b/test/src/indentation.hs.sexps
index 005753d..fa270e1 100644
--- a/test/src/indentation.hs.sexps
+++ b/test/src/indentation.hs.sexps
@@ -41,12 +41,13 @@
         ((gaz) (a) = (blah) -- indented
         ((faz) = (blah)) -- same level as gaz
 
-)))(let_in) (a) (b) = (let ((blah) = (bloo)
-                 ((wobble) (_) = (fish))
-             )in)
-               (flibble) (blah)
+)))(let_in) (a) (b) = (let
+  (((blah) = (bloo)
+  (((wobble) (_) = (fish))
+  )in)
+    (flibble) (blah)
 
-((case_of) (wibble) = ((case (wibble) (of)
+)(case_of) (wibble) = ((case (wibble) (of)
   ((Nothing)   -> ("")
   ((Just) (fish) -> (fish))
 



reply via email to

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