emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/scala-mode 4dbaa5f 010/217: picked some of Erik's fontlock


From: ELPA Syncer
Subject: [nongnu] elpa/scala-mode 4dbaa5f 010/217: picked some of Erik's fontlock magic for an interim solution
Date: Sun, 29 Aug 2021 11:30:34 -0400 (EDT)

branch: elpa/scala-mode
commit 4dbaa5fa6c4d846ae3dd8cf2030ca164ecf11dc9
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>

    picked some of Erik's fontlock magic for an interim solution
---
 README                 |  8 ++++-
 scala-mode-fontlock.el | 89 ++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 82 insertions(+), 15 deletions(-)

diff --git a/README b/README
index 1988df1..d6c9caf 100644
--- a/README
+++ b/README
@@ -12,6 +12,12 @@ The mode will target scala code written in a functinal style.
 
 Check out Example.scala to see how it indents.
 
+Special thanks for valuable feedback:
+- Eiríkr Åsheim (aka Erik Osheim)
+
 TODO:
+- indent scaladoc left margin correctly
 - indenting a row removes trailing whitespace and converts tabs to spaces
-
+- highlight number (decimal, octal, hex, double, float) literals as constants
+- indent and fill multi-line strings with margin correctly
+- high-light headings and annotations inside scaladoc specially (use underline 
for headings)
diff --git a/scala-mode-fontlock.el b/scala-mode-fontlock.el
index dd112f3..0d2815e 100644
--- a/scala-mode-fontlock.el
+++ b/scala-mode-fontlock.el
@@ -305,6 +305,10 @@ 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)
 
@@ -329,20 +333,20 @@ Does not continue past limit.
               "\\)") 
      2 font-lock-type-face)
 
-    ;; extends, with, new
-    (,(concat "\\<\\(extends\\|with\\|new\\)[ \t]+\\([(" 
-              scala-syntax:id-first-char-group "]\\)")
-     (scala-font-lock:mark-simpleType (scala-font-lock:limit-simpleType 
-                                       (goto-char (match-beginning 2))) 
-                                      nil
-                                      (0 font-lock-type-face nil t)))
-
-    ;; ':'
-    (,scala-syntax:colon-re
-     (scala-font-lock:mark-simpleType (scala-font-lock:limit-simpleType
-                                       (goto-char (match-end 2)))
-                                      nil
-                                      (0 font-lock-type-face nil t)))
+    ;; ;; extends, with, new
+    ;; (,(concat "\\<\\(extends\\|with\\|new\\)[ \t]+\\([(" 
+    ;;           scala-syntax:id-first-char-group "]\\)")
+    ;;  (scala-font-lock:mark-simpleType (scala-font-lock:limit-simpleType 
+    ;;                                    (goto-char (match-beginning 2))) 
+    ;;                                   nil
+    ;;                                   (0 font-lock-type-face nil t)))
+
+    ;; ;; ':'
+    ;; (,scala-syntax:colon-re
+    ;;  (scala-font-lock:mark-simpleType (scala-font-lock:limit-simpleType
+    ;;                                    (goto-char (match-end 2)))
+    ;;                                   nil
+    ;;                                   (0 font-lock-type-face nil t)))
 
     ;; def
     (,(concat "\\<def[ \t]+\\(" scala-syntax:id-re "\\)") 1 
font-lock-function-name-face)
@@ -364,5 +368,62 @@ Does not continue past limit.
                                         (1 font-lock-variable-name-face nil t)
                                         (2 font-lock-constant-face nil t)
                                         (3 font-lock-type-face nil t)))
+
+    ;; Some patterns from Erik
+    (,(rx "@" (in "a-zA-Z_") (0+ (in "a-zA-Z0-9_")))
+     . font-lock-preprocessor-face)
+
+    ;; :
+    (,(rx ":"
+        (0+ space)
+        (group (or
+                 (and (in "a-zA-Z_")
+                      (0+ (in "a-zA-Z0-9_"))
+                      (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+                 (and (in "!#%&*+-/<=>?@\\^|~") (0+ (in 
"!#%&*+-/:<=>?@\\^|~"))))))
+      (1 font-lock-type-face))
+
+    (,(rx (group "extends")
+          (1+ space)
+          (group (or
+                   (and (in "a-zA-Z_")
+                        (0+ (in "a-zA-Z0-9_"))
+                        (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+                   (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+      (1 font-lock-keyword-face) (2 font-lock-type-face))
+    
+    (,(rx (group "with")
+          (1+ space)
+          (group (or
+                   (and (in "a-zA-Z_")
+                        (0+ (in "a-zA-Z0-9_"))
+                        (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+                   (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+      (1 font-lock-keyword-face) (2 font-lock-type-face))
+    
+    (,(rx (group "new")
+          (1+ space)
+          (group (or
+                   (and (in "a-zA-Z_")
+                        (0+ (in "a-zA-Z0-9_"))
+                        (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+                   (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+      (1 font-lock-keyword-face) (2 font-lock-type-face))
+
+    ; uppercase
+    (,(rx symbol-start
+        (and (in "A-Z")
+             (0+ (in "a-zA-Z0-9_"))
+             (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~"))))))
+     . font-lock-type-face)
+
+    ; package name
+    (,(rx symbol-start
+        (group "package")
+        (1+ space)
+        (group (and (in "a-zA-Z_.") (0+ (in "a-zA-Z0-9_.")))))
+     (1 font-lock-keyword-face) (2 font-lock-string-face))
+
+    
     
 ))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]