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

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

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

steinarb opened this issue Apr 3, 2023 · 6 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

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.

2 participants