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

Use appropriate coding system when unzipping jars #3004

Merged
merged 1 commit into from
Apr 16, 2021

Conversation

pdbrown
Copy link
Contributor

@pdbrown pdbrown commented Apr 16, 2021

in cider-find-file. This prevents CRLF encoded files from appearing with ^M
characters at the end of each line, which, in turn, avoids confusing
clojure-find-ns and breaking cider-find-var.
clojure-find-ns uses Emacs' (thing-at-point 'symbol) as part of identifying
a file's namespace, and when a file isn't decoded properly, namespaces can be
reported as my.lib^M which cider-find-var won't know what to do with.


Hey again! I came across https://github.com/clojure-emacs/cider/discussions/2957 today, where @expez mentions cider-find-var is broken in jars. I do this all the time and it works fine, so I looked into the repro a little and found that cider-find-var was getting confused in cljfx.api, as extracted from its jar, because it has windows line endings.

The nrepl message trace:

(-->
  id         "14"
  op         "info"
  session    "5cf7e082-fe85-448e-bc8f-9bb99e038211"
  time-stamp "2021-04-15 14:33:35.951811315"

  ns         #("cljfx.api^M" 0 10 (fontified nil))
;;                        ^--- broken!

  sym        "event-handler/dispatch-effect"
)
(<--
  id         "14"
  session    "5cf7e082-fe85-448e-bc8f-9bb99e038211"
  time-stamp "2021-04-15 14:33:35.954095391"
  status     ("done" "no-info")
)

The ns value is obtained from clojure-find-ns via (thing-at-point 'symbol), which will include the ^M if it's there.
While we could wrap a (string-trim-right ...) around the ns name somewhere, that shouldn't really be necessary, and clojure-mode uses thing-at-point in several other ways so this might not be the only broken thing. The ^Ms are also a bit of an eyesore, so I think attempting to get rid of them is the way to go. People might still be broken by files with mixed encoding though.


  • 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)

@bbatsov
Copy link
Member

bbatsov commented Apr 16, 2021

The fix looks good. Just mention it in the changelog and we're good to go.

in `cider-find-file`. This prevents CRLF encoded files from appearing with ^M
characters at the end of each line, which, in turn, avoids confusing
`clojure-find-ns` and breaking `cider-find-var`.
`clojure-find-ns` uses Emacs' `(thing-at-point 'symbol)` as part of identifying
a file's namespace, and when a file isn't decoded properly, namespaces can be
reported as `my.lib^M` which `cider-find-var` won't know what to do with.
@bbatsov bbatsov merged commit fdac85d into clojure-emacs:master Apr 16, 2021
@bbatsov
Copy link
Member

bbatsov commented Apr 16, 2021

Thanks!

@pdbrown pdbrown deleted the bugfix/jar-coding-system branch April 16, 2021 20:41
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