Skip to content

Commit e63a41d

Browse files
iarenazaexpez
authored andcommitted
Send nREPL-based paths instead of CIDER-based paths
When `cider-path-translations` is in use (e.g., when CIDER is running on the host, but the nREPL is running in a VM or a Docker container) we need to translate the local CIDER-based paths to the remote nREPL-based paths for those operations that send paths to nREPL. We use the new `cider-to-nrepl-filename-function` that is introduced in CIDER pull request #2897, that should be applied before this one. Also includes a fix for #442.
1 parent 9709568 commit e63a41d

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

clj-refactor.el

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -896,12 +896,14 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-rename-file-or-d
896896
(affected-buffers (when (file-directory-p old-path)
897897
(cljr--buffers-visiting-dir old-path)))
898898
(old-path (expand-file-name old-path))
899-
(new-path (cljr--maybe-replace-dash-in-file-name (expand-file-name new-path))))
899+
(new-path (cljr--maybe-replace-dash-in-file-name (expand-file-name new-path)))
900+
(nrepl-new-path (funcall cider-to-nrepl-filename-function new-path))
901+
(nrepl-old-path (funcall cider-to-nrepl-filename-function old-path)))
900902
(when (y-or-n-p (format "Really rename %s to %s?" old-path new-path))
901903
(let* ((changed-files (cljr--call-middleware-sync
902904
(cljr--create-msg "rename-file-or-dir"
903-
"old-path" old-path
904-
"new-path" new-path)
905+
"old-path" nrepl-old-path
906+
"new-path" nrepl-new-path)
905907
"touched"))
906908
(changed-files-count (length changed-files)))
907909
(cond
@@ -2481,7 +2483,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-promote-function
24812483
(let* ((filename (funcall cider-to-nrepl-filename-function (buffer-file-name)))
24822484
(line (line-number-at-pos))
24832485
(column (1+ (current-column)))
2484-
(dir (cljr--project-dir))
2486+
(dir (funcall cider-to-nrepl-filename-function (cljr--project-dir)))
24852487
(request (cljr--create-msg "find-symbol"
24862488
"ns" ns
24872489
"dir" dir
@@ -2505,7 +2507,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-promote-function
25052507
(let* ((filename (funcall cider-to-nrepl-filename-function (buffer-file-name)))
25062508
(line (line-number-at-pos))
25072509
(column (1+ (current-column)))
2508-
(dir (cljr--project-dir))
2510+
(dir (funcall cider-to-nrepl-filename-function (cljr--project-dir)))
25092511
(find-symbol-request
25102512
(cljr--create-msg "find-symbol"
25112513
"ns" ns
@@ -2737,7 +2739,7 @@ removed."
27372739
(unless (and *cljr--noninteractive*
27382740
(not (buffer-modified-p)))
27392741
(save-buffer))
2740-
(let ((path (or path (buffer-file-name)))
2742+
(let* ((path (funcall cider-to-nrepl-filename-function (or path (buffer-file-name))))
27412743
(relative-path (cljr--project-relative-path path)))
27422744
(when-let (new-ns (cljr--call-middleware-sync
27432745
(cljr--create-msg "clean-ns"
@@ -2975,11 +2977,12 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-hotload-dependen
29752977
" "))))
29762978

29772979
(defun cljr--call-middleware-to-find-used-locals (file line column)
2978-
(string-join
2979-
(cljr--call-middleware-sync
2980-
(cljr--create-msg "find-used-locals" "file" file "line" line
2981-
"column" column)
2982-
"used-locals") " "))
2980+
(let ((file (funcall cider-to-nrepl-filename-function file)))
2981+
(string-join
2982+
(cljr--call-middleware-sync
2983+
(cljr--create-msg "find-used-locals" "file" file "line" line
2984+
"column" column)
2985+
"used-locals") " ")))
29832986

29842987
(defun cljr--goto-enclosing-sexp ()
29852988
(let ((sexp-regexp (rx (or "(" "#{" "{" "["))))

0 commit comments

Comments
 (0)