Skip to content

Commit 7941d90

Browse files
tsulejbenedekfazekas
authored andcommitted
Cygwin path fix. (#357)
[Fix clojure-emacs/refactor-nrepl#183] Converting between unix-like path when sending requests through the nREPL if necessary. * Cygwin path conversion fix. Converting between unix-like path (cygwin, emacs) and Windows path (REPL) when sending requests through the nREPL. Cygwin fix - changelog updated * updated after code review leftover after local test removed
1 parent 46a9253 commit 7941d90

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [#320](https://github.com/clojure-emacs/clj-refactor.el/issues/320) `*data-readers*` ignored when searching for macros.
2626
- [#339](https://github.com/clojure-emacs/clj-refactor.el/issues/339) Teach stop refer to understand multiline refer clauses.
2727
- [#341](https://github.com/clojure-emacs/clj-refactor.el/issues/341) Avoid creating circular dependencies with move form when source namespace refers to the target namespace with a require.
28+
- [refactor-nrepl#183](https://github.com/clojure-emacs/refactor-nrepl/issues/183) Applied conversion between Unix-like path generated by Emacs under Cygwin and Windows-like path required by nREPL. Cider functions `cider-to-nrepl-filename-function` and `cider-from-nrepl-filename-function` are used.
2829

2930
## 2.2.0
3031

clj-refactor.el

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-promote-function
23502350
(= (point) (cljr--point-after 'end-of-buffer)))
23512351

23522352
(defun cljr--find-symbol-sync (symbol ns)
2353-
(let* ((filename (buffer-file-name))
2353+
(let* ((filename (funcall cider-to-nrepl-filename-function (buffer-file-name)))
23542354
(line (line-number-at-pos))
23552355
(column (1+ (current-column)))
23562356
(dir (cljr--project-dir))
@@ -2373,7 +2373,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-promote-function
23732373
occurrences))
23742374

23752375
(defun cljr--find-symbol (symbol ns callback)
2376-
(let* ((filename (buffer-file-name))
2376+
(let* ((filename (funcall cider-to-nrepl-filename-function (buffer-file-name)))
23772377
(line (line-number-at-pos))
23782378
(column (1+ (current-column)))
23792379
(dir (cljr--project-dir))
@@ -2401,8 +2401,12 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-promote-function
24012401
root."
24022402
(s-chop-prefix (cljr--project-dir) path))
24032403

2404+
(defun cljr--get-valid-filename (hash)
2405+
"Get :file value from the hash table and convert path if necessary."
2406+
(funcall cider-from-nrepl-filename-function (gethash :file hash)))
2407+
24042408
(defun cljr--format-symbol-occurrence (occurrence)
2405-
(let ((file (gethash :file occurrence ))
2409+
(let ((file (cljr--get-valid-filename occurrence))
24062410
(line (gethash :line-beg occurrence))
24072411
(col (1- (gethash :col-beg occurrence)))
24082412
(match (gethash :match occurrence)))
@@ -2421,7 +2425,7 @@ root."
24212425
(-when-let (occurrence-data (nrepl-dict-get occurrence-resp "occurrence"))
24222426
(let* ((occurrence (edn-read occurrence-data))
24232427
(occurrence-id (format "%s%s"
2424-
(gethash :file occurrence)
2428+
(cljr--get-valid-filename occurrence)
24252429
(gethash :line-beg occurrence))))
24262430
(cl-incf cjr--occurrence-count)
24272431
(unless (member occurrence-id cljr--occurrence-ids)
@@ -2503,7 +2507,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-find-usages"
25032507

25042508
(defun cljr--rename-occurrences (occurrences new-name)
25052509
(dolist (symbol-meta occurrences)
2506-
(let* ((file (gethash :file symbol-meta))
2510+
(let* ((file (cljr--get-valid-filename symbol-meta))
25072511
(line-beg (gethash :line-beg symbol-meta))
25082512
(col-beg (gethash :col-beg symbol-meta))
25092513
(line-end (gethash :line-end symbol-meta))
@@ -2550,7 +2554,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-rename-symbol"
25502554
Also adds the alias prefix to all occurrences of public symbols in the namespace.
25512555
"
25522556
(cljr--ensure-op-supported "find-used-publics")
2553-
(let ((filename (buffer-file-name)))
2557+
(let ((filename (funcall cider-to-nrepl-filename-function (buffer-file-name))))
25542558
(let* ((alias (or alias
25552559
(cljr--prompt-user-for (format "alias for [%s]: " ns))))
25562560
(request
@@ -2937,7 +2941,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-add-stubs"
29372941

29382942
(defun cljr--delete-definition (definition)
29392943
"Delete a definition as part of inlining a symbol."
2940-
(let ((file (gethash :file definition))
2944+
(let ((file (cljr--get-valid-filename definition))
29412945
(line-beg (gethash :line-beg definition))
29422946
(col-beg (gethash :col-beg definition)))
29432947
(with-current-buffer (find-file-noselect file)
@@ -3000,7 +3004,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-add-stubs"
30003004

30013005
(defun cljr--inline-symbol (definition occurrences)
30023006
(dolist (symbol-meta (cljr--sort-occurrences occurrences))
3003-
(let* ((file (gethash :file symbol-meta))
3007+
(let* ((file (cljr--get-valid-filename symbol-meta))
30043008
(line-beg (gethash :line-beg symbol-meta))
30053009
(col-beg (gethash :col-beg symbol-meta))
30063010
(def (gethash :definition definition)))
@@ -3050,7 +3054,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-inline-symbol"
30503054
(when (cljr--asts-y-or-n-p)
30513055
(save-buffer)
30523056
(save-excursion
3053-
(let* ((filename (buffer-file-name))
3057+
(let* ((filename (funcall cider-to-nrepl-filename-function (buffer-file-name)))
30543058
(line (line-number-at-pos))
30553059
(column (1+ (current-column)))
30563060
(dir (cljr--project-dir))
@@ -3857,7 +3861,7 @@ Point is assumed to be at the function being called."
38573861
;; The OCCURRENCES are the same as those returned by `cljr--find-symbol'
38583862
(let ((*cljr--noninteractive* t))
38593863
(dolist (symbol-meta occurrences)
3860-
(let ((file (gethash :file symbol-meta))
3864+
(let ((file (cljr--get-valid-filename symbol-meta))
38613865
(line-beg (gethash :line-beg symbol-meta))
38623866
(col-beg (gethash :col-beg symbol-meta))
38633867
(name (gethash :name symbol-meta))

0 commit comments

Comments
 (0)