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

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

[nongnu] elpa/julia-mode e4d0e09 199/352: Highlight quoted symbols, e.g.


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode e4d0e09 199/352: Highlight quoted symbols, e.g. :foo.
Date: Sun, 29 Aug 2021 11:22:44 -0400 (EDT)

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

    Highlight quoted symbols, e.g. :foo.
    
    Fixes https://github.com/JuliaLang/julia/issues/8713.
---
 julia-mode.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/julia-mode.el b/julia-mode.el
index 7bb8676..9cd4ae5 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -46,6 +46,11 @@
   "Face for Julia macro invocations."
   :group 'julia-mode)
 
+(defface julia-quoted-symbol-face
+  '((t :inherit font-lock-preprocessor-face))
+  "Face for quoted Julia symbols, e.g. :foo."
+  :group 'julia-mode)
+
 
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-mode))
@@ -196,8 +201,19 @@ This function provides equivalent functionality, but makes 
no efforts to optimis
      "DataType" "Symbol" "Function" "Vector" "Matrix" "Union" "Type" "Any" 
"Complex" "None" "String" "Ptr" "Void" "Exception" "Task" "Signed" "Unsigned" 
"Associative" "Dict" "IO" "IOStream" "Ranges" "Rational" "Regex" "RegexMatch" 
"Set" "IntSet" "Expr" "WeakRef" "Nothing" "ObjectIdDict")
    'symbols))
 
+(defconst julia-quoted-symbol-regex
+  ;; :foo and :foo2 are valid, but :123 is not.
+  (rx (or whitespace "(" "[" ",")
+      (group ":" (or letter (syntax symbol)) (0+ (or word (syntax symbol))))))
+
 (defconst julia-font-lock-keywords
   (list
+   ;; Ensure :: and <: aren't highlighted, so we don't confuse ::Foo with :foo.
+   ;; (in Emacs, keywords don't overlap).
+   (cons (rx (or "::" "<:")) ''default)
+   ;; Highlight quoted symbols before keywords, so :function is not
+   ;; highlighted as a keyword.
+   (list julia-quoted-symbol-regex 1 ''julia-quoted-symbol-face)
    (cons julia-builtin-types-regex 'font-lock-type-face)
    (cons julia-keyword-regex 'font-lock-keyword-face)
    (cons julia-macro-regex ''julia-macro-face)



reply via email to

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