[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 9ec4841 104/385: meh indentation
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 9ec4841 104/385: meh indentation |
Date: |
Tue, 5 Oct 2021 23:59:10 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 9ec48419d88ce2029660cd68d5f4eb1fac51d0ae
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
meh indentation
---
haskell-tng-smie.el | 29 +++++++++++++++++------------
test/haskell-tng-indent-test.el | 16 ++++++++++++++++
test/src/layout.hs.insert.indent | 4 ++--
test/src/medley.hs.insert.indent | 16 ++++++++--------
4 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index bfec21e..adb3de1 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -85,21 +85,26 @@
)))
;;
https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Indentation
-;;
-;; ideas for an indentation tester
-;;
https://github.com/elixir-editors/emacs-elixir/blob/master/test/test-helper.el#L52-L63
(defun haskell-tng-smie:rules (method arg)
;; see docs for `smie-rules-function'
;; FIXME implement prime indentation
- (pcase (cons method arg)
- (`(:elem . basic) smie-indent-basic)
- (`(,_ . ",") (smie-rule-separator method))
- (`(:after . "=") smie-indent-basic)
- (`(:before . ,(or `"(" `"{"))
- (if (smie-rule-hanging-p) (smie-rule-parent)))
- (`(:before . "if")
- (and (not (smie-rule-bolp)) (smie-rule-prev-p "else")
- (smie-rule-parent)))))
+;; (message "INDENT %S %S" method arg)
+ (pcase method
+ (:elem
+ (pcase arg
+ ('basic smie-indent-basic)
+ ))
+
+ (:after
+ (pcase arg
+ ((or "::" "=" "where" "let" "do" "of")
+ ;; TODO module where should have column 0
+ ;; TODO wtf is happening with the line "class Get a s where"
+ smie-indent-basic)
+ ))
+
+ ;; TODO :before rules
+ ))
(defconst haskell-tng-smie:return '(newline-and-indent)
"Users with custom newlines should add their command.")
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index 10622bb..acb6560 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -31,6 +31,22 @@
;; TODO more tests
)
+;; TODO enable this test and get it passing, which requires a TAB command that
+;; will insert whitespace and move point to end. Workaround is to use abbrevs
or
+;; yasnippets for things like "import" that have fixed indentations.
+;;
+;; (ert-deftest haskell-tng-indent-custom-tests ()
+;; (with-temp-buffer
+;; (insert-file-contents (testdata "src/medley.hs"))
+;; (haskell-tng-mode)
+;; ;; import TAB should jump to column 17
+;; (goto-char 511)
+;; (ert-simulate-command '(forward-word))
+;; (ert-simulate-command '(indent-for-tab-command))
+;; (ert-simulate-command '(indent-for-tab-command))
+;; (should (equal (point) 528))
+;; ))
+
(defun current-line-string ()
(buffer-substring-no-properties
(line-beginning-position)
diff --git a/test/src/layout.hs.insert.indent b/test/src/layout.hs.insert.indent
index a0aa39a..9133f2a 100644
--- a/test/src/layout.hs.insert.indent
+++ b/test/src/layout.hs.insert.indent
@@ -1,7 +1,7 @@
-- Figure 2.1 from the Haskell2010 report
v
module AStack( Stack, push, pop, top, size ) where
-v
+. v
data Stack a = Empty
. v
| MkStack a (Stack a)
@@ -17,7 +17,7 @@ v
size :: Stack a -> Int
v
size s = length (stkToLst s) where
-v
+. v
stkToLst Empty = []
. . v
stkToLst (MkStack x s) = x:xs where xs = stkToLst s
diff --git a/test/src/medley.hs.insert.indent b/test/src/medley.hs.insert.indent
index 475b574..501e073 100644
--- a/test/src/medley.hs.insert.indent
+++ b/test/src/medley.hs.insert.indent
@@ -17,9 +17,9 @@ module Foo.Bar.Main
, module Bloo.Foo
. . v
) where
-v .
+. v
-v .
+. v
import Control.Applicative (many, optional, pure, (<*>), (<|>))
v
import Data.Foldable (traverse_)
@@ -83,19 +83,19 @@ foo = "wobble (wibble)"
v
class Get a s where
-. v
+. v
get :: Set s -> a
. . v
. v
instance {-# OVERLAPS #-} Get a (a ': s) where
-. v
+. v
get (Ext a _) = a
. . v
. v
instance {-# OVERLAPPABLE #-} Get a s => Get a (b ': s) where
-. v
+. v
get (Ext _ xs) = get xs
. . v
@@ -115,7 +115,7 @@ data Options = Options
v .
class (Eq a) => Ord a where
-. v
+. v
(<), (<=), (>=), (>) :: a -> a -> Bool
. . v
max @Foo, min :: a -> a -> a
@@ -123,7 +123,7 @@ class (Eq a) => Ord a where
. v
instance (Eq a) => Eq (Tree a) where
-. v
+. v
Leaf a == Leaf b = a == b
. . v
(Branch l1 r1) == (Branch l2 r2) = (l1==l2) && (r1==r2)
@@ -147,7 +147,7 @@ data ReportType = Alloc -- ^ Report allocations, percent
v .
type family G a where
-. v
+. v
G Int = Bool
. . v
G a = Char
- [nongnu] elpa/haskell-tng-mode ee1fb28 345/385: small cleanup, (continued)
- [nongnu] elpa/haskell-tng-mode ee1fb28 345/385: small cleanup, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1310276 346/385: planning, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 09018bc 352/385: support hsinspect beta releases, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e73bc19 335/385: jump-to-definition, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2f2c500 354/385: defining a test spec, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 232baf8 362/385: less import suggestions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ab53433 375/385: reprioritise, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2b9c6bf 369/385: support dev hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 68d1d7c 371/385: bump hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6a31b59 101/385: document the plan for indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9ec4841 104/385: meh indentation,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode ea46850 207/385: bugfix for compile vs runtime loading, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 63b1c8d 250/385: flip the default newline / comment behaviour, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 83458d6 253/385: reverting newline comment behaviour, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f59c9ee 259/385: fix indentation of short type signatures, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode dbbe488 265/385: abbrevs don't fire in comments / strings, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f56bd2a 256/385: prefer optimised hsinspect builds, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e84970b 263/385: rename -contrib to -extra, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode af443a1 269/385: fix a name clash in the tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cce466c 271/385: hsinspect now has a compiler plugin, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d0cd9b9 252/385: documenting an annoying indentation bug, ELPA Syncer, 2021/10/06