Skip to content

Commit 30dfa2d

Browse files
committed
Automatically regexp-quote aliases in rename-ns-alias
This allows for renaming ns aliases with special regex chars like . and *, without having to quote them
1 parent b1ea6de commit 30dfa2d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clojure-mode.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,16 +2686,16 @@ lists up."
26862686
(defun clojure--rename-ns-alias-internal (current-alias new-alias)
26872687
"Rename a namespace alias CURRENT-ALIAS to NEW-ALIAS."
26882688
(clojure--find-ns-in-direction 'backward)
2689-
(let ((rgx (concat ":as +" current-alias))
2689+
(let ((rgx (concat ":as +" (regexp-quote current-alias)))
26902690
(bound (save-excursion (forward-list 1) (point))))
26912691
(when (search-forward-regexp rgx bound t)
26922692
(replace-match (concat ":as " new-alias))
26932693
(save-excursion
2694-
(while (re-search-forward (concat current-alias "/") nil t)
2694+
(while (re-search-forward (concat (regexp-quote current-alias) "/") nil t)
26952695
(when (not (nth 3 (syntax-ppss)))
26962696
(replace-match (concat new-alias "/")))))
26972697
(save-excursion
2698-
(while (re-search-forward (concat "#::" current-alias "{") nil t)
2698+
(while (re-search-forward (concat "#::" (regexp-quote current-alias) "{") nil t)
26992699
(replace-match (concat "#::" new-alias "{"))))
27002700
(message "Successfully renamed alias '%s' to '%s'" current-alias new-alias))))
27012701

0 commit comments

Comments
 (0)