@@ -2196,10 +2196,12 @@ before fixing whitespace."
21962196 (delete-trailing-whitespace (car sexp) (cdr sexp)))))
21972197
21982198;;;### autoload
2199- (defun clojure-unwind ()
2200- " Unwind thread at point or above point by one level.
2201- Return nil if there are no more levels to unwind."
2202- (interactive )
2199+ (defun clojure-unwind (&optional n )
2200+ " Unwind thread at point or above point by N levels.
2201+ With universal argument \\ [universal-argument], fully unwind thread."
2202+ (interactive " P" )
2203+ (setq n (cond ((equal n '(4 )) 999 )
2204+ (n) (1 )))
22032205 (save-excursion
22042206 (let ((limit (save-excursion
22052207 (beginning-of-defun )
@@ -2208,23 +2210,24 @@ Return nil if there are no more levels to unwind."
22082210 (when (looking-at " (" )
22092211 (forward-char 1 )
22102212 (forward-sexp 1 )))
2211- (search-backward-regexp " ([^-]*->" limit)
2212- (if (clojure--nothing-more-to-unwind)
2213- (progn (clojure--pop-out-of-threading)
2214- (clojure--fix-sexp-whitespace)
2215- nil )
2216- (down-list )
2217- (prog1 (cond
2218- ((looking-at " [^-]*->\\ _>" ) (clojure--unwind-first))
2219- ((looking-at " [^-]*->>\\ _>" ) (clojure--unwind-last)))
2220- (clojure--fix-sexp-whitespace 'move-out ))
2221- t ))))
2213+ (while (> n 0 )
2214+ (search-backward-regexp " ([^-]*->" limit)
2215+ (if (clojure--nothing-more-to-unwind)
2216+ (progn (clojure--pop-out-of-threading)
2217+ (clojure--fix-sexp-whitespace)
2218+ (setq n 0 )) ; ; break out of loop
2219+ (down-list )
2220+ (cond
2221+ ((looking-at " [^-]*->\\ _>" ) (clojure--unwind-first))
2222+ ((looking-at " [^-]*->>\\ _>" ) (clojure--unwind-last)))
2223+ (clojure--fix-sexp-whitespace 'move-out )
2224+ (setq n (1- n)))))))
22222225
22232226;;;### autoload
22242227(defun clojure-unwind-all ()
22252228 " Fully unwind thread at point or above point."
22262229 (interactive )
2227- (while ( clojure-unwind)))
2230+ (clojure-unwind '( 4 )))
22282231
22292232(defun clojure--remove-superfluous-parens ()
22302233 " Remove extra parens from a form."
0 commit comments