[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 32175c0 158/385: thots
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 32175c0 158/385: thots |
Date: |
Tue, 5 Oct 2021 23:59:21 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 32175c0a4a7103d2a0a7103df1590d3723dfea65
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
thots
---
haskell-tng-font-lock.el | 2 ++
haskell-tng-smie.el | 62 +++++++++++++++++++++--------------------
test/haskell-tng-indent-test.el | 7 +++--
3 files changed, 38 insertions(+), 33 deletions(-)
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index 4f571be..6f6950f 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -47,6 +47,8 @@
"Haskell reserved names and operators."
:group 'haskell-tng:faces)
+;; TODO module when defining and importing should be different than when using
+;; (which should make the text more subtle rather than highlighted)
(defface haskell-tng:module
'((t :inherit font-lock-variable-name-face :weight bold))
"Haskell modules (packages)."
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 8b2f647..9ffc506 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -138,30 +138,17 @@ information, to aid in the creation of new rules."
;; `:after' and a `:before' for `do' which may be at column 20 but virtually at
;; column 0.
(defun haskell-tng-smie:rules (method arg)
- ;; WORKAROUND https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36434
- ;;
- ;; smie-rule-next-p needs smie--after to be defined.
- ;; smile-rule-parent-p doesn't work
- ;;
- ;; TODO fix the SMIE bug
- (defvar smie--after)
- (defvar smie--parent)
-
(when haskell-tng-smie:debug
- (let ((sym (symbol-at-point)))
- (with-current-buffer haskell-tng-smie:debug
- (insert (format "RULES: %S %S %S\n" method arg sym))))
- (unless (boundp 'smie--parent)
- (setq smie--parent nil))
- (when-let (parent (caddr (smie-indent--parent)))
- (with-current-buffer haskell-tng-smie:debug
- (insert (format " PARENT: %S\n" parent))))
- (when-let (grand (caddr (smie-indent--grandparent)))
- (with-current-buffer haskell-tng-smie:debug
- (insert (format " GRAND: %S\n" grand))))
- (when-let (prev (caddr (smie-indent--prev-line-start)))
+ (let ((sym (symbol-at-point))
+ (parent (and (boundp 'smie--parent)
+ (caddr (smie-indent--parent))))
+ (grand (and (boundp 'smie--parent)
+ (caddr (smie-indent--grandparent)))))
(with-current-buffer haskell-tng-smie:debug
- (insert (format " PREV: %S\n" prev)))))
+ (insert
+ (format
+ "RULES: %S %S %S\n PARENT: %S\n GRAND: %S\n"
+ method arg sym parent grand)))))
(pcase method
@@ -170,9 +157,24 @@ information, to aid in the creation of new rules."
((or 'args 'basic) 0)
('empty-line-token
- ;; even if these are set, they can be wrong
+ ;; WORKAROUND https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36434
+ ;;
+ ;; smie-rule-* are not designed be used in :elem because there is no
+ ;; clear current token. We force their use to mean relative to the
+ ;; current empty line, prior to knowing what the expected value should
+ ;; be.
+ (defvar smie--after)
(setq smie--after (point))
+ (defvar smie--parent)
(setq smie--parent nil)
+ (when haskell-tng-smie:debug
+ (let ((parent (caddr (smie-indent--parent)))
+ (grand (caddr (smie-indent--grandparent))))
+ (with-current-buffer haskell-tng-smie:debug
+ (insert
+ (format
+ " PARENT': %S\n GRAND': %S\n"
+ parent grand)))))
(cond
((or (smie-rule-parent-p "|")
@@ -181,13 +183,6 @@ information, to aid in the creation of new rules."
(smie-rule-prev-line-start-p "|"))
"|")
- ((save-excursion
- (forward-comment (point-max))
- (eobp))
- ;; this happens when we're at the end of the buffer. Must use
- ;; heuristics before we get to this point.
- ";")
-
((smie-rule-next-p ";" "}")
;; TODO semantic indentation
;;
@@ -196,6 +191,13 @@ information, to aid in the creation of new rules."
;; we should be able to infer if the user wants to terminate ; or
;; continue "" the current line.
";")
+
+ ((save-excursion
+ (forward-comment (point-max))
+ (eobp))
+ ;; this happens when we're at the end of the buffer. Must use
+ ;; heuristics before we get to this point.
+ ";")
))))
(:list-intro
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index 8b10fca..e1caec8 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -14,10 +14,11 @@
;; FIXME implement more indentation rules
;;
-;; TODO lists, records, tuples
-;; TODO long type signatures vs definitions
+;; TODO lists
+;; TODO tuples
+;; TODO records
+;; TODO multiline type signatures
;; TODO if/then/else
-;; TODO following opening bracket in a record defn, shouldn't indent so much
;; Three indentation regression tests are possible:
;;
- [nongnu] elpa/haskell-tng-mode cf22f3a 138/385: simplify indentation testing, (continued)
- [nongnu] elpa/haskell-tng-mode cf22f3a 138/385: simplify indentation testing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a0f777e 166/385: Revert "duplicate ; tokens to be used as terminators", ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2320b89 167/385: alternative to smie-rules-* in :elem and :list-intro, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 60d8c20 149/385: indent "case of", ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7f9afd2 159/385: list indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6e70344 165/385: duplicate ; tokens to be used as terminators, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ab5252b 169/385: rearrange alts, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e1aba33 168/385: fix a layout bug in lists and records, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2c6c772 150/385: better WLDO indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3f54673 155/385: don't fontify toplevel, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 32175c0 158/385: thots,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 8c2e3f7 157/385: better symid indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bc5c827 160/385: tuple indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e0acc42 156/385: better tasty error detection, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c211672 174/385: indentation for hanging type definition, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ef7f335 171/385: note stack compatibility, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 86bcd98 175/385: constraint indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e1c0f0a 179/385: allow indentation option to be tested, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1cceb64 182/385: cleaner tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b1122e4 188/385: allow users to use unsupported build tools, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bd4ff6f 192/385: standardise on naming convention:, ELPA Syncer, 2021/10/06