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

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

[nongnu] elpa/julia-mode ea54e19 196/352: Fontify strings and chars as s


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode ea54e19 196/352: Fontify strings and chars as strings, not keywords.
Date: Sun, 29 Aug 2021 11:22:43 -0400 (EDT)

branch: elpa/julia-mode
commit ea54e19d9229f9c4ba427a82f59d842e2173f651
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>

    Fontify strings and chars as strings, not keywords.
    
    This is faster and less code.
---
 julia-mode.el | 53 ++++++++++++++++++-----------------------------------
 1 file changed, 18 insertions(+), 35 deletions(-)

diff --git a/julia-mode.el b/julia-mode.el
index bbfc535..4504c49 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -82,11 +82,13 @@ This function provides equivalent functionality, but makes 
no efforts to optimis
     (modify-syntax-entry ?\] ")[ " table)
     (modify-syntax-entry ?\( "() " table)
     (modify-syntax-entry ?\) ")( " table)
-    ;(modify-syntax-entry ?\\ "." table)  ; \ is an operator outside quotes
-    (modify-syntax-entry ?'  "." table)  ; character quote or transpose
+    ;; Here, we treat ' as punctuation (when it's used for transpose),
+    ;; see our use of `julia-char-regex' for handling ' as a character
+    ;; delimeter
+    (modify-syntax-entry ?'  "." table)
     (modify-syntax-entry ?\" "\"" table)
     (modify-syntax-entry ?` "\"" table)
-    ;; (modify-syntax-entry ?\" "." table)
+
     (modify-syntax-entry ?. "." table)
     (modify-syntax-entry ?? "." table)
     (modify-syntax-entry ?$ "." table)
@@ -101,31 +103,16 @@ This function provides equivalent functionality, but 
makes no efforts to optimis
     table)
   "Syntax table for `julia-mode'.")
 
-;; syntax table that holds within strings
-(defvar julia-mode-string-syntax-table
-  (let ((table (make-syntax-table)))
-    table)
-  "Syntax table for `julia-mode'.")
-
-;; disable " inside char quote
-(defvar julia-mode-char-syntax-table
-  (let ((table (make-syntax-table)))
-    (modify-syntax-entry ?\" "." table)
-    table)
-  "Syntax table for `julia-mode'.")
-
-(defconst julia-string-regex
-  "\"[^\"]*?\\(\\(\\\\\\\\\\)*\\\\\"[^\"]*?\\)*\"")
-
 (defconst julia-char-regex
-  (rx (submatch (or (any "-" ";" "\\" "^" "!" "|" "?" "*" "<" "%" "," "=" ">" 
"+" "/" "&" "$" "~" ":")
-                    (syntax open-parenthesis)
-                    (syntax whitespace)
-                    bol))
-      (submatch "'"
-                (or (repeat 0 8 (not (any "'"))) (not (any "\\"))
-                    "\\\\")
-                "'")))
+  (rx (or (any "-" ";" "\\" "^" "!" "|" "?" "*" "<" "%" "," "=" ">" "+" "/" 
"&" "$" "~" ":")
+          (syntax open-parenthesis)
+          (syntax whitespace)
+          bol)
+      (group "'")
+      (group
+       (or (repeat 0 8 (not (any "'"))) (not (any "\\"))
+           "\\\\"))
+      (group "'")))
 
 (defconst julia-unquote-regex
   "\\(\\s(\\|\\s-\\|-\\|[,%=<>\\+*/?&|!\\^~\\\\;:]\\|^\\)\\($[a-zA-Z0-9_]+\\)")
@@ -208,7 +195,6 @@ This function provides equivalent functionality, but makes 
no efforts to optimis
      'symbols)
     'font-lock-constant-face)
    (list julia-unquote-regex 2 'font-lock-constant-face)
-   (list julia-char-regex 2 'font-lock-string-face)
    (list julia-forloop-in-regex 1 'font-lock-keyword-face)
    (list julia-function-regex 1 'font-lock-function-name-face)
    (list julia-function-assignment-regex 1 'font-lock-function-name-face)
@@ -405,13 +391,10 @@ before point. Returns nil if we're not within nested 
parens."
   (set (make-local-variable 'font-lock-defaults) '(julia-font-lock-keywords))
   (set (make-local-variable 'font-lock-syntactic-keywords)
        (list
-       (list "\\(\\\\\\)\\s-*\".*?\"" 1 julia-mode-char-syntax-table)))
-  (set (make-local-variable 'font-lock-syntactic-keywords)
-        (list
-       (list julia-char-regex 2
-             julia-mode-char-syntax-table)
-        (list julia-string-regex 0
-              julia-mode-string-syntax-table)
+       `(,julia-char-regex
+          (1 "\"") ; Treat ' as a string delimiter.
+          (2 ".") ; Don't highlight anything between the open and close '.
+          (3 "\"")) ; Treat the close ' as a string delimiter.
        ))
   (set (make-local-variable 'indent-line-function) 'julia-indent-line)
   (set (make-local-variable 'julia-basic-offset) 4)



reply via email to

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