Skip to content

Commit b2d6d39

Browse files
anthonygaleabbatsov
authored andcommitted
Add refactoring command clojure-rename-ns-alias (#529)
Originally requested in clj-refactor: clojure-emacs/clj-refactor.el#366.
1 parent b111dfc commit b2d6d39

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
;;; clojure-mode-refactor-rename-ns-alias-test.el --- Clojure Mode: refactor rename ns alias -*- lexical-binding: t; -*-
2+
3+
;; This file is not part of GNU Emacs.
4+
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
;;; Code:
19+
20+
(require 'clojure-mode)
21+
(require 'ert)
22+
23+
(def-refactor-test test-rename-ns-alias
24+
"(ns cljr.core
25+
(:require [my.lib :as lib]))
26+
27+
(def m #::lib{:kw 1, :n/kw 2, :_/bare 3, 0 4})
28+
29+
(+ (lib/a 1) (b 2))"
30+
"(ns cljr.core
31+
(:require [my.lib :as foo]))
32+
33+
(def m #::foo{:kw 1, :n/kw 2, :_/bare 3, 0 4})
34+
35+
(+ (foo/a 1) (b 2))"
36+
(clojure--rename-ns-alias-internal "lib" "foo"))
37+
38+
(def-refactor-test test-rename-ns-alias-with-missing-as
39+
"(ns cljr.core
40+
(:require [my.lib :as lib]))
41+
42+
(def m #::lib{:kw 1, :n/kw 2, :_/bare 3, 0 4})
43+
44+
(+ (lib/a 1) (b 2))"
45+
"(ns cljr.core
46+
(:require [my.lib :as lib]))
47+
48+
(def m #::lib{:kw 1, :n/kw 2, :_/bare 3, 0 4})
49+
50+
(+ (lib/a 1) (b 2))"
51+
(clojure--rename-ns-alias-internal "foo" "bar"))
52+
53+
(provide 'clojure-mode-refactor-rename-ns-alias-test)
54+
55+
;;; clojure-mode-refactor-rename-ns-alias-test.el ends here

0 commit comments

Comments
 (0)