@@ -1568,7 +1568,7 @@ current sexp."
15681568 " Undo a `join-line' done by a threading command."
15691569 (when (get-text-property (point ) 'clojure-thread-line-joined )
15701570 (remove-text-properties (point ) (1+ (point )) '(clojure-thread-line-joined t ))
1571- (newline-and-indent )))
1571+ (insert " \n " )))
15721572
15731573(defun clojure--unwind-last ()
15741574 (forward-sexp )
@@ -1584,13 +1584,12 @@ current sexp."
15841584 (multiline-sexp-p (not (= sexp-beg-line sexp-end-line))))
15851585 (down-list -1 )
15861586 (if multiline-sexp-p
1587- (newline )
1587+ (insert " \n " )
15881588 ; ; `clojure--maybe-unjoin-line' only works when unwinding sexps that were
15891589 ; ; threaded in the same Emacs session, but it also catches cases that
15901590 ; ; `multiline-sexp-p' doesn't.
15911591 (clojure--maybe-unjoin-line))
1592- (insert contents)
1593- (clojure-indent-region beg (point )))))
1592+ (insert contents))))
15941593 (forward-char ))
15951594
15961595(defun clojure--ensure-parens-around-function-names ()
@@ -1617,12 +1616,7 @@ Point must be between the opening paren and the -> symbol."
16171616 (save-excursion
16181617 (down-list 2 )
16191618 (backward-up-list )
1620- (raise-sexp )
1621- (let ((beg (point ))
1622- (end (progn
1623- (forward-sexp )
1624- (point ))))
1625- (clojure-indent-region beg end))))
1619+ (raise-sexp )))
16261620
16271621(defun clojure--nothing-more-to-unwind ()
16281622 (save-excursion
@@ -1634,6 +1628,13 @@ Point must be between the opening paren and the -> symbol."
16341628 (backward-up-list )) ; ; and the paren
16351629 (= beg (point )))))
16361630
1631+ (defun clojure--fix-sexp-whitespace (&optional move-out )
1632+ (save-excursion
1633+ (when move-out (backward-up-list ))
1634+ (let ((sexp (bounds-of-thing-at-point 'sexp )))
1635+ (clojure-indent-region (car sexp) (cdr sexp))
1636+ (delete-trailing-whitespace (car sexp) (cdr sexp)))))
1637+
16371638;;;### autoload
16381639(defun clojure-unwind ()
16391640 " Unwind thread at point or above point by one level.
@@ -1650,11 +1651,13 @@ Return nil if there are no more levels to unwind."
16501651 (search-backward-regexp " ([^-]*->" limit)
16511652 (if (clojure--nothing-more-to-unwind)
16521653 (progn (clojure--pop-out-of-threading)
1654+ (clojure--fix-sexp-whitespace)
16531655 nil )
16541656 (down-list )
1655- (cond
1656- ((looking-at " [^-]*->\\ _>" ) (clojure--unwind-first))
1657- ((looking-at " [^-]*->>\\ _>" ) (clojure--unwind-last)))
1657+ (prog1 (cond
1658+ ((looking-at " [^-]*->\\ _>" ) (clojure--unwind-first))
1659+ ((looking-at " [^-]*->>\\ _>" ) (clojure--unwind-last)))
1660+ (clojure--fix-sexp-whitespace 'move-out ))
16581661 t ))))
16591662
16601663;;;### autoload
@@ -1714,9 +1717,10 @@ Return nil if there are no more levels to unwind."
17141717 (search-backward-regexp " ([^-]*->" )
17151718 (down-list )
17161719 (when (clojure--threadable-p)
1717- (cond
1718- ((looking-at " [^-]*->\\ _>" ) (clojure--thread-first))
1719- ((looking-at " [^-]*->>\\ _>" ) (clojure--thread-last)))))
1720+ (prog1 (cond
1721+ ((looking-at " [^-]*->\\ _>" ) (clojure--thread-first))
1722+ ((looking-at " [^-]*->>\\ _>" ) (clojure--thread-last)))
1723+ (clojure--fix-sexp-whitespace 'move-out ))))
17201724
17211725(defun clojure--thread-all (first-or-last-thread but-last )
17221726 (save-excursion
0 commit comments