File tree 2 files changed +40
-8
lines changed
2 files changed +40
-8
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,15 @@ namespace in the project."
184
184
185
185
(defcustom cljr-auto-eval-ns-form t
186
186
" When true refactorings which change the ns form also trigger
187
- its re-evaluation." )
187
+ its re-evaluation."
188
+ :group 'cljr
189
+ :type 'boolean )
190
+
191
+ (defcustom cljr-thread-all-but-last nil
192
+ " When true cljr-thread-first-all and cljr-thread-last-all don't thread
193
+ the last expression."
194
+ :group 'cljr
195
+ :type 'boolean )
188
196
189
197
(defvar clj-refactor-map (make-sparse-keymap ) " " )
190
198
@@ -1636,28 +1644,32 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-thread"
1636
1644
((looking-at " [^-]*->>[\n\r\t ]" ) (cljr--thread-last)))))
1637
1645
1638
1646
;;;### autoload
1639
- (defun cljr-thread-first-all ()
1647
+ (defun cljr-thread-first-all (but-last )
1640
1648
" Fully thread the form at point using ->.
1641
1649
1642
1650
See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-thread-first-all"
1643
- (interactive )
1651
+ (interactive " P " )
1644
1652
(save-excursion
1645
1653
(paredit-wrap-round)
1646
1654
(insert " -> " ))
1647
1655
(while (save-excursion (cljr-thread))
1648
- t ))
1656
+ t )
1657
+ (when (or but-last cljr-thread-all-but-last)
1658
+ (cljr-unwind)))
1649
1659
1650
1660
;;;### autoload
1651
- (defun cljr-thread-last-all ()
1661
+ (defun cljr-thread-last-all (but-last )
1652
1662
" Fully thread the form at point using ->>.
1653
1663
1654
1664
See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-thread-last-all"
1655
- (interactive )
1665
+ (interactive " P " )
1656
1666
(save-excursion
1657
1667
(paredit-wrap-round)
1658
1668
(insert " ->> " ))
1659
1669
(while (save-excursion (cljr-thread))
1660
- t ))
1670
+ t )
1671
+ (when (or but-last cljr-thread-all-but-last)
1672
+ (cljr-unwind)))
1661
1673
1662
1674
; ; ------ let binding ----------
1663
1675
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ Feature: Threading and unwinding of macros
351
351
"""
352
352
353
353
Scenario : Unwind all (->>)
354
- When I insert:
354
+ When I insert:
355
355
"""
356
356
(->> (make-things)
357
357
(filter even?)
@@ -363,3 +363,23 @@ Feature: Threading and unwinding of macros
363
363
"""
364
364
(map square (filter even? (make-things)))
365
365
"""
366
+
367
+ Scenario : Thread first all (->) part 2, but last
368
+ When I insert "(->map (assoc {} :key " value") :lock)"
369
+ And I place the cursor before "(->map (assoc"
370
+ And I press "C-u C-! tf"
371
+ Then I should see:
372
+ """
373
+ (-> (assoc {} :key "value")
374
+ (->map :lock))
375
+ """
376
+
377
+ Scenario : Thread last all (->>) part 2, but last
378
+ When I insert "(map square (filter even? (make-things)))"
379
+ And I place the cursor before "(map square"
380
+ And I press "C-u C-! tl"
381
+ Then I should see:
382
+ """
383
+ (->> (filter even? (make-things))
384
+ (map square))
385
+ """
You can’t perform that action at this time.
0 commit comments