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

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

[nongnu] elpa/haskell-tng-mode ec39a64 133/385: improvements to indentat


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode ec39a64 133/385: improvements to indentation alts and compilation info
Date: Tue, 5 Oct 2021 23:59:16 -0400 (EDT)

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

    improvements to indentation alts and compilation info
---
 haskell-tng-compile.el                            | 14 ++++++++----
 haskell-tng-font-lock.el                          |  3 +++
 haskell-tng-smie.el                               |  9 ++++++--
 test/compile/ghc-8.4.4-error.compile.faceup       |  4 ++--
 test/compile/ghc-8.4.4-errorspan.compile.faceup   |  4 ++--
 test/compile/ghc-8.4.4-warning.compile.faceup     |  8 +++----
 test/compile/ghc-8.4.4-warningspan.compile.faceup |  8 +++----
 test/src/layout.hs.insert.indent                  |  4 ++--
 test/src/medley.hs.insert.indent                  | 26 +++++++++++------------
 9 files changed, 47 insertions(+), 33 deletions(-)

diff --git a/haskell-tng-compile.el b/haskell-tng-compile.el
index 017ae25..9412acd 100644
--- a/haskell-tng-compile.el
+++ b/haskell-tng-compile.el
@@ -40,12 +40,18 @@
          `(: bol (+ space) "error, called at" (+ space) ,file ":" ,num ":" 
,num " in "))
        1 2 3 2 1)
 
-      ;; ghc information. It's better to not have -fhide-source-paths
+      ;; ghc information.
       (,(rx-to-string
-         `(: bol "[" ,num " of " ,num "] Compiling "
+         ;; Finds .hs references if `source-paths' are emitted
+         `(: bol "[" (* space) ,num (+ space) "of" (+ space) ,num "] Compiling 
"
              (group (+ (not (syntax whitespace))))
-             (? (* space) "(" (* space) ,file)))
-       4 nil nil 0 3 (3 'compilation-info))
+             (* space) "(" (* space) ,file))
+       4 nil nil 0 4)
+      (,(rx-to-string
+         ;; Highlights compilation progress
+         `(: bol "[" (* space) ,num (+ space) "of" (+ space) ,num "] Compiling 
"
+             (group (+ (not (syntax whitespace)))) (group word-end)))
+       nil nil nil 0 4 (1 'compilation-info) (2 'compilation-info) (3 
'compilation-info))
       ))
   "The `compilation-error-regexp-alist' for `haskell-tng'.")
 
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index 45856b1..488282f 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -105,6 +105,9 @@
        (1 'haskell-tng:keyword keep)
        (2 'haskell-tng:type keep))
 
+      ;; TODO unnamed newtype fields should be a type, not a constructor
+      ;; TODO bug, multiple standalone instance declarations in a row do not 
fire
+
       ;; TODO CPP #ifdef would be nice
 
       ;; EXT:TypeApplications: It is not easy to disambiguate between type
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 92bdc9c..ce9dde1 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -97,6 +97,7 @@
 
     ;; TODO implement more indentation rules
 
+    ;; 1. when writing do notation, should we align with the last do line or 
aim for continuations? sync with alts
     (:after
      (pcase arg
        ("where"
@@ -144,7 +145,9 @@ current line."
   (let ((the-line (line-number-at-pos))
         indents)
     (save-excursion
-      (when (re-search-backward haskell-tng:regexp:toplevel nil t)
+      (when (re-search-backward
+             (rx-to-string `(| ,haskell-tng:rx:toplevel (= 2 ?\n)))
+             nil t)
         (let ((start (point)))
           (while (< (line-number-at-pos) the-line)
             (push (current-indentation) indents) ;; this line's indentation
@@ -152,7 +155,7 @@ current line."
           (when (re-search-backward
                  (rx word-start (| "where" "let" "do" "case") word-end)
                  start t)
-            ;; TODO the next whitespace level after a WLDO (not a WLDC)
+            ;; TODO the next whitespace level after a WLDO (not a WLDC), not +2
             (push (+ 2 (current-column)) indents)))))
 
     (save-excursion
@@ -165,6 +168,8 @@ current line."
     ;; TODO consider ordering alts, and cycling the list so the first 
suggestion
     ;; is the next one higher than the current indentation level.
 
+    ;; TODO indentation to current WLDO alignment should be a top priority
+
     ;; indentation of the next line is common for insert edits, top priority
     (save-excursion
       (forward-line)
diff --git a/test/compile/ghc-8.4.4-error.compile.faceup 
b/test/compile/ghc-8.4.4-error.compile.faceup
index 3f951a8..f91cb61 100644
--- a/test/compile/ghc-8.4.4-error.compile.faceup
+++ b/test/compile/ghc-8.4.4-error.compile.faceup
@@ -7,8 +7,8 @@ In order, the following will be built (use -v for more details):
 Configuring library for stackage-to-hackage-1.1.0..
 Preprocessing library for stackage-to-hackage-1.1.0..
 Building library for stackage-to-hackage-1.1.0..
-[1 of 2] Compiling «U:«:compilation-info:StackageToHackage.Stackage»» ( 
«:compilation-info:lib/StackageToHackage/Stackage.hs», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Stackage.o
 )
-[2 of 2] Compiling «U:«:compilation-info:StackageToHackage.Hackage»» ( 
«:compilation-info:lib/StackageToHackage/Hackage.hs», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Hackage.o
 )
+[«:compilation-info:1» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Stackage» ( 
«U:«:compilation-info:lib/StackageToHackage/Stackage.hs»», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Stackage.o
 )
+[«:compilation-info:2» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Hackage» ( 
«U:«:compilation-info:lib/StackageToHackage/Hackage.hs»», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Hackage.o
 )
 
 
«U:«:compilation-error:lib/StackageToHackage/Hackage.hs»»:«:compilation-line-number:33»:«:compilation-column-number:16»:
 «:compilation-error:error»:
     parse error on input ‘=’
diff --git a/test/compile/ghc-8.4.4-errorspan.compile.faceup 
b/test/compile/ghc-8.4.4-errorspan.compile.faceup
index 3871b70..e325476 100644
--- a/test/compile/ghc-8.4.4-errorspan.compile.faceup
+++ b/test/compile/ghc-8.4.4-errorspan.compile.faceup
@@ -7,8 +7,8 @@ In order, the following will be built (use -v for more details):
 Configuring library for stackage-to-hackage-1.1.0..
 Preprocessing library for stackage-to-hackage-1.1.0..
 Building library for stackage-to-hackage-1.1.0..
-[1 of 2] Compiling «U:«:compilation-info:StackageToHackage.Stackage»»
-[2 of 2] Compiling «U:«:compilation-info:StackageToHackage.Hackage»»
+[«:compilation-info:1» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Stackage»
+[«:compilation-info:2» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Hackage»
 
 
«U:«:compilation-error:lib/StackageToHackage/Hackage.hs»»:«:compilation-line-number:13»:«:compilation-column-number:1»-«:compilation-column-number:53»:
 «:compilation-error:error»:
     Could not find module ‘Data.ByteStrong’
diff --git a/test/compile/ghc-8.4.4-warning.compile.faceup 
b/test/compile/ghc-8.4.4-warning.compile.faceup
index a9a2021..8e951e1 100644
--- a/test/compile/ghc-8.4.4-warning.compile.faceup
+++ b/test/compile/ghc-8.4.4-warning.compile.faceup
@@ -7,8 +7,8 @@ In order, the following will be built (use -v for more details):
 Configuring library for stackage-to-hackage-1.1.0..
 Preprocessing library for stackage-to-hackage-1.1.0..
 Building library for stackage-to-hackage-1.1.0..
-[1 of 2] Compiling «U:«:compilation-info:StackageToHackage.Stackage»» ( 
«:compilation-info:lib/StackageToHackage/Stackage.hs», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Stackage.o
 )
-[2 of 2] Compiling «U:«:compilation-info:StackageToHackage.Hackage»» ( 
«:compilation-info:lib/StackageToHackage/Hackage.hs», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Hackage.o
 )
+[«:compilation-info:1» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Stackage» ( 
«U:«:compilation-info:lib/StackageToHackage/Stackage.hs»», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Stackage.o
 )
+[«:compilation-info:2» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Hackage» ( 
«U:«:compilation-info:lib/StackageToHackage/Hackage.hs»», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/noopt/build/StackageToHackage/Hackage.o
 )
 
 
«U:«:compilation-warning:lib/StackageToHackage/Hackage.hs»»:«:compilation-line-number:13»:«:compilation-column-number:1»:
 «:compilation-warning:warning»: [-Wunused-imports]
     The qualified import of ‘Data.ByteString’ is redundant
@@ -23,7 +23,7 @@ Preprocessing executable 'stackage-to-hackage' for 
stackage-to-hackage-1.1.0..
 Building executable 'stackage-to-hackage' for stackage-to-hackage-1.1.0..
 Preprocessing executable 'stack2cabal' for stack2cabal-1.0.2..
 Building executable 'stack2cabal' for stack2cabal-1.0.2..
-[1 of 1] Compiling «U:«:compilation-info:Main»»             ( 
«:compilation-info:exe/Main.hs», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/x/stackage-to-hackage/noopt/build/stackage-to-hackage/stackage-to-hackage-tmp/Main.o
 )
-[1 of 1] Compiling «U:«:compilation-info:Main»»             ( 
«:compilation-info:exe/Main.hs», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stack2cabal-1.0.2/x/stack2cabal/noopt/build/stack2cabal/stack2cabal-tmp/Main.o
 )
+[«:compilation-info:1» of «:compilation-info:1»] Compiling 
«:compilation-info:Main»             ( «U:«:compilation-info:exe/Main.hs»», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/x/stackage-to-hackage/noopt/build/stackage-to-hackage/stackage-to-hackage-tmp/Main.o
 )
+[«:compilation-info:1» of «:compilation-info:1»] Compiling 
«:compilation-info:Main»             ( «U:«:compilation-info:exe/Main.hs»», 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stack2cabal-1.0.2/x/stack2cabal/noopt/build/stack2cabal/stack2cabal-tmp/Main.o
 )
 Linking 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stack2cabal-1.0.2/x/stack2cabal/noopt/build/stack2cabal/stack2cabal
 ...
 Linking 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/x/stackage-to-hackage/noopt/build/stackage-to-hackage/stackage-to-hackage
 ...
diff --git a/test/compile/ghc-8.4.4-warningspan.compile.faceup 
b/test/compile/ghc-8.4.4-warningspan.compile.faceup
index b78fcc2..47988d4 100644
--- a/test/compile/ghc-8.4.4-warningspan.compile.faceup
+++ b/test/compile/ghc-8.4.4-warningspan.compile.faceup
@@ -7,8 +7,8 @@ In order, the following will be built (use -v for more details):
 Configuring library for stackage-to-hackage-1.1.0..
 Preprocessing library for stackage-to-hackage-1.1.0..
 Building library for stackage-to-hackage-1.1.0..
-[1 of 2] Compiling «U:«:compilation-info:StackageToHackage.Stackage»»
-[2 of 2] Compiling «U:«:compilation-info:StackageToHackage.Hackage»»
+[«:compilation-info:1» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Stackage»
+[«:compilation-info:2» of «:compilation-info:2»] Compiling 
«:compilation-info:StackageToHackage.Hackage»
 
 
«U:«:compilation-warning:lib/StackageToHackage/Hackage.hs»»:«:compilation-line-number:13»:«:compilation-column-number:1»-«:compilation-column-number:53»:
 «:compilation-warning:warning»: [-Wunused-imports]
     The qualified import of ‘Data.ByteString’ is redundant
@@ -29,7 +29,7 @@ Preprocessing executable 'stackage-to-hackage' for 
stackage-to-hackage-1.1.0..
 Building executable 'stackage-to-hackage' for stackage-to-hackage-1.1.0..
 Preprocessing executable 'stack2cabal' for stack2cabal-1.0.2..
 Building executable 'stack2cabal' for stack2cabal-1.0.2..
-[1 of 1] Compiling «U:«:compilation-info:Main»»
-[1 of 1] Compiling «U:«:compilation-info:Main»»
+[«:compilation-info:1» of «:compilation-info:1»] Compiling 
«:compilation-info:Main»
+[«:compilation-info:1» of «:compilation-info:1»] Compiling 
«:compilation-info:Main»
 Linking 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stackage-to-hackage-1.1.0/x/stackage-to-hackage/noopt/build/stackage-to-hackage/stackage-to-hackage
 ...
 Linking 
/home/tseenshe/stack2cabal/dist-newstyle/build/x86_64-linux/ghc-8.4.4/stack2cabal-1.0.2/x/stack2cabal/noopt/build/stack2cabal/stack2cabal
 ...
diff --git a/test/src/layout.hs.insert.indent b/test/src/layout.hs.insert.indent
index f82da4a..9b65f98 100644
--- a/test/src/layout.hs.insert.indent
+++ b/test/src/layout.hs.insert.indent
@@ -23,7 +23,7 @@ size s = length (stkToLst s)  where
            stkToLst (MkStack x s)  = x:xs where xs = stkToLst s
 1          2 3                              4                 v
 
-1 2        3                                4                 v
+1 2        3                                                  v
 pop :: Stack a -> (a, Stack a)
 v 1
 pop (MkStack x s)
@@ -31,7 +31,7 @@ pop (MkStack x s)
   = (x, case s of r -> i r where i x = x) -- (pop Empty) is an error
 1 2 3 v                      4
 
-v 1                          2
+v 1
 top :: Stack a -> a
 v 1
 top (MkStack x s) = x                     -- (top Empty) is an error
diff --git a/test/src/medley.hs.insert.indent b/test/src/medley.hs.insert.indent
index d980b25..efc98ba 100644
--- a/test/src/medley.hs.insert.indent
+++ b/test/src/medley.hs.insert.indent
@@ -19,7 +19,7 @@ module Foo.Bar.Main
 ) where
 v 1 2
 
-v 1 2
+v 1
 import           Control.Applicative (many, optional, pure, (<*>), (<|>))
 v 1
 import           Data.Foldable       (traverse_)
@@ -103,19 +103,19 @@ class Get a s where
   get :: Set s -> a
 1 2 3           4   v
 
-1 v             2
+1 v
 instance {-# OVERLAPS #-} Get a (a ': s) where
 2 1 v                                      3
   get (Ext a _) = a
 1 2 3               v                      4
 
-1 v                                        2
+1 v
 instance {-# OVERLAPPABLE #-} Get a s => Get a (b ': s) where
 2 1 v                                                     3
   get (Ext _ xs) = get xs
 1 2 3                  v                                  4
 
-1 v                                                       2
+1 v
 data Options = Options
 2 1              v
   { optionsReportType      :: ReportType
@@ -137,7 +137,7 @@ class  (Eq a) => Ord a  where
   max @Foo, min        :: a -> a -> a
 1 2 3                     4           v
 
-1 v                       2
+1 v
 instance (Eq a) => Eq (Tree a) where
 2 1 v                            3
   Leaf a         == Leaf b          =  a == b
@@ -147,7 +147,7 @@ instance (Eq a) => Eq (Tree a) where
   _              == _               =  False
 1 2 3                            4       v
 
-1 v                              2
+1 v
 data ReportType = Alloc   -- ^ Report allocations, percent
 2 3             1   v
                 | Entries -- ^ Report entries, number
@@ -169,7 +169,7 @@ type family G a where
   G a   = Char
 1 2 3       v     4
 
-1 v               2
+1 v
 data Flobble = Flobble
 2 1              v
   deriving (Eq) via (NonNegative (Large Int))
@@ -201,11 +201,11 @@ foo ::
     a b c)
 12  3 4  v
 
-v12 3
+v 1 2
 (foo :: (Wibble Wobble)) foo
-123 4                    v
+1 2 3                    v
 
-v12 3
+v 1
 newtype TestApp
 2 31    v
    (logger :: TestLogger)
@@ -239,7 +239,7 @@ optionsParser = Options
            Opts.help "meh"))
 1 2    3v 45 6
 
-1 2   v34 56
+1 2   v    3
 type PhantomThing
 1 2  v
 
@@ -265,7 +265,7 @@ type SomeApi =
                       :> Post '[JSON] (The Response)
 1 2    3              v 4                      5
 
-v 1    2              3                        4
+v 1                   2
 deriving instance FromJSONKey StateName
 v 1
 deriving anyclass instance FromJSON Base
@@ -287,6 +287,6 @@ foo = do
         (+) = _
 1 2 3   4 5     v
 
-1 2 3   4       v
+1 2     3       v
 test = 1 `shouldBe` 1
 v 1
\ No newline at end of file



reply via email to

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