branch: elpa/julia-mode
commit 46d2469c408888cfeeec27904116cfc22ceb1461
Merge: 04b97c4 c4a75b4
Author: Yichao Yu <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #39 from rfourquet/rf/where
add support for `where` keyword
---
julia-mode-tests.el | 26 +++++++++++++++++++++++---
julia-mode.el | 5 ++---
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/julia-mode-tests.el b/julia-mode-tests.el
index 3a0c8dd..f2320a3 100644
--- a/julia-mode-tests.el
+++ b/julia-mode-tests.el
@@ -246,12 +246,12 @@ qux"))
(julia--should-indent
"
if foo
-
+
bar
end"
"
if foo
-
+
bar
end"))
@@ -390,7 +390,7 @@ end"))
"indentation for ( following keywords"
"if( a>0 )
end
-
+
function( i=1:2 )
for( j=1:2 )
for( k=1:2 )
@@ -417,6 +417,26 @@ end")
(let ((string "function \\(a, b)"))
(julia--should-font-lock string (1- (length string)) nil)))
+(ert-deftest julia--test-function-assignment-font-locking ()
+ (julia--should-font-lock
+ "f(x) = 1" 1 'font-lock-function-name-face)
+ (julia--should-font-lock
+ "Base.f(x) = 1" 6 'font-lock-function-name-face)
+ (julia--should-font-lock
+ "f(x) where T = 1" 1 'font-lock-function-name-face)
+ (julia--should-font-lock
+ "f(x) where{T} = 1" 1 'font-lock-function-name-face))
+
+(ert-deftest julia--test-where-keyword-font-locking ()
+ (julia--should-font-lock
+ "f(x) where T = 1" 6 'font-lock-keyword-face)
+ (dolist (pos '(22 30))
+ (julia--should-font-lock
+ "function f(::T, ::Z) where T where Z
+ 1
+ end"
+ pos 'font-lock-keyword-face)))
+
(defun julia--run-tests ()
(interactive)
(if (featurep 'ert)
diff --git a/julia-mode.el b/julia-mode.el
index cd10242..737e44a 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -229,14 +229,13 @@ This function provides equivalent functionality, but
makes no efforts to optimis
(rx line-start (* (or space "@inline" "@noinline")) symbol-start
(* (seq (1+ (or word (syntax symbol))) ".")) ; module name
(group (1+ (or word (syntax symbol))))
- (* space)
(? "{" (* (not (any "}"))) "}")
- (* space)
"(" (* (or
(seq "(" (* (not (any "(" ")"))) ")")
(not (any "(" ")"))))
")"
(* space)
+ (* (seq "where" (or "{" (+ space)) (+ (not (any "=")))))
"="
(not (any "="))))
@@ -261,7 +260,7 @@ This function provides equivalent functionality, but makes
no efforts to optimis
(julia--regexp-opt
'("if" "else" "elseif" "while" "for" "begin" "end" "quote"
"try" "catch" "return" "local" "function" "macro" "ccall"
- "finally" "break" "continue" "global"
+ "finally" "break" "continue" "global" "where"
"module" "using" "import" "export" "const" "let" "do" "in"
"baremodule" "importall"
"immutable" "type" "bitstype" "abstract" "typealias" ;; remove after 0.6