Skip to content

Improve highlighting of in. #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions julia-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down