[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 91a1d08 136/385: creating small scenarios
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 91a1d08 136/385: creating small scenarios for indentation specs |
Date: |
Tue, 5 Oct 2021 23:59:17 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 91a1d0840265ef6104fb543bfb549e157c7d5cc5
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
creating small scenarios for indentation specs
---
README.md | 1 +
haskell-tng-smie.el | 26 +++++++++++++---------
test/haskell-tng-indent-test.el | 7 +++---
test/src/indentation.hs | 21 ++++++++++++++++++
test/src/indentation.hs.insert.indent | 42 +++++++++++++++++++++++++++++++++++
test/src/indentation.hs.reindent | 42 +++++++++++++++++++++++++++++++++++
6 files changed, 125 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
index b1c9c35..f0b6db3 100644
--- a/README.md
+++ b/README.md
@@ -103,6 +103,7 @@ Some blue sky features are being considered but may be best
as independent proje
- identify trivial / helper functions and forward their `edit-definition` to
another location.
- Code gen
- `instance` boilerplate
+ - record of functions boilerplate
- Refactoring
- be compatible with
[`apply-refact`](https://github.com/mpickering/apply-refact) /
[`hlint-refactor-mode`](https://github.com/mpickering/hlint-refactor-mode)
- insert explicit list of exports
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 06067fe..9c8baa6 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -5,14 +5,20 @@
;;; Commentary:
;;
-;; SMIE precedence table, providing s-expression navigation, and indentation
-;; rules.
+;; SMIE precedence table and indentation rules.
;;
-;; Although SMIE provides the primary indentation suggest (when the user types
-;; RETURN), we cycle through alternative candidates on TAB. The philosophy is
-;; not to try and get indentation right 100% of the time, but to get it right
-;; 90% of the time and make it so easy to fix it that it doesn't get in the
-;; way.
+;; Although SMIE provides the primary indentation suggestion, we cycle through
+;; heuristic alternative candidates on subsequent presses of TAB.
+;;
+;; The philosophy is not to get indentation right 100% of the time, but to get
+;; it right 90% of the time and make it so easy to fix it that it doesn't get
+;; in the way.
+;;
+;; Interactive indentation is ambiguous in a whitespace sensitive language
+;; 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.
;;
;; Users may consult the SMIE manual to customise their indentation rules:
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE
@@ -128,14 +134,14 @@ information, to aid in the creation of new rules."
(:after
(pcase arg
("where"
+ ;; TODO `module' doesn't trigger when writing a fresh file, it's coming
+ ;; up as before/after `{'.
(if (smie-rule-parent-p "module")
'(column . 0)
smie-indent-basic))
((or "::" "=" "let" "do" "of" "{")
smie-indent-basic)
))
-
- ;; TODO :before rules
))
(defconst haskell-tng-smie:return
@@ -226,8 +232,6 @@ current line."
#'haskell-tng-smie:indent-cycle
nil 'local)
- ;; TODO alternative to indent-for-tab-command that does alignment
-
(smie-setup
haskell-tng-smie:grammar
#'haskell-tng-smie:rules
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index 08da3b0..2734c83 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -26,6 +26,8 @@
;; Test 1 involves a lot of buffer refreshing and will be very slow.
(ert-deftest haskell-tng-newline-indent-file-tests ()
+ (should (have-expected-newline-indent-insert (testdata
"src/indentation.hs")))
+
(should (have-expected-newline-indent-insert (testdata "src/layout.hs")))
(should (have-expected-newline-indent-insert (testdata "src/medley.hs")))
;; TODO more tests
@@ -33,11 +35,10 @@
)
(ert-deftest haskell-tng-reindent-file-tests ()
+ (should (have-expected-reindent-insert (testdata "src/indentation.hs")))
+
(should (have-expected-reindent-insert (testdata "src/layout.hs")))
(should (have-expected-reindent-insert (testdata "src/medley.hs")))
-
- ;; FIXME a test file specifically for common indentation situations to
- ;; define a spec.
)
(defun current-line-string ()
diff --git a/test/src/indentation.hs b/test/src/indentation.hs
new file mode 100644
index 0000000..e66d171
--- /dev/null
+++ b/test/src/indentation.hs
@@ -0,0 +1,21 @@
+-- | Idealised indentation scenarios.
+--
+-- Bugs and unexpected behaviour in (re-)indentation may be documented here.
+module Indentation where
+
+-- A basic `do` block using virtual indentation to suggest the whitespace
+basic_do = do
+ -- TODO do should have virtual indentation of 0, so this is at 2
+ foo = blah blah blah
+ -- TODO should suggest that bar is a binding
+ bar = blah blah
+ blah -- manual continuation, should be 1st alt TODO
+ blah -- continue what we were doing, should be the SMIE rule
+
+-- TODO `do` with manual layout
+-- TODO nested `do`
+
+
+-- TODO coproduct definitions, the | should align with =
+
+-- TODO lists
diff --git a/test/src/indentation.hs.insert.indent
b/test/src/indentation.hs.insert.indent
new file mode 100644
index 0000000..cfb7ced
--- /dev/null
+++ b/test/src/indentation.hs.insert.indent
@@ -0,0 +1,42 @@
+-- | Idealised indentation scenarios.
+v 1
+--
+v 1
+-- Bugs and unexpected behaviour in (re-)indentation may be documented here.
+v 1
+module Indentation where
+v 1 2
+
+v 1
+-- A basic `do` block using virtual indentation to suggest the whitespace
+v 1 2
+basic_do = do
+2 1 v
+ -- TODO do should have virtual indentation of 0, so this is at 2
+2 1 3 4v
+ foo = blah blah blah
+2 1 3 4v
+ -- TODO should suggest that bar is a binding
+2 1 3 4v
+ bar = blah blah
+2 3 4 1 5v
+ blah -- manual continuation, should be 1st alt TODO
+1 2 v 3 4
+ blah -- continue what we were doing, should be the SMIE rule
+1 2 v 3 4
+
+1 2 v
+-- TODO `do` with manual layout
+1 2 v 3
+-- TODO nested `do`
+1 2 v 3
+
+1 2 v
+
+1 2 v
+-- TODO coproduct definitions, the | should align with =
+1 2 v
+
+1 2 v
+-- TODO lists
+1 2 v
\ No newline at end of file
diff --git a/test/src/indentation.hs.reindent b/test/src/indentation.hs.reindent
new file mode 100644
index 0000000..21edc49
--- /dev/null
+++ b/test/src/indentation.hs.reindent
@@ -0,0 +1,42 @@
+v
+-- | Idealised indentation scenarios.
+v 1
+--
+v 1
+-- Bugs and unexpected behaviour in (re-)indentation may be documented here.
+v 1
+module Indentation where
+v 1 2
+
+1 v
+-- A basic `do` block using virtual indentation to suggest the whitespace
+1 v 2
+basic_do = do
+2 1 v 3
+ -- TODO do should have virtual indentation of 0, so this is at 2
+2 1 v 3
+ foo = blah blah blah
+1 v 2 3
+ -- TODO should suggest that bar is a binding
+v 2 3 1 4
+ bar = blah blah
+2 3 4 1 5v
+ blah -- manual continuation, should be 1st alt TODO
+1 2 v 3 4
+ blah -- continue what we were doing, should be the SMIE rule
+1 2 v 3 4
+
+1 2 v
+-- TODO `do` with manual layout
+1 2 v 3
+-- TODO nested `do`
+1 2 v 3
+
+1 2 v
+
+1 2 v
+-- TODO coproduct definitions, the | should align with =
+1 2 v
+
+1 2 v
+-- TODO lists
\ No newline at end of file
- [nongnu] elpa/haskell-tng-mode 7a8f714 139/385: indent back to the same level of `do', (continued)
- [nongnu] elpa/haskell-tng-mode 7a8f714 139/385: indent back to the same level of `do', ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ac55d33 134/385: interactive SMIE debugging, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6ade588 195/385: key bindings in compilation mode, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 144cabf 202/385: fix test assertions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 04ebec6 204/385: third party integrations, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode aa9bbb7 216/385: add (broken) test coverage for consyms, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5f423b9 100/385: some alts in the indentation test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 50b53d3 114/385: tng compilation tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 36ece6d 117/385: low hanging fruit, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 489e4c9 124/385: document explicit export fontification bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 91a1d08 136/385: creating small scenarios for indentation specs,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode ec39a64 133/385: improvements to indentation alts and compilation info, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f67557b 142/385: fix a layout corner case, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 20f4091 152/385: support dollars in indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0d5e020 151/385: support LambdaCase, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 08a3946 163/385: records indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3449847 162/385: no need to special-case dollar, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8b5a4d4 177/385: improve indentation tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cb801b4 015/385: moar multiline type search, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode de48840 030/385: multiline import anchors, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5c50be0 044/385: remove redundant TODOs, ELPA Syncer, 2021/10/06