[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 95ab59c 014/385: multiline type matching
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 95ab59c 014/385: multiline type matching seems to work |
Date: |
Tue, 5 Oct 2021 23:58:52 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 95ab59c0a0559e41d07e5bf07411b08d9d8ce61f
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
multiline type matching seems to work
---
haskell-tng-font-lock.el | 67 ++++++++++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index d2116af..9f1fe88 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -67,7 +67,7 @@
(defconst haskell-tng:conid '(: upper (* wordchar)))
(defconst haskell-tng:qual `(: (+ (: ,haskell-tng:conid (char ?.)))))
-(defconst haskell-tng:consym '(: ":" (+ (syntax symbol)))) ;; TODO exclude ::
+(defconst haskell-tng:consym '(: ":" (+ (syntax symbol)))) ;; TODO exclude ::,
limited symbol set
(defconst haskell-tng:toplevel
`(: line-start (group (| (: (any lower ?_) (* wordchar))
(: "(" (+? (syntax symbol)) ")")))
@@ -205,42 +205,47 @@ Ensures that multiline type signatures are opened."
font-lock-end t)
(re-search-backward
(rx symbol-start "::" symbol-end)
- (point-min) t)
- (let ((beg (match-beginning 0)))
- (haskell-tng:type-end)
- (when (< font-lock-beg (point))
- (haskell-tng:debug-extend (point))
- (setq font-lock-end (point)))))))
+ (point-min) t))
+ (goto-char (match-beginning 0))
+ (let ((beg (point)))
+ (haskell-tng:type-end)
+ (when (< font-lock-beg (point))
+ (haskell-tng:debug-extend beg)
+ (setq font-lock-beg beg)
+ (when (< font-lock-end (point))
+ (haskell-tng:debug-extend (point))
+ (setq font-lock-end (point))))))
+ nil
+ )
+
+;; note that \n has syntax `comment-end'
+(defconst haskell-tng:newline
+ '(| (syntax comment-end)
+ (: symbol-start
+ "--"
+ (+ (not (syntax comment-end)))
+ (+ (syntax comment-end))))
+ "Newline or line comment.")
+
+;; TODO literal types and generic lists ... eek!
+(defconst haskell-tng:type
+ (let ((typepart `(| (+ (| ?\( ?\)))
+ (+ (| lower ?_))
+ (: (opt ,haskell-tng:qual)
+ (| "::" ,haskell-tng:conid ,haskell-tng:consym)))))
+ `(: (opt ,haskell-tng:newline) (+ (| space ,typepart))
+ (* (opt ,haskell-tng:newline (+ space)) "->" (+ (| space ,typepart)))))
+ "An explicit type")
(defun haskell-tng:type-end ()
"Move to the end of this type signature."
- ;; TODO literal types and generic lists ... eek!
- (let ((conid haskell-tng:conid)
- (qual haskell-tng:qual)
- (consym haskell-tng:consym)
- (toplevel haskell-tng:toplevel))
+ (interactive)
+ (let* ((case-fold-search nil))
(re-search-forward
- ;; TODO cache this regex
- (rx-to-string `(: point
- (| (+ (| space (syntax comment-end)))
- (: symbol-start
- "--" ;; TODO comment-delimiter
- (+? anything)
- (+ (syntax comment-end)))
- (any ?\( ?\))
- (: symbol-start
- (| "->"
- (+ lower ?_)
- (: (opt ,qual) (| ,conid ,consym)))
- symbol-end))))
+ (rx-to-string `(: point "::" (* space) ,haskell-tng:type))
(point-max) t)))
-;; FIXME: this is matching fooBar
-;; (re-search-forward
-;; (rx (: point
-;; symbol-start
-;; upper (* wordchar)
-;; symbol-end)))
+;; also consider multiline data / newtype / type definitions to the equals sign
(defun haskell-tng:extend-type-close ()
"For use in `font-lock-extend-region-functions'.
- [nongnu] elpa/haskell-tng-mode 52f0cb9 011/385: expand parens, (continued)
- [nongnu] elpa/haskell-tng-mode 52f0cb9 011/385: expand parens, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode f99ca77 012/385: fixup! expand parens, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode bd8f905 016/385: almost there, regions not being expanded, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode db064be 024/385: dank macro for font-lock extends/keyword, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 639fc6c 018/385: multiline types and font-lock-multiline, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode cc739ad 020/385: multiline topdecl type sections, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 595bd44 034/385: type families, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 77d6ec5 019/385: cleaned up multiline explicit types, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode fa32b46 037/385: finally caught the bug in anchor pre/post resetting, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode f2ce737 038/385: neutral, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 95ab59c 014/385: multiline type matching seems to work,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 85272cb 029/385: fixup! fixup! improve the multiline font macro, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 00f7d84 002/385: simplify names, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 111396f 004/385: converted many font-face rules to the rx DSL, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 6f8258c 009/385: thinking about multiline, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 5536d23 025/385: all font locks use the new macro, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode a7a90ea 028/385: fixup! improve the multiline font macro, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode b9bc414 027/385: improve the multiline font macro, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode ea77bb2 017/385: fixup! almost there, regions not being expanded, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 2b82b2f 022/385: fixup! fixup! multiline topdecl type sections, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 46abfc4 035/385: getting closer to good types in imports, ELPA Syncer, 2021/10/05