Can't send funny chars to SLIME
Asked Answered
C

1

7

Although I set UTF-8 everywhere (in my lein project, the slime-lisp group customization, the Emacs buffer itself...), I keep getting this error when trying to run code such as (def beta "β"):

Coding system iso-latin-1-unix not suitable [...]

Happens only in Emacs, not when running lein repl from the command line, for instance.

What could be causing it? I'm using Ubuntu, if that makes any difference.

Cognition answered 16/4, 2012 at 1:43 Comment(5)
by the way... Does .clj file have a character encoding specified that every .clj file have to use? For example Google's Go language specs says that every source code file must be UTF-8 while Java doesn't specify anything (you can use UTF-8 or ISO-8859-1 or what you want for .java source code files). What about .clj file?Lounge
The built-in load-file fn slurps anything so I don't think so...Cognition
All .clj files must be in UTF-8. This isn't documented anywhere (unfortunately), but it is hard-coded into the compiler: github.com/clojure/clojure/blob/…Wildawildcat
@vemv: SLIME's default settings assumes Common Lisp, which has a different tradition of default encoding. If you use clojure-jack-in, it will automatically set the encoding to to utf-8-unix (since it knows you are using Clojure), but if you use "vanilla SLIME" you have to configure this yourself.Wildawildcat
raek: cool, nice find! I don't use clojure-jack-in but plain slime-connect instead. this has the advantage of not creating a swank process each time. so I launch just one swank instance at OS startup, so connections take nothing rather than ~10 seconds (on my machine).Cognition
C
6

you should have following code in your .emacs:

(setq slime-net-coding-system 'utf-8-unix)

and following in your project.clj when you run lein swank (or setup swank.encoding Java system property to utf-8):

:encoding "utf-8"
Crossstaff answered 16/4, 2012 at 7:28 Comment(1)
:encoding "utf-8" made the difference for me; I was using :jvm-opts ["-Dfile.encoding=utf-8"] instead. Thank you!Cognition

© 2022 - 2024 — McMap. All rights reserved.