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

[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:
 ;;



reply via email to

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