[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 85272cb 029/385: fixup! fixup! improve th
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 85272cb 029/385: fixup! fixup! improve the multiline font macro |
Date: |
Tue, 5 Oct 2021 23:58:55 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 85272cb98cddeaaab673430d32ae7de55995d277
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
fixup! fixup! improve the multiline font macro
---
haskell-tng-font-lock.el | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index 790ef30..2024919 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -182,40 +182,41 @@ Automatically populated by `haskell-tng:font:multiline'")
(defmacro haskell-tng:font:multiline (name trigger find &rest limiters)
"Defines `font-lock-keywords' / `font-lock-extend-region-functions' entries.
-TRIGGER is a referentially transparent form that produces a regexp.
+TRIGGER and FIND are forms that produce a regexp, which is
+memoised by this macro. FIND typically begins by repeating
+TRIGGER.
-FIND is a form that must behave the same as `re-search-forward',
-i.e. setting the match groups and placing point after the match.
-The variable `limit' is dynamically bound within this form.
-
-The generated `haskell-tng:PREFIX-extend' searches backwards from
-the end of the proposed region for TRIGGER. If a match is found,
-FIND is called with a limit until the end of the buffer, which
-may extend the region.
+The generated `haskell-tng:PREFIX-extend' searches backwards for
+TRIGGER from the end of the region. If a match is found, FIND is
+called with no limit, which will extend the region if there is a
+match.
The generated `haskell-tng:PREFIX-keyword' searches forward for
-TRIGGER within the fontification limit. The point is reset to the
-beginning of the TRIGGER's match and FIND is evaluated.
+TRIGGER, limited to the fontification region. The point is reset
+to the beginning of the TRIGGER's match and FIND is then
+searched. This function is ideal for inclusion in the mode's
+`font-lock-keywords' list and behaves like a regexp.
-The LIMITERS are function names that will be called when the
-TRIGGER succeeds and may return a more restrictive limit than the
-defaults for FIND."
+The LIMITERS are function names that are called if the TRIGGER
+succeeds and may further restrict the FIND search limit."
(declare (indent defun))
(let* ((sname (concat "haskell-tng:font:" (symbol-name name)))
- (regexp (intern (concat sname ":trigger")))
+ (regexp-1 (intern (concat sname ":trigger")))
+ (regexp-2 (intern (concat sname ":matcher")))
(keyword (intern (concat sname ":keyword")))
(extend (intern (concat sname ":extend"))))
(cl-flet
((finder (lim)
`(re-search-forward
- ,find
+ ,regexp-2
(-min (cons ,lim (-non-nil (-map 'funcall ',limiters))))
t)))
`(progn
- (defconst ,regexp ,trigger)
+ (defconst ,regexp-1 ,trigger)
+ (defconst ,regexp-2 ,find)
(defun ,extend ()
(goto-char font-lock-end)
- (when (re-search-backward ,regexp font-lock-beg t)
+ (when (re-search-backward ,regexp-1 font-lock-beg t)
,(finder '(point-max))
(when (< font-lock-end (point))
(when haskell-tng:font:debug-extend
@@ -223,7 +224,7 @@ defaults for FIND."
(setq font-lock-end (point))
nil)))
(defun ,keyword (limit)
- (when (re-search-forward ,regexp limit t)
+ (when (re-search-forward ,regexp-1 limit t)
(goto-char (match-beginning 0))
,(finder 'limit)))
(add-to-list 'haskell-tng:extend-region-functions ',extend t)))))
- [nongnu] elpa/haskell-tng-mode f99ca77 012/385: fixup! expand parens, (continued)
- [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, 2021/10/05
- [nongnu] elpa/haskell-tng-mode 85272cb 029/385: fixup! fixup! improve the multiline font macro,
ELPA Syncer <=
- [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
- [nongnu] elpa/haskell-tng-mode c3d4e70 031/385: don't reinvent standard tools, ELPA Syncer, 2021/10/05