emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/julia-mode d7a7607 184/352: Make julia-last-open-block-pos


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode d7a7607 184/352: Make julia-last-open-block-pos a pure function that only returns the position.
Date: Sun, 29 Aug 2021 11:22:41 -0400 (EDT)

branch: elpa/julia-mode
commit d7a76075508e2e445ef9440c28c774cc27cd038d
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]