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

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

[nongnu] elpa/julia-mode f3f2ad1 198/352: Highlight triple quoted string


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode f3f2ad1 198/352: Highlight triple quoted strings.
Date: Sun, 29 Aug 2021 11:22:44 -0400 (EDT)

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

    Highlight triple quoted strings.
---
 julia-mode.el | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/julia-mode.el b/julia-mode.el
index 1fa44ca..7bb8676 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -114,6 +114,18 @@ This function provides equivalent functionality, but makes 
no efforts to optimis
            "\\\\"))
       (group "'")))
 
+(defconst julia-triple-quoted-string-regex
+  ;; We deliberately put a group on the first and last delimiter, so
+  ;; we can mark these as string delimiters for font-lock.
+  (rx (group "\"")
+      (group "\"\""
+             ;; After the delimiter, we're a sequence of
+             ;; non-backslashes or blackslashes paired with something.
+             (*? (or (not (any "\\"))
+                     (seq "\\" anything)))
+             "\"\"")
+      (group "\"")))
+
 (defconst julia-unquote-regex
   "\\(\\s(\\|\\s-\\|-\\|[,%=<>\\+*/?&|!\\^~\\\\;:]\\|^\\)\\($[a-zA-Z0-9_]+\\)")
 
@@ -391,10 +403,14 @@ 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
-       `(,julia-char-regex
+        `(,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.
+          (3 "\"")); Treat the close ' as a string delimiter.
+        `(,julia-triple-quoted-string-regex
+          (1 "\"") ; Treat the first " in """ as a string delimiter.
+          (2 ".") ; Don't highlight anything between.
+          (3 "\"")) ; Treat the last " in """ 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]