From 67f158d7144d34f364c749ed56540499d85b186e Mon Sep 17 00:00:00 2001 From: David Hansen Date: Wed, 29 May 2019 10:26:42 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20stop=20at=20empty=20lines=20in?= =?UTF-8?q?=20=E2=80=98end-of-defun=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- julia-mode-tests.el | 18 ++++++++++++++++++ julia-mode.el | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/julia-mode-tests.el b/julia-mode-tests.el index f5436c7..c61df6d 100644 --- a/julia-mode-tests.el +++ b/julia-mode-tests.el @@ -567,6 +567,24 @@ f(x) = x + 1" 'beginning-of-defun "\\+" 4)) "f(x)::Int8 = x *x" 'end-of-defun "(" "*x" 'end)) +(ert-deftest julia--test-end-of-defun-assn-with-empty-lines () + "Point should move to end of assignment function." + (julia--should-move-point + "f(x)::Int8 = + +# no comment +x*x" 'end-of-defun "(" "*x" 'end)) + +(ert-deftest julia-test-end-of-defun-with-empty-lines () + "Point should move to end of function." + (julia--should-move-point + " +function forty_two() + +# no comment + return 42 +end" 'end-of-defun 0 "end" 'end)) + (ert-deftest julia--test-end-of-defun-nested-1 () "Point should move to end of inner function when called from inner." (julia--should-move-point diff --git a/julia-mode.el b/julia-mode.el index 3263507..86b962a 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -759,7 +759,8 @@ Return nil if point is not in a function, otherwise point." (while (and (not (eobp)) (forward-line 1) (or (julia-syntax-comment-or-string-p) - (> (current-indentation) beg-defun-indent))))) + (> (current-indentation) beg-defun-indent) + (looking-at-p "^\\s-*\\(?:#.*\\)*$"))))) (end-of-line) (point))))