Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate paths from CIDER to nREPL and vice-versa #2897

Merged
merged 1 commit into from
Sep 4, 2020

Conversation

iarenaza
Copy link
Contributor

When cider-path-translations is in use (e.g., when CIDER is running
on the host, but the nREPL is running in a virtual machine or a
container) we need to translate from the host "CIDER-based" paths to
the container "nREPL-based" paths and vice-versa, depending on the
operation.

Translations from "nREPL-based" paths to "CIDER-based" paths were
already implemented, but not the other way around. Some operations in
clj-refactor need the "CIDER-based"to "nREPL-based" path translations
to work correctly (e.g., cljr-rename-file-or-dir,
cljr-rename-symbol, etc.).

This patch implements the missing path translations, and is a
pre-requisite for the complementary clj-refactor patch that is
proposed separately.


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • All code passes the linter (eldev lint) which is based on elisp-lint and includes
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the user manual (if adding/changing user-visible functionality)

Thanks!

If you're just starting out to hack on CIDER you might find this section of its
manual
extremely useful.

@bbatsov
Copy link
Member

bbatsov commented Sep 4, 2020

The changes look good to me overall, but if this is going to be public API used by other packages the functions shouldn't have -- in their names. I also think we can expand the relevant documentation.

@iarenaza
Copy link
Contributor Author

iarenaza commented Sep 4, 2020

Hi @bbatsov

I didn't intend any of the new functions to be public. I saw them as just internal implementation details for cider-from-nrepl-filename-function and cider-to-nrepl-filename-function, which I thought was the public API for this functionality. Do you want them to be public?

Regarding the documentation expansion, do you mean the functions documentation or other kind of documentation?

cider-common.el Outdated
Looks at `cider-path-translations' for (container . host) alist of path
prefixes and translates PATH from container to host or viceversa depending on
whether DIRECTION is :from-nrepl or :to-nrepl"
(seq-let [from-fn to-fn path-fn] (cond ((eq direction :from-nrepl) '(car cdr identity))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Emacs Lisp we normally use symbols instead of keywords - e.g. 'from-nrepl.

cider-common.el Outdated
"Attempt to translate the PATH in the given DIRECTION.
Looks at `cider-path-translations' for (container . host) alist of path
prefixes and translates PATH from container to host or viceversa depending on
whether DIRECTION is :from-nrepl or :to-nrepl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget the final ..

@bbatsov
Copy link
Member

bbatsov commented Sep 4, 2020

My bad. I misread the implementation.

When `cider-path-translations` is in use (e.g., when CIDER is running
on the host, but the nREPL is running in a virtual machine or a
container) we need to translate from the host "CIDER-based" paths to
the container "nREPL-based" paths and vice-versa, depending on the
operation.

Translations from "nREPL-based" paths to "CIDER-based" paths were
already implemented, but not the other way around. Some operations in
clj-refactor need the "CIDER-based"to "nREPL-based" path translations
to work correctly (e.g., `cljr-rename-file-or-dir`,
`cljr-rename-symbol`, etc.).

This patch implements the missing path translations, and is a
pre-requisite for the complementary clj-refactor patch that is
proposed separately.
@bbatsov bbatsov merged commit 249d3b5 into clojure-emacs:master Sep 4, 2020
@bbatsov
Copy link
Member

bbatsov commented Sep 4, 2020

Thanks for tackling this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants