File tree 2 files changed +30
-8
lines changed
2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -1446,12 +1446,10 @@ With a prefix add a declaration for the symbol under the cursor instead.
1446
1446
1447
1447
See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-add-declaration"
1448
1448
(interactive "P")
1449
- (if for-thing-at-point-p
1450
- (cljr--add-declaration (cider-symbol-at-point))
1451
- (save-excursion
1452
- (-if-let (def (cljr--name-of-current-def))
1453
- (cljr--add-declaration def)
1454
- (user-error "Not inside a def form.")))))
1449
+ (-if-let (def (and (not for-thing-at-point-p)
1450
+ (save-excursion (cljr--name-of-current-def))))
1451
+ (cljr--add-declaration def)
1452
+ (cljr--add-declaration (cider-symbol-at-point))))
1455
1453
1456
1454
;; ------ extract constant ----------------
1457
1455
Original file line number Diff line number Diff line change @@ -72,15 +72,15 @@ Feature: Declare current top-level form
72
72
(+ a b))
73
73
"""
74
74
75
- Scenario : Declare the thing at point
75
+ Scenario : Declare the thing at point if outside a def
76
76
When I insert:
77
77
"""
78
78
(ns cljr.core)
79
79
80
80
(foo :bar)
81
81
"""
82
82
And I place the cursor before " :bar"
83
- And I press "C-u C- ! ad"
83
+ And I press "C-! ad"
84
84
Then I should see:
85
85
"""
86
86
(ns cljr.core)
@@ -89,3 +89,27 @@ Feature: Declare current top-level form
89
89
90
90
(foo :bar)
91
91
"""
92
+
93
+ Scenario : Declare the thing at point if inside a def
94
+ When I insert:
95
+ """
96
+ (ns cljr.core)
97
+
98
+ (declare foo)
99
+
100
+ (defn- ^{:meta :data} add
101
+ [a b]
102
+ (bar a b))
103
+ """
104
+ And I place the cursor before " a b"
105
+ And I press "C-u C-! ad"
106
+ Then I should see:
107
+ """
108
+ (ns cljr.core)
109
+
110
+ (declare foo bar)
111
+
112
+ (defn- ^{:meta :data} add
113
+ [a b]
114
+ (bar a b))
115
+ """
You can’t perform that action at this time.
0 commit comments