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

"charset = utf-8" setting in .editorconfig breaks opening .jar files in emacs #294

Open
steinarb opened this issue Apr 3, 2023 · 8 comments · Fixed by #301
Open

"charset = utf-8" setting in .editorconfig breaks opening .jar files in emacs #294

steinarb opened this issue Apr 3, 2023 · 8 comments · Fixed by #301

Comments

@steinarb
Copy link

steinarb commented Apr 3, 2023

.jar files in Java projects are actually .zip files, which emacs can open natively.

If I have a project with an .editorconfig file, like e.g. this project: https://github.com/steinarb/modelstore
and then builds that project with "mvn clean install"
and then tries opening the jar files in the modelstore/modelstore.services/target/ directory they fail to open correctly:
https://www.bang.priv.no/screenshots/Screenshot%20at%202023-04-03%2007-27-13.png

I bisected my .emacs and found that the offending config was the following in my ~/.emacs:

;; editorconfig formatting support
;;;================================
(when (locate-library "editorconfig")
  (editorconfig-mode 1))

Removing the above config caused jar files to open correctly in .emacs, which BTW looks like this:
https://www.bang.priv.no/screenshots/Screenshot%20at%202023-04-03%2007-54-54.png

Removing the .editorconfig from the project also made .jar files open correctly in .emacs, so I bisected the .editorconfig file and found that the offending line was

charset = utf-8

Removing that line from a project's .editorconfig made .jar files open correctly

@steinarb
Copy link
Author

steinarb commented Apr 3, 2023

I tried fixing this by customizing editorconfig-exclude-modes, adding the following to custom-set-variables in .emacs:

 '(editorconfig-exclude-modes '(Zip-Archive))

But I was unable to open .jar files in a project with .editorconfig files even with the editorconfig-exclude-modes setting in a freshly started emacs.

@steinarb
Copy link
Author

steinarb commented Apr 3, 2023

The editorconfig-exclude-regexps did work for me. I customized editorconfig-exclude-regexps and tried to match buffers ending with .jar:

 '(editorconfig-exclude-regexps '("\\.jar$"))

And after this .jar files opened correctly in a project containing an .editorconfig file.

@steinarb
Copy link
Author

steinarb commented Apr 3, 2023

I removed both customizations and added a handwritten config in .emacs, and the following also works:

;; editorconfig formatting support
;;;================================
(when (locate-library "editorconfig")
  (editorconfig-mode 1)
  (setq editorconfig-exclude-regexps '("\\.jar$")))

@steinarb
Copy link
Author

steinarb commented Apr 3, 2023

Even though I found a config workaround, this probably should be fixed in the way that editorconfig doesn't touch buffers where mode-class is special.

For more detail, please see the following comments for an issue I opened for this on emacs (before I knew it was caused by editorconfig):
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62630#26
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62630#29

@jcs090218
Copy link
Contributor

jcs090218 commented Apr 9, 2023

'(editorconfig-exclude-modes '(Zip-Archive))

This doesn't look right. Do you mean archive-mode? You shouldn't enable editorconfig-mode in the archive-mode, that's why you are getting those errors?

@steinarb
Copy link
Author

steinarb commented Apr 9, 2023 via email

@rprimus
Copy link

rprimus commented Jul 2, 2024

Wed 3 Jul 2024 00:33:50 BST

I've just run into this problem with .zip files (archive-mode). My solution: add the following to .editorconfig:

[*.{zip,jar}]
charset = unset

Neither

(setq editorconfig-exclude-modes '(archive-mode))

nor

(setq editorconfig-exclude-regexps '("\\.jar$" "\\.zip$"))

worked for me.

versions:

editorconfig: Melpa: 20240604.602
emacs: GNU Emacs 29.3 (build 1, aarch64-apple-darwin23.4.0, Carbon Version 170 AppKit 2487.5) of 2024-05-04

@10sr 10sr reopened this Jul 18, 2024
@10sr
Copy link
Member

10sr commented Aug 13, 2024

@rprimus
I could partially reproduce your problem. There was a regression caused by recent change, but I could solve this by setting (setq editorconfig-exclude-regexps '("\\.jar$" "\\.zip$"))...

Anyway I fixed the regression, so please try the latest version and comment if the problem still persists.

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 a pull request may close this issue.

4 participants