Skip to content

Commit 86e8641

Browse files
Fix sr: add space when alias is after :refer
In case `:refer` is before `:as` clause there was no space between the namespace and the `:as` keyword after the removel of `:refer`.
1 parent d1685b9 commit 86e8641

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

clj-refactor.el

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,9 +1227,14 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-stop-referring"
12271227
(paredit-backward)
12281228
(clojure-delete-and-extract-sexp)
12291229
(clojure-delete-and-extract-sexp)
1230-
(if (looking-back "\\w+ " 3)
1231-
(just-one-space 0)
1232-
(join-line))
1230+
(cond
1231+
((looking-at-p "\\s-*[\\w:]+")
1232+
(just-one-space))
1233+
1234+
((looking-back "\\w+ " 3)
1235+
(just-one-space 0))
1236+
1237+
(t (join-line)))
12331238
(cljr--add-ns-prefix (or alias ns) symbols))))))
12341239

12351240
(defun cljr--add-ns-prefix (ns symbols)

features/stop-refering.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,23 @@ Feature: Stop referring
8989
(+ (lib/a 1) (lib/b 2))
9090
(+ (A 1) (B 2))
9191
"""
92+
93+
Scenario: With :as after the :refer
94+
When I insert:
95+
"""
96+
(ns cljr.core
97+
(:require [my.lib :refer [a b] :as lib]))
98+
99+
(+ (a 1) (b 2))
100+
(+ (A 1) (B 2))
101+
"""
102+
And I place the cursor before "my.lib"
103+
And I press "C-! sr"
104+
Then I should see:
105+
"""
106+
(ns cljr.core
107+
(:require [my.lib :as lib]))
108+
109+
(+ (lib/a 1) (lib/b 2))
110+
(+ (A 1) (B 2))
111+
"""

0 commit comments

Comments
 (0)