Skip to content

Commit fdac85d

Browse files
pdbrownbbatsov
authored andcommitted
Use appropriate coding system when unzipping jars
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.
1 parent 5993f96 commit fdac85d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
* [#2953](https://github.com/clojure-emacs/cider/issues/2953): Don't font-lock function/macro vars as generic vars.
1616
* [#2964](https://github.com/clojure-emacs/cider/issues/2964): Fix issue with `cider-company-enable-fuzzy-completion` and Helm.
1717
* [#2937](https://github.com/clojure-emacs/cider/issues/2937): Green fringe produced for extra line in rich comment block.
18-
* [#2996]((https://github.com/clojure-emacs/cider/issues/2937)): Fix debugger incorrectly locating `#_` ignored forms.
18+
* [#2996](https://github.com/clojure-emacs/cider/issues/2937): Fix debugger incorrectly locating `#_` ignored forms.
1919
* Bump the injected `cider-nrepl` to 0.25.6. This should fix a compatibility issue with Java 15 and fetching fresh ClojureDocs data.
20+
* [#3004](https://github.com/clojure-emacs/cider/pull/3004): Use appropriate coding system when unzipping jars
2021

2122
### Changes
2223

cider-common.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,18 @@ found."
382382
(t
383383
(with-current-buffer (generate-new-buffer
384384
(file-name-nondirectory entry))
385-
(archive-zip-extract path entry)
385+
;; Use appropriate coding system for bytes read from unzip cmd to
386+
;; display Emacs native newlines regardless of whether the file
387+
;; uses unix LF or dos CRLF line endings.
388+
;; It's important to avoid spurious CR characters, which may
389+
;; appear as `^M', because they can confuse clojure-mode's symbol
390+
;; detection, e.g. `clojure-find-ns', and break `cider-find-var'.
391+
;; `clojure-find-ns' uses Emacs' (thing-at-point 'symbol) as
392+
;; part of identifying a file's namespace, and when a file
393+
;; isn't decoded properly, namespaces can be reported as
394+
;; `my.lib^M' which `cider-find-var' won't know what to do with.
395+
(let ((coding-system-for-read 'prefer-utf-8))
396+
(archive-zip-extract path entry))
386397
(set-visited-file-name name)
387398
(setq-local default-directory (file-name-directory path))
388399
(setq-local buffer-read-only t)

0 commit comments

Comments
 (0)