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

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

[nongnu] elpa/haskell-tng-mode 489e4c9 124/385: document explicit export


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 489e4c9 124/385: document explicit export fontification bug
Date: Tue, 5 Oct 2021 23:59:14 -0400 (EDT)

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

    document explicit export fontification bug
---
 haskell-tng-font-lock.el         | 22 ++++++++++++++++++----
 haskell-tng-rx.el                |  4 ++++
 haskell-tng-syntax.el            |  3 ++-
 test/src/medley.hs               |  2 +-
 test/src/medley.hs.faceup        |  2 +-
 test/src/medley.hs.insert.indent |  4 ++--
 test/src/medley.hs.layout        |  2 +-
 test/src/medley.hs.syntax        |  2 +-
 8 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index 8dd775f..ddc785c 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -141,7 +141,9 @@
        ;; EXT:ExplicitNamespaces
        )
 
-      ;; TODO module defn with explicit exports have wrong face (Constructor) 
for final part
+      ;; FIXME module defn with explicit exports has wrong face (Constructor)
+      ;; for final part of the module name when the closing paren is the first
+      ;; character on the line.
       (haskell-tng:font:module:keyword
        (,(rx-to-string `(: word-start "module" word-end (+ space)
                            (group symbol-start (* ,conid ".") ,conid 
symbol-end)))
@@ -175,16 +177,20 @@
 
       )))
 
-(defun haskell-tng:font:multiline:anchor-rewind (&optional group jump)
+(defun haskell-tng:font:multiline:anchor-rewind (&optional group jump end)
   "MATCH-ANCHORED moving point to group beginning (plus JUMP) and declaring 
LIMIT.
 Can be used as PRE-FORM or POST-FORM, allowing anchors to
 refontify the previously matched region.
 
+If END is non-nil, use group end (plus JUMP).
+
 If there is no match for GROUP, move to the end of the line, canceling this 
ANCHOR."
   (setq group (or group 0))
   (if (not (match-string group))
       (end-of-line)
-    (goto-char (match-beginning group))
+    (goto-char (if end
+                   (match-end group)
+                 (match-beginning group)))
     (when jump
       (forward-char jump))
     (match-end 0)))
@@ -193,6 +199,7 @@ If there is no match for GROUP, move to the end of the 
line, canceling this ANCH
   "Finds paren blocks of constructors when in an import statement.
 Some complexity to avoid matching on operators."
   (when (re-search-forward
+         ;; TODO word not just lower should be ok
          (rx (any lower) (* space) "(")
          limit t)
     (let ((open (point)))
@@ -270,6 +277,9 @@ succeeds and may further restrict the FIND search limit."
              ,(finder 'limit)))
          (add-to-list 'haskell-tng:extend-region-functions ',extend t)))))
 
+;; TODO if the beginning of a multiline pattern goes off the screen, e.g. for a
+;; large type definition, we can lose the fontification. This seems to be a bug
+;; in Emacs.
 (haskell-tng:font:multiline explicit-type
                             (rx symbol-start "::" symbol-end)
                             (rx symbol-start "::" symbol-end (group (+ 
anything)))
@@ -311,9 +321,13 @@ succeeds and may further restrict the FIND search limit."
 
 (haskell-tng:font:multiline module
                             (rx line-start "module" word-end)
+                            ;; TODO would be a good idea to capture the FQN 
name
+                            ;; so that anchors can use END in the PRE-FORM to
+                            ;; avoid overfitting (e.g. explicit constructors
+                            ;; everywhere).
                             (rx line-start "module" word-end (group (+ 
anything))
                                 word-start "where" word-end)
-                            haskell-tng:indent-close)
+                            haskell-tng:indent-close) ;; FIXME is the 
indent-close the culprit?
 
 (provide 'haskell-tng-font-lock)
 ;;; haskell-tng-font-lock.el ends here
diff --git a/haskell-tng-rx.el b/haskell-tng-rx.el
index 2ca0858..eb4ab74 100644
--- a/haskell-tng-rx.el
+++ b/haskell-tng-rx.el
@@ -55,6 +55,10 @@ give false positives." `(|
 
 (defconst haskell-tng:rx:toplevel
   ;; TODO multi-definitions, e.g. Servant's :<|>
+  ;;
+  ;; Lexically and grammatically there is nothing special about top-level
+  ;; definitions, since they are just WLDOs for the module's `where'. But they
+  ;; are so common in practice that it's useful to special case them.
   `(: line-start (group (| ,haskell-tng:rx:varid
                            (: "(" (+? (syntax symbol)) ")")))
       symbol-end))
diff --git a/haskell-tng-syntax.el b/haskell-tng-syntax.el
index d28d9bf..697520b 100644
--- a/haskell-tng-syntax.el
+++ b/haskell-tng-syntax.el
@@ -47,7 +47,8 @@
 
     ;; TODO consider using categories more heavily, which would involve doing
     ;; lexing here. It would make the fontification regexps simpler and faster,
-    ;; and would be reused by the SMIE lexer.
+    ;; and would be reused by the SMIE lexer. We might not need zero-length
+    ;; matchers because greedy matching will be much simpler.
 
     ;; some special (treated like punctuation)
     (--each (string-to-list ",;@")
diff --git a/test/src/medley.hs b/test/src/medley.hs
index 534bbae..e0f3b50 100644
--- a/test/src/medley.hs
+++ b/test/src/medley.hs
@@ -7,7 +7,7 @@ module Foo.Bar.Main
   -- * Operations
   , getFooByBar, getWibbleByWobble
   , module Bloo.Foo
-  ) where
+) where
 
 import           Control.Applicative (many, optional, pure, (<*>), (<|>))
 import           Data.Foldable       (traverse_)
diff --git a/test/src/medley.hs.faceup b/test/src/medley.hs.faceup
index 9b34d03..2dc53af 100644
--- a/test/src/medley.hs.faceup
+++ b/test/src/medley.hs.faceup
@@ -7,7 +7,7 @@
   «m:-- »«x:* Operations
 »  «:haskell-tng:keyword:,» getFooByBar«:haskell-tng:keyword:,» 
getWibbleByWobble
   «:haskell-tng:keyword:,» «:haskell-tng:keyword:module» 
«:haskell-tng:module:Bloo.Foo»
-  «:haskell-tng:keyword:)» «:haskell-tng:keyword:where»
+«:haskell-tng:keyword:)» «:haskell-tng:keyword:where»
 
 «:haskell-tng:keyword:import»           
«:haskell-tng:module:Control.Applicative» 
«:haskell-tng:keyword:(»many«:haskell-tng:keyword:,» 
optional«:haskell-tng:keyword:,» pure«:haskell-tng:keyword:,» 
«:haskell-tng:keyword:(»<*>«:haskell-tng:keyword:),» 
«:haskell-tng:keyword:(»<|>«:haskell-tng:keyword:))»
 «:haskell-tng:keyword:import»           «:haskell-tng:module:Data.Foldable»    
   «:haskell-tng:keyword:(»traverse_«:haskell-tng:keyword:)»
diff --git a/test/src/medley.hs.insert.indent b/test/src/medley.hs.insert.indent
index 62d2a89..7d2d4d1 100644
--- a/test/src/medley.hs.insert.indent
+++ b/test/src/medley.hs.insert.indent
@@ -15,8 +15,8 @@ module Foo.Bar.Main
   , getFooByBar, getWibbleByWobble
 2 1                v
   , module Bloo.Foo
-2 1               v
-  ) where
+1 2               v
+) where
 v 1
 
 v 1
diff --git a/test/src/medley.hs.layout b/test/src/medley.hs.layout
index 4027728..3cfca1a 100644
--- a/test/src/medley.hs.layout
+++ b/test/src/medley.hs.layout
@@ -7,7 +7,7 @@ module Foo.Bar.Main
   -- * Operations
   , getFooByBar, getWibbleByWobble
   , module Bloo.Foo
-  ) where
+) where
 
 {import           Control.Applicative (many, optional, pure, (<*>), (<|>))
 ;import           Data.Foldable       (traverse_)
diff --git a/test/src/medley.hs.syntax b/test/src/medley.hs.syntax
index 67fd841..faea55c 100644
--- a/test/src/medley.hs.syntax
+++ b/test/src/medley.hs.syntax
@@ -7,7 +7,7 @@ wwwwww www.www.wwww>
   __ _ wwwwwwwwww>
   . wwwwwwwwwww. wwwwwwwwwwwwwwwww>
   . wwwwww wwww.www>
-  ) wwwww>
+) wwwww>
 >
 wwwwww           wwwwwww.wwwwwwwwwww (wwww. wwwwwwww. wwww. (___). (___))>
 wwwwww           wwww.wwwwwwww       (wwwwwwwww)>



reply via email to

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