Skip to content

Commit 5aa1a38

Browse files
committed
[Fix #531] Don't match strings when using clojure-rename-ns-alias.
1 parent fae40b9 commit 5aa1a38

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

clojure-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,8 @@ lists up."
26682668
(replace-match (concat ":as " new-alias))))
26692669
(save-excursion
26702670
(while (re-search-forward (concat current-alias "/") nil t)
2671-
(replace-match (concat new-alias "/"))))
2671+
(when (not (eq 'font-lock-string-face (get-text-property (point) 'face)))
2672+
(replace-match (concat new-alias "/")))))
26722673
(save-excursion
26732674
(while (re-search-forward (concat "#::" current-alias "{") nil t)
26742675
(replace-match (concat "#::" new-alias "{"))))

test/clojure-mode-refactor-rename-ns-alias-test.el

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,26 @@
5555
5656
(+ (lib/a 1) (b 2))"
5757

58-
(clojure--rename-ns-alias-internal "foo" "bar")))
58+
(clojure--rename-ns-alias-internal "foo" "bar"))
5959

60-
(provide 'clojure-mode-refactor-rename-ns-alias-test)
60+
(when-refactoring-it "should skip strings"
61+
"(ns cljr.core
62+
(:require [my.lib :as lib]))
63+
64+
(def dirname \"/usr/local/lib/python3.6/site-packages\")
65+
66+
(+ (lib/a 1) (b 2))"
67+
68+
"(ns cljr.core
69+
(:require [my.lib :as foo]))
70+
71+
(def dirname \"/usr/local/lib/python3.6/site-packages\")
72+
73+
(+ (foo/a 1) (b 2))"
74+
75+
(font-lock-fontify-buffer)
76+
(clojure--rename-ns-alias-internal "lib" "foo")))
77+
78+
(provide 'clojure-mode-refactor-rename-ns-alias-test)
6179

6280
;;; clojure-mode-refactor-rename-ns-alias-test.el ends here

0 commit comments

Comments
 (0)