Skip to content

Commit 4dc6fa2

Browse files
committed
Limit the search for threads to unwind and save-excursion
1 parent b39633b commit 4dc6fa2

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

clojure-mode.el

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,19 +1626,23 @@ Point must be between the opening paren and the -> symbol."
16261626
"Unwind thread at point or above point by one level.
16271627
Return nil if there are no more levels to unwind."
16281628
(interactive)
1629-
(ignore-errors
1630-
(when (looking-at "(")
1631-
(forward-char 1)
1632-
(forward-sexp 1)))
1633-
(search-backward-regexp "([^-]*->")
1634-
(if (clojure--nothing-more-to-unwind)
1635-
(progn (clojure--pop-out-of-threading)
1636-
nil)
1637-
(down-list)
1638-
(cond
1639-
((looking-at "[^-]*->\\_>") (clojure--unwind-first))
1640-
((looking-at "[^-]*->>\\_>") (clojure--unwind-last)))
1641-
t))
1629+
(save-excursion
1630+
(let ((limit (save-excursion
1631+
(beginning-of-defun)
1632+
(point))))
1633+
(ignore-errors
1634+
(when (looking-at "(")
1635+
(forward-char 1)
1636+
(forward-sexp 1)))
1637+
(search-backward-regexp "([^-]*->" limit)
1638+
(if (clojure--nothing-more-to-unwind)
1639+
(progn (clojure--pop-out-of-threading)
1640+
nil)
1641+
(down-list)
1642+
(cond
1643+
((looking-at "[^-]*->\\_>") (clojure--unwind-first))
1644+
((looking-at "[^-]*->>\\_>") (clojure--unwind-last)))
1645+
t))))
16421646

16431647
;;;###autoload
16441648
(defun clojure-unwind-all ()

0 commit comments

Comments
 (0)