@@ -1568,7 +1568,7 @@ current sexp."
1568
1568
" Undo a `join-line' done by a threading command."
1569
1569
(when (get-text-property (point ) 'clojure-thread-line-joined )
1570
1570
(remove-text-properties (point ) (1+ (point )) '(clojure-thread-line-joined t ))
1571
- (newline-and-indent )))
1571
+ (insert " \n " )))
1572
1572
1573
1573
(defun clojure--unwind-last ()
1574
1574
(forward-sexp )
@@ -1584,13 +1584,12 @@ current sexp."
1584
1584
(multiline-sexp-p (not (= sexp-beg-line sexp-end-line))))
1585
1585
(down-list -1 )
1586
1586
(if multiline-sexp-p
1587
- (newline )
1587
+ (insert " \n " )
1588
1588
; ; `clojure--maybe-unjoin-line' only works when unwinding sexps that were
1589
1589
; ; threaded in the same Emacs session, but it also catches cases that
1590
1590
; ; `multiline-sexp-p' doesn't.
1591
1591
(clojure--maybe-unjoin-line))
1592
- (insert contents)
1593
- (clojure-indent-region beg (point )))))
1592
+ (insert contents))))
1594
1593
(forward-char ))
1595
1594
1596
1595
(defun clojure--ensure-parens-around-function-names ()
@@ -1617,12 +1616,7 @@ Point must be between the opening paren and the -> symbol."
1617
1616
(save-excursion
1618
1617
(down-list 2 )
1619
1618
(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 )))
1626
1620
1627
1621
(defun clojure--nothing-more-to-unwind ()
1628
1622
(save-excursion
@@ -1634,6 +1628,13 @@ Point must be between the opening paren and the -> symbol."
1634
1628
(backward-up-list )) ; ; and the paren
1635
1629
(= beg (point )))))
1636
1630
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
+
1637
1638
;;;### autoload
1638
1639
(defun clojure-unwind ()
1639
1640
" Unwind thread at point or above point by one level.
@@ -1650,11 +1651,13 @@ Return nil if there are no more levels to unwind."
1650
1651
(search-backward-regexp " ([^-]*->" limit)
1651
1652
(if (clojure--nothing-more-to-unwind)
1652
1653
(progn (clojure--pop-out-of-threading)
1654
+ (clojure--fix-sexp-whitespace)
1653
1655
nil )
1654
1656
(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 ))
1658
1661
t ))))
1659
1662
1660
1663
;;;### autoload
@@ -1714,9 +1717,10 @@ Return nil if there are no more levels to unwind."
1714
1717
(search-backward-regexp " ([^-]*->" )
1715
1718
(down-list )
1716
1719
(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 ))))
1720
1724
1721
1725
(defun clojure--thread-all (first-or-last-thread but-last )
1722
1726
(save-excursion
0 commit comments