branch: elpa/julia-mode commit d7a76075508e2e445ef9440c28c774cc27cd038d Author: Wilfred Hughes <m...@wilfred.me.uk> Commit: Yichao Yu <yyc1...@gmail.com>
Make julia-last-open-block-pos a pure function that only returns the position. --- julia-mode.el | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/julia-mode.el b/julia-mode.el index cac3f03..7dfc292 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -295,21 +295,23 @@ a keyword if used as a field name, X.word, or quoted, :word." (ignore-errors (backward-char)))) (defun julia-last-open-block-pos (min) - "Move back and return the position of the last open block, if one found. + "Return the position of the last open block, if one found. Do not move back beyond position MIN." - (let ((count 0)) - (while (not (or (> count 0) (<= (point) min))) - (julia-safe-backward-sexp) - (setq count - (cond ((julia-at-keyword julia-block-start-keywords) - (+ count 1)) - ((and (equal (current-word t) "end") - (not (julia-in-comment)) (not (julia-in-brackets))) - (- count 1)) - (t count)))) - (if (> count 0) - (point) - nil))) + (save-excursion + (let ((count 0)) + (while (not (or (> count 0) (<= (point) min))) + (julia-safe-backward-sexp) + (setq count + (cond ((julia-at-keyword julia-block-start-keywords) + (+ count 1)) + ;; fixme: breaks on strings + ((and (equal (current-word t) "end") + (not (julia-in-comment)) (not (julia-in-brackets))) + (- count 1)) + (t count)))) + (if (> count 0) + (point) + nil)))) (defun julia-last-open-block (min) "Move back and return indentation level for last open block.