branch: elpa/julia-mode commit 78024526718479b63fe3804308b65b405a164688 Merge: feb6e79 5812bc3 Author: Jeff Bezanson <jeff.bezan...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #35 from tpapp/fix-10 Fix indentation for anonymous functions. --- julia-mode-tests.el | 35 +++++++++++++++++++++++++++++++++++ julia-mode.el | 1 + 2 files changed, 36 insertions(+) diff --git a/julia-mode-tests.el b/julia-mode-tests.el index 92c4568..e813657 100644 --- a/julia-mode-tests.el +++ b/julia-mode-tests.el @@ -360,6 +360,41 @@ using Foo: bar , quux notpartofit")) +(ert-deftest julia--test-indent-anonymous-function () + "indentation for function(args...)" + (julia--should-indent + "function f(x) +function(y) +x+y +end +end" + "function f(x) + function(y) + x+y + end +end")) + +(ert-deftest julia--test-indent-keyword-paren () + "indentation for ( following keywords" + "if( a>0 ) +end + + function( i=1:2 ) + for( j=1:2 ) + for( k=1:2 ) + end + end + end" + "if( a>0 ) +end + +function( i=1:2 ) + for( j=1:2 ) + for( k=1:2 ) + end + end +end") + (ert-deftest julia--test-symbol-font-locking-at-bol () "Symbols get font-locked at beginning or line." (julia--should-font-lock diff --git a/julia-mode.el b/julia-mode.el index 48cffa5..7b113e4 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -405,6 +405,7 @@ a keyword if used as a field name, X.word, or quoted, :word." (and (or (= (point) 1) (and (not (equal (char-before (point)) ?.)) (not (equal (char-before (point)) ?:)))) + (not (looking-at "(")) ; handle "function(" when on ( (member (current-word t) kw-list) ;; 'end' is not a keyword when used for indexing, e.g. foo[end-2] (or (not (equal (current-word t) "end"))