diff --git a/julia-mode-tests.el b/julia-mode-tests.el index 72314a6..56ebb38 100644 --- a/julia-mode-tests.el +++ b/julia-mode-tests.el @@ -655,6 +655,17 @@ var = func(begin (let ((string "for i∈1:10\nprintln(i)\nend")) (julia--should-font-lock string 2 font-lock-keyword-face) (julia--should-font-lock string 6 font-lock-keyword-face)) + (let ((string "for i\n in (5, 10)\nprintln(i)\nend")) + (julia--should-font-lock string 1 font-lock-keyword-face) + (julia--should-font-lock string 8 font-lock-keyword-face)) + (let ((string "for i in (5, 10), j in (10, 15)\nprintln(i)\nend")) + (julia--should-font-lock string 1 font-lock-keyword-face) + (julia--should-font-lock string 7 font-lock-keyword-face) + (julia--should-font-lock string 21 font-lock-keyword-face)) + (let ((string "for i in (5, 10),\nj in (10, 15)\nprintln(i)\nend")) + (julia--should-font-lock string 1 font-lock-keyword-face) + (julia--should-font-lock string 7 font-lock-keyword-face) + (julia--should-font-lock string 21 font-lock-keyword-face)) (let ((string "[i for i in 1:10]")) (julia--should-font-lock string 4 font-lock-keyword-face) (julia--should-font-lock string 10 font-lock-keyword-face)) @@ -668,6 +679,11 @@ var = func(begin (julia--should-font-lock string 25 nil) (julia--should-font-lock string 26 nil))) +(ert-deftest julia--test-in-font-lock () + "in font-locked as keyword for containment" + (let ((string "if 2 in [1, 2, 3]")) + (julia--should-font-lock string 6 font-lock-keyword-face))) + (ert-deftest julia--test-typeparams-font-lock () (let ((string "@with_kw struct Foo{A <: AbstractThingy, B <: Tuple}\n bar::A\n baz::B\nend")) (julia--should-font-lock string 30 font-lock-type-face) ; AbstractThingy diff --git a/julia-mode.el b/julia-mode.el index 10fd963..0a4600b 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -189,9 +189,8 @@ (defconst julia-unquote-regex "\\(\\s(\\|\\s-\\|-\\|[,%=<>\\+*/?&|!\\^~\\\\;:]\\|^\\)\\($[a-zA-Z0-9_]+\\)") -(defconst julia-forloop-in-regex - "for +.*[^ -].* \\(in\\)\\(\\s-\\|$\\)+") +(defconst julia-in-regex + " \\(in\\)\\(\\s-\\|$\\)+") (defconst julia--forloop-=-regex (rx "for" @@ -282,7 +281,7 @@ 'font-lock-constant-face) (cons "ccall" 'font-lock-builtin-face) (list julia-unquote-regex 2 'font-lock-constant-face) - (list julia-forloop-in-regex 1 'font-lock-keyword-face) + (list julia-in-regex 1 'font-lock-keyword-face) (list julia--forloop-=-regex 1 'font-lock-keyword-face) (list julia-ternary-regex (list 1 'font-lock-keyword-face) (list 2 'font-lock-keyword-face)) (list julia-function-regex 1 'font-lock-function-name-face)