[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode d9a12e1 151/192: Fontifies function declarations
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode d9a12e1 151/192: Fontifies function declarations |
Date: |
Sun, 29 Aug 2021 11:02:08 -0400 (EDT) |
branch: elpa/dart-mode
commit d9a12e167eb1ad3fd106700e7c92399aa0208e8f
Author: Brady Trainor <mail@bradyt.com>
Commit: Brady Trainor <mail@bradyt.com>
Fontifies function declarations
This commit adds a function to match function declarations.
We search forward for a lower camel case identifier followed by an
opening paren, then jump to closing paren, and check for either an async
keyword, or an opening of a block statement, or an arrow.
The docstring of `font-lock-keywords` specifies how a matcher function
must work.
Function takes an argument `limit`, searches from point, and if no
match found returns nil, otherwise, sets match data, sets point for
next search, and returns non-nil.
---
dart-mode.el | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/dart-mode.el b/dart-mode.el
index 575f95e..edea013 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -407,6 +407,25 @@ Returns nil if `dart-sdk-path' is nil."
(setq dart--types-re (rx (eval (dart--identifier 'upper))))
+(defun dart--function-declaration-func (limit)
+ (catch 'result
+ (let (beg end)
+ (while (re-search-forward
+ (rx (group (eval (dart--identifier 'lower))) ?\() limit t)
+ (setq beg (match-beginning 1))
+ (setq end (match-end 1))
+ (condition-case nil
+ (progn
+ (up-list)
+ (when (looking-at (rx (one-or-more space)
+ (or "async" "async*" "sync*" "{" "=>")))
+ (set-match-data (list beg end))
+ (goto-char end)
+ (throw 'result t)))
+ (scan-error nil))
+ (goto-char end))
+ (throw 'result nil))))
+
(setq dart-font-lock-defaults
`((,dart--async-keywords-re
,(regexp-opt dart--keywords 'words)
@@ -416,7 +435,8 @@ Returns nil if `dart-sdk-path' is nil."
(,dart--number-re . (1 font-lock-constant-face))
(,dart--metadata-re . font-lock-constant-face)
(,(regexp-opt dart--types 'words) . font-lock-type-face)
- (,dart--types-re . font-lock-type-face))))
+ (,dart--types-re . font-lock-type-face)
+ (dart--function-declaration-func .
font-lock-function-name-face))))
(defun dart-fontify-region (beg end)
"Use fontify the region between BEG and END as Dart.
- [nongnu] elpa/dart-mode 25a0b8a 128/192: Add tests for dart-format, (continued)
- [nongnu] elpa/dart-mode 25a0b8a 128/192: Add tests for dart-format, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d1a0c5e 103/192: Fall back to normal expansion, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 613b311 111/192: Stop using lexical let, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 950d3a8 133/192: Add emacs versions 24.3 and snapshot, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a4126bd 121/192: Allow s 1.10, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 52034c7 110/192: Add a dart--get helper to make it easier to use JSON, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f3a7c7b 122/192: Properly tell flycheck when there are no errors, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1153c53 134/192: Add ert-runner, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 2a95005 159/192: Fix typo in README, regarding M-/ fallback, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c30eaa9 140/192: Specify path to the dart-sdk inside of flutter, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d9a12e1 151/192: Fontifies function declarations,
ELPA Syncer <=
- [nongnu] elpa/dart-mode aa628c9 138/192: Remove deprecated analysis server option, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 5d0a7cd 139/192: Use dart-sdk-path to find dartfmt., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1879cb8 145/192: Update README for providing diff to dart-format on Windows, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 21abd77 152/192: Fontifies declared identifiers, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode ac14859 147/192: Normalize paths for dartanalyzer on Windows, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9d72469 169/192: Don't set variables globally, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 591b6fe 170/192: Improve handling of strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f20f895 164/192: Move docs from README to Wiki, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 36fe2ce 166/192: Fontify identifiers after multi-nested types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 57767bb 157/192: Makes current indentation logic more usable, ELPA Syncer, 2021/08/29