[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode a0b73b2 177/217: add string interpolation (#116
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode a0b73b2 177/217: add string interpolation (#116) |
Date: |
Sun, 29 Aug 2021 11:31:07 -0400 (EDT) |
branch: elpa/scala-mode
commit a0b73b25377f5aedf50abe198d6b6111310735be
Author: Brian Malehorn <bmalehorn@users.noreply.github.com>
Commit: Sam Halliday <sam.halliday@gmail.com>
add string interpolation (#116)
Before, scala-mode wouldn't highlight formatter variables, making them a
bit difficult to pick out:
val s = s"foo $bar"
Now, they're given a different color (`font-lock-variable-name-face`)
than the surrounding string.
Text inside `${}` will be highlighted homogenously (rather than
recursively highlighted as constants, keywords, etc.). This is what
`ruby-mode` does and it's definitely good enough.
Closes #60.
---
scala-mode-fontlock.el | 2 ++
scala-mode-syntax.el | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/scala-mode-fontlock.el b/scala-mode-fontlock.el
index 7c0aa7d..e919353 100644
--- a/scala-mode-fontlock.el
+++ b/scala-mode-fontlock.el
@@ -487,6 +487,8 @@ Does not continue past limit.
(scala-font-lock:mark-floatingPointLiteral . font-lock-constant-face)
(scala-font-lock:mark-integerLiteral . font-lock-constant-face)
+ (scala-syntax:interpolation-matcher 0 font-lock-variable-name-face t)
+
))
(defun scala-font-lock:syntactic-face-function (state)
diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el
index 6eb9312..c0b6277 100644
--- a/scala-mode-syntax.el
+++ b/scala-mode-syntax.el
@@ -155,6 +155,29 @@
"\\|" scala-syntax:symbolLiteral-re
"\\|" "null" "\\)"))
+(defconst scala-syntax:interpolation-re
+ (concat "\\(" "\\$" scala-syntax:id-re "\\|" "\\${[^}\n\\\\]*}" "\\)"))
+
+(defun scala-syntax:interpolation-matcher (end)
+ (let* ((pos nil)
+ (syntax nil)
+ (str-start nil)
+ (char-before-str nil))
+ (while (and
+ (setq pos (re-search-forward scala-syntax:interpolation-re end t))
+ (setq syntax (syntax-ppss pos))
+ (if (nth 3 syntax) ;; "is string"
+ (progn
+ (setq str-start (nth 8 syntax))
+ ;; s"foo"
+ ;; ^-- `char-before-str', must be identifier
+ (setq char-before-str (char-after (1- str-start)))
+ ;; break if match
+ (null (string-match-p
+ scala-syntax:id-re (string char-before-str))))
+ t))) ;; keep going
+ pos))
+
;; Paths (Chapter 3.1)
;; emacs has a problem with these regex, don't use them
;; (defconst scala-syntax:classQualifier-re (concat "[[]" scala-syntax:id-re
"[]]"))
- [nongnu] elpa/scala-mode defa2af 098/217: pkg.el cleanup, (continued)
- [nongnu] elpa/scala-mode defa2af 098/217: pkg.el cleanup, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 13b30a6 093/217: Added Hugh Giddens to contributors, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9ab0a59 091/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c48b479 113/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode af2dc30 136/217: Removed Marmelade from README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 8d4d99b 156/217: Add optional flattening to creation of imenu index (again)., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aebed53 168/217: Mark a couple of indentation variables as safe (#105), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode ece95ca 170/217: use CI to compile PRs, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 37e7537 173/217: rename to scala-mode (#110), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 474a616 175/217: Merge ob-scala into scala-mode (#107), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a0b73b2 177/217: add string interpolation (#116),
ELPA Syncer <=
- [nongnu] elpa/scala-mode 4b492b9 179/217: Fix for fill-paragraph (#123), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 5ffaa1f 185/217: Merge pull request #129 from ensime/hvesalai-patch-94, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f88091a 191/217: `**` at end of multiline comment cause issue #140 (#141), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 44772cb 196/217: fixed some compilation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9e5b8af 190/217: Operator characters ids cannot be adjoint to word constituent ids (#139), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a82f186 192/217: Removed duplicated defconst, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode cc960f3 197/217: fixed some markdown syntax mistakes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9d3b56e 206/217: Merge pull request #161 from Kazark/scala3-keywords, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a4ed6b4 073/217: Merge pull request #28 from non/bug/fix-colon-operators, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 27459c3 080/217: Merge pull request #32 from evnm/insert-asterisk-in-multiline-comment, ELPA Syncer, 2021/08/29