[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 46abfc4 035/385: getting closer to good t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 46abfc4 035/385: getting closer to good types in imports |
Date: |
Tue, 5 Oct 2021 23:58:56 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 46abfc46bb78a8cad3948bb0e075cf6ad0b5a374
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
getting closer to good types in imports
---
haskell-tng-font-lock.el | 49 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 9 deletions(-)
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index 2ea6e58..9e04350 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -10,11 +10,11 @@
;;
;; It is not possible to be completely accurate for all language extensions.
;; For example TypeOperators and TypeApplications allow constructs that can
-;; only be disambiguated by semantic rules, e.g. having access to the symbol
-;; table from the imported module.
+;; only be disambiguated by semantic rules via the symbol table from the
+;; imported modules.
;;
-;; If an extension has been considered, but not implemented, the marker EXT
-;; will appear with the extension name near the relevant lines of code.
+;; If an extension has been considered, but not implemented, the marker EXT:
+;; will appear with the extension name.
;;
;; The detection of complex language constructs is not considered, for
;; simplicity and speed. Maybe one day we could use
@@ -155,7 +155,16 @@
(2 'haskell-tng:module)
(3 'haskell-tng:keyword)
(4 'haskell-tng:keyword))
- ;; TODO constructors vs types in import brackets
+ (,(rx word-start "as" (+ space) (group (+ word) word-end))
+ (haskell-tng:font:multiline:pre) nil
+ (1 'haskell-tng:module))
+ ;; (haskell-tng:font:paren-search-forward
+ ;; (haskell-tng:font:multiline:pre 1 0) nil
+ ;; (0 'haskell-tng:constructor))
+ ;; TODO FIXME the paren in group 1
+ ;; (,(rx-to-string `(: word-start ,conid word-end))
+ ;; (haskell-tng:font:multiline:pre 1) nil
+ ;; (0 'haskell-tng:type))
;; EXT:ExplicitNamespaces
)
@@ -177,11 +186,30 @@
)))
-(defun haskell-tng:font:multiline:pre ()
- "Multiline MATCH-ANCHORED forms must move point and return LIMIT."
- (goto-char (match-beginning 0))
+(defun haskell-tng:font:multiline:pre (&optional group jump)
+ "MATCH-ANCHORED moving point to group beginning (plus JUMP) and extend
LIMIT."
+ (setq group (or group 0))
+ ;; TODO: does a group inside an opt give nil? That would be better
+ (when (match-string group)
+ (when (< 0 group)
+ (message "MATCHED GROUP %s AS %s"
+ group
+ (match-string group)))
+ (goto-char (match-beginning group))
+ (when jump
+ (forward-char jump)
+ (message "JUMPING FOR %s TO %s"
+ (match-string group)
+ (buffer-substring-no-properties (point) (+ 10 (point))))))
(match-end 0))
+(defun haskell-tng:font:paren-search-forward (limit)
+ "Match the contents of balanced parenthesis."
+ (when (re-search-forward "(" limit t)
+ (when-let (close (haskell-tng:paren-close))
+ (when (<= close limit)
+ (re-search-forward (rx (+ anything)) close t)))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Here are `function' matchers for use in `font-lock-keywords' and
;; `font-lock-extend-region-functions' procedures for extending the region.
@@ -283,7 +311,10 @@ succeeds and may further restrict the FIND search limit."
(haskell-tng:font:multiline import
(rx line-start "import" word-end)
- (rx line-start "import" word-end (group (+ anything)))
+ (rx line-start "import" word-end
+ (+? anything)
+ (opt (group "(" (+ anything)))
+ (* anything))
haskell-tng:indent-close)
(haskell-tng:font:multiline module
- [nongnu] elpa/haskell-tng-mode 95ab59c 014/385: multiline type matching seems to work, (continued)
- [nongnu] elpa/haskell-tng-mode 95ab59c 014/385: multiline type matching seems to work, ELPA Syncer, 2021/10/05
- [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 <=
- [nongnu] elpa/haskell-tng-mode c3d4e70 031/385: don't reinvent standard tools, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 7c2dedb 043/385: use pyenv when running cask, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 2f04c01 051/385: starting work on semicolon inference, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode a4a664b 056/385: layout inference, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode d33d146 060/385: [ci skip] start to refactor layout out of lexer, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 12c7148 040/385: leave fontification in comments and strings, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 61f4c09 062/385: [ci skip] unify the testing approach, ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 138aca0 089/385: typelevel lists are harder than I thought..., ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode f5961e6 099/385: indentation cycles are really complicated..., ELPA Syncer, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 6e4849c 112/385: some compilation test cases, ELPA Syncer, 2021/10/05