[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 2f04c01 051/385: starting work on semicol
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 2f04c01 051/385: starting work on semicolon inference |
Date: |
Tue, 5 Oct 2021 23:59:00 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 2f04c01f5b43bce2978368e6e4da803e69b713ba
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
starting work on semicolon inference
---
haskell-tng-smie.el | 53 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 18 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 95db8f8..576a783 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -38,26 +38,43 @@
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Lexer
(defun haskell-tng-smie:forward-token ()
(interactive) ;; for testing
- (forward-comment (point-max))
- (unless (eobp)
- (let ((case-fold-search nil)
- (syntax (char-syntax (char-after))))
- (cond
- ;; TODO detect newlines with significant whitespace
+ (let ((start (point)))
+ (forward-comment (point-max))
+ (unless (eobp)
+ (let ((start-line (line-number-at-pos start))
+ (this-line (line-number-at-pos))
+ (case-fold-search nil)
+ (syntax (char-syntax (char-after))))
+ (cond
+ ;; TODO brace inference
+ ((and
+ (not (eq start-line this-line))
+ (<=
+ (haskell-tng-smie:indentation-level (point))
+ (haskell-tng-smie:indentation-level start))
+ ";"))
- ;; parens
- ((member syntax '(?\( ?\) ?\" ?$)) nil)
+ ;; parens
+ ((member syntax '(?\( ?\) ?\" ?$)) nil)
- ;; regexps
- ((or
- ;; known identifiers
- (looking-at haskell-tng:regexp:reserved)
- ;; symbols
- (looking-at (rx (+ (| (syntax word) (syntax symbol)))))
- ;; whatever the current syntax class is
- (looking-at (rx-to-string `(+ (syntax ,syntax)))))
- (goto-char (match-end 0))
- (match-string-no-properties 0))))))
+ ;; regexps
+ ((or
+ ;; known identifiers
+ (looking-at haskell-tng:regexp:reserved)
+ ;; symbols
+ (looking-at (rx (+ (| (syntax word) (syntax symbol)))))
+ ;; whatever the current syntax class is
+ (looking-at (rx-to-string `(+ (syntax ,syntax)))))
+ (goto-char (match-end 0))
+ (match-string-no-properties 0)))))))
+
+(defun haskell-tng-smie:indentation-level (p)
+ "Calculates the indentation level of the most inner part of the given
point's line."
+ ;; FIXME this is a hack for now, look for `let', `do' and friends according
to
+ ;; the Haskell2010 report.
+ (save-excursion
+ (goto-char p)
+ (current-indentation)))
;; TODO a haskell grammar
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Grammar
- [nongnu] elpa/haskell-tng-mode 111396f 004/385: converted many font-face rules to the rx DSL, (continued)
- [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
- [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 <=
- [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
- [nongnu] elpa/haskell-tng-mode cb1d2db 106/385: newline shouldn't trigger indent cycling, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f342041 118/385: better SMIE blinkers, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 249f507 121/385: support whitespace gaps, ELPA Syncer, 2021/10/06