Giter Site home page Giter Site logo

Problem with file encoding about emacs-eclim HOT 7 CLOSED

senny avatar senny commented on July 17, 2024
Problem with file encoding

from emacs-eclim.

Comments (7)

root42 avatar root42 commented on July 17, 2024

When I manually set the coding-system to utf-8, the completion works.

from emacs-eclim.

senny avatar senny commented on July 17, 2024

I think the problem is the following: Emacs transmits the encoding of the current buffer to eclim. Eclim uses that encoding in the Java-World to read the source file properly. Since Emacs know a wide array of encodings, which are not common because they have suffixes like "-unix" or "-dos" eclim does not understand the encoding.

I skimmed the emacs-eclim source and found the following variable:

(defvar eclim--file-coding-system-mapping
  '(("undecided-dos" . "iso-8859-1")
    ("dos" . "iso-8859-1")
    ("undecided-unix" . "iso-8859-1")
    ("utf-8-dos" . "utf-8")
    ("utf-8-unix" . "utf-8")
    ("utf-8-emacs-unix" . "utf-8")))

It looks like that variable performs the mapping of Emacs encodings into encodings eclim can understand. You should be fine if you add a mapping for your encoding:

(add-to-list 'eclim--file-coding-system-mapping '("iso-latin-1-unix" . "iso-8859-1"))

Since this is a common mistake people will run into it would be nice if you make a pull-request and add the mapping to the emacs-eclim source.

from emacs-eclim.

root42 avatar root42 commented on July 17, 2024

Thanks, this works. Maybe there should be a "default" case, which maps to e.g. iso-8859-1 or utf-8 (which would probably work in a lot of cases), just like the undecided-unix case.

from emacs-eclim.

senny avatar senny commented on July 17, 2024

@root42 I think there should be a better error message when things go wrong but I disagree with the default case. This would swallow error messages and just supply broken completions and features. It's much harder to debug such a situation where things just don't work compared to a straight-forward error-message.

@fred-o What do you think about catching this error and printing a message, which describes how to add new mappings to emacs-eclim?

from emacs-eclim.

root42 avatar root42 commented on July 17, 2024

@senny Yes, I understand. A simple message stating that the coding is unknown to emacs-eclim would have been useful. Maybe you can make the mappings a customizable variable? Usually I just fire up customize when something goes wrong and see if I can turn some knobs to make it work.

from emacs-eclim.

fred-o avatar fred-o commented on July 17, 2024

Something like this? 49ff122

from emacs-eclim.

senny avatar senny commented on July 17, 2024

@fred-o exactly! closing this one.

from emacs-eclim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.