branch: elpa/julia-mode commit 1f254f80ed5273ee33245fc4915c02ed43a19d35 Author: Tamas K. Papp <tkp...@gmail.com> Commit: Tamas K. Papp <tkp...@gmail.com>
Fix indentation for anonymous functions. This should fix issue #10. The problem was that when the indentation algorithm traversed forms with `function(args...)`, and it was on the `(`, `(julia-at-keyword julia-block-start-keywords)` would return `t` because `(current-word t)` would return `function`. The fix adds a check for this. Tests are also added. --- julia-mode-tests.el | 14 ++++++++++++++ julia-mode.el | 1 + 2 files changed, 15 insertions(+) diff --git a/julia-mode-tests.el b/julia-mode-tests.el index 92c4568..8fd1882 100644 --- a/julia-mode-tests.el +++ b/julia-mode-tests.el @@ -360,6 +360,20 @@ 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-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"))