branch: elpa/scala-mode commit 84d9c10c23f7dc30d3e359f3019d93d1c997db4a Author: Heikki Vesalainen <heikkivesalai...@yahoo.com> Commit: Heikki Vesalainen <heikkivesalai...@yahoo.com>
highlight string escapes --- scala-mode-fontlock.el | 16 +++++++++++----- scala-mode-syntax.el | 7 +++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/scala-mode-fontlock.el b/scala-mode-fontlock.el index 0d2815e..8c35dcd 100644 --- a/scala-mode-fontlock.el +++ b/scala-mode-fontlock.el @@ -295,6 +295,11 @@ Does not continue past limit. (message "limit %d" (scala-font-lock:limit-simpleType (point))) (message "mark from %d: %s at %d" (point) (scala-font-lock:mark-simpleType) (point))) + +(defun scala-font-lock:mark-string-escapes (limit) + (when (re-search-forward scala-syntax:string-escape-re limit) + (let ((state (syntax-ppss (match-beginning 0)))) + (= (nth 3 state) ?\")))) (defun scala-font-lock:keywords () ;; chars, string, comments are handled acording to syntax and @@ -305,10 +310,6 @@ Does not continue past limit. (,scala-syntax:value-keywords-re 2 font-lock-constant-face) (,scala-syntax:path-keywords-re 2 font-lock-keyword-face) - ;; number literals - (,scala-syntax:floatingPointLiteral-re . font-lock-constant-face) - (,scala-syntax:integerLiteral-re . font-lock-constant-face) - ;; User defined constants (,(scala-font-lock:create-user-constant-re) 0 font-lock-constant-face) @@ -321,6 +322,9 @@ Does not continue past limit. ;; underscore (scala-font-lock:mark-underscore 2 font-lock-keyword-face) + ;; escapes inside strings + (scala-font-lock:mark-string-escapes (0 font-lock-constant-face prepend nil)) + ;; object (,(concat "\\<object[ \t]+\\(" scala-syntax:id-re @@ -424,6 +428,8 @@ Does not continue past limit. (group (and (in "a-zA-Z_.") (0+ (in "a-zA-Z0-9_."))))) (1 font-lock-keyword-face) (2 font-lock-string-face)) - + ;; number literals (have to be here so that other rules take precedence) + (,scala-syntax:floatingPointLiteral-re . font-lock-constant-face) + (,scala-syntax:integerLiteral-re . font-lock-constant-face) )) diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el index 1313f7b..575b457 100644 --- a/scala-mode-syntax.el +++ b/scala-mode-syntax.el @@ -80,11 +80,14 @@ "\\|" scala-syntax:escapeSequence-re "\\|" scala-syntax:UnicodeEscape-re "\\)\\('\\)")) +(defconst scala-syntax:string-escape-re + (concat scala-syntax:escapeSequence-re + "\\|" scala-syntax:UnicodeEscape-re)) + ;; String Literals (Chapter 1.3.5) (defconst scala-syntax:stringElement-re (concat "\\(" "[^\n\"\\\\\]" - "\\|" scala-syntax:escapeSequence-re - "\\|" scala-syntax:UnicodeEscape-re "\\)")) + "\\|" scala-syntax:string-escape-re "\\)")) (defconst scala-syntax:oneLineStringLiteral-re (concat "\\(\"\\)" scala-syntax:stringElement-re "*\\(\"\\)")) (defconst scala-syntax:multiLineStringLiteral-re "\\(\"\\)\\(\"\"\\(\"?\"?[^\"]\\)*\"\"+\\)\\(\"\\)")