branch: elpa/julia-mode
commit 0eec10a93a32d10a0f7402cab6d3958b2ae3962c
Author: Ronan Arraes Jardim Chagas <[email protected]>
Commit: Ronan Arraes Jardim Chagas <[email protected]>
Do not consider `:end` as block ending
The word `:end` was being considered as a block ending. Hence, the
following code:
if a == :end
r = 1
end
was being incorrectly indented:
if a == :end
r = 1
end
Closes #122
---
julia-mode-tests.el | 10 ++++++++++
julia-mode.el | 4 +++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/julia-mode-tests.el b/julia-mode-tests.el
index 8ca4299..6d326a9 100644
--- a/julia-mode-tests.el
+++ b/julia-mode-tests.el
@@ -433,6 +433,16 @@ function( i=1:2 )
end
end")
+(ert-deftest julia--test-indent-ignore-:end-as-block-ending ()
+ "Do not consider `:end` as a block ending."
+ (julia--should-indent
+ "if a == :end
+r = 1
+end"
+ "if a == :end
+ r = 1
+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 2282bab..d9bb6c3 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -412,7 +412,9 @@ Do not move back beyond position MIN."
(cond ((julia-at-keyword julia-block-start-keywords)
(+ nesting-count 1))
((and (equal (current-word t) "end")
- (not (julia-in-comment)))
+ (not (julia-in-comment))
+ ;; Do not consider the symbol `:end` a block ending.
+ (not (equal (char-before (point)) ?:)))
(- nesting-count 1))
(t nesting-count))))
(if (> nesting-count 0)