[slime-devel] encoding problem ?

I am just starting to use slime (2.0) and noticed the following problem (which may not be a problem but I can't seem to find a solution): I have a source file that includes Japanese, English and French, it is encoded in UTF-8 and when I load it I get:
invalid byte #xE7 in CHARSET:ASCII conversion [Condition of type SIMPLE-ERROR]
Restarts: 0: [ABORT-REQUEST] Abort handling SLIME request. 1: [ABORT] ABORT
Backtrace: <snip>
Is there any way out of this ? If I can't use Unicode to be able to work with multiple languages it really is a pity. Jean-Christophe Helary ps I use CLISP.

In your .emacs you do it like this, so you can not just set the needed coding-system but also have it different depending on the lisp implmenetation used: (require 'slime) (setf slime-lisp-implementations '((sbcl ("sbcl") :coding-system utf-8-unix) (clisp ("clisp") :coding-system utf-8-unix) (cmucl ("lisp") :coding-system iso-latin-1-unix))) (slime-setup) -- Ignas Mikalajūnas

In your .emacs you do it like this, so you can not just set the needed coding-system but also have it different depending on the lisp implmenetation used:
(require 'slime) (setf slime-lisp-implementations '((sbcl ("sbcl") :coding-system utf-8-unix) (clisp ("clisp") :coding-system utf-8-unix) (cmucl ("lisp") :coding-system iso-latin-1-unix))) (slime-setup)
Ignas, thank you for your suggestion. FYI, I am a total Slime/Emacs beginner so I am not sure I understand everything that is going on here... My .emacs for Slime is: ;; slime-mode (add-to-list 'load-path "/Users/bubu/Library/Application\ Support/ Emacs/slime-mode/") (setq inferior-lisp-program "/sw/bin/clisp") (require 'slime) (setf slime-lisp-implementations '((clisp ("clisp") :coding-system utf-8-unix))) (setq slime-net-coding-system 'utf-8-unix) (slime-setup) And I still have the following message when I want to load my file:
invalid byte #xE7 in CHARSET:ASCII conversion [Condition of type SIMPLE-ERROR]
Since I don't understand the error message itself I really have no idea where to look for information. I have set my "Multilingual Environment" to UTF-8 too. I can open the file for edit without any problem, and it shows the Japanese and the French. Even if I set the multilingual environment to Ascii the file is properly opened. Jean-Christophe Helary

+ Jean-Christophe Helary <fusion@mx6.tiki.ne.jp>: | And I still have the following message when I want to load my file: | | > invalid byte #xE7 in CHARSET:ASCII conversion | > [Condition of type SIMPLE-ERROR] You don't tell us how you load the file, but my guess is that you are not doing (load filename :external-format :utf-8). Right? - Harald

Harald,
| And I still have the following message when I want to load my file: | | > invalid byte #xE7 in CHARSET:ASCII conversion | > [Condition of type SIMPLE-ERROR]
You don't tell us how you load the file, but my guess is that you are not doing (load filename :external-format :utf-8). Right?
You are absolutely right. I am trying to go through the Practical Common Lisp book so it is needless to say that I was not even aware that such an option existed. The way I try to load the file is simply: (load "~/path/to/file.txt") For practical purposes I would like to have Slime understand that my default is UTF-8, since I mostly deal with mulilingual files with not overlapping character sets. I think I managed to have Emacs (I use Aquamacs) understand that, since all the .lisp multilingual files I have are properly displayed, so the next step would be to have Slime get that too :) Besides, after I tried: (load "~/Documents/_travail/Programmes/lisp/salut_2.lisp" :external- format :utf-8) I got yet another error message:
OPEN: illegal :EXTERNAL-FORMAT argument :UTF-8 [Condition of type SIMPLE-TYPE-ERROR]
I just checked that the file was properly saved in utf-8. Regards, Jean-Christophe

+ Jean-Christophe Helary <fusion@mx6.tiki.ne.jp>: | I got yet another error message: | > OPEN: illegal :EXTERNAL-FORMAT argument :UTF-8 | > [Condition of type SIMPLE-TYPE-ERROR] Uh-oh. I had somehow jumped to the totally unsupported conclusion that you were running a (not too old) SBCL. If you're running a different Lisp, you may need to check the documentation for that Lisp, or ask on a mailing list for that Lisp. - Harald

Well, at least I know where to look for info now :) Thanks. JC On 2006/04/25, at 18:47, Harald Hanche-Olsen wrote:
+ Jean-Christophe Helary <fusion@mx6.tiki.ne.jp>:
| I got yet another error message: | > OPEN: illegal :EXTERNAL-FORMAT argument :UTF-8 | > [Condition of type SIMPLE-TYPE-ERROR]
Uh-oh. I had somehow jumped to the totally unsupported conclusion that you were running a (not too old) SBCL. If you're running a different Lisp, you may need to check the documentation for that Lisp, or ask on a mailing list for that Lisp.

Jean-Christophe Helary writes:
Harald,
| And I still have the following message when I want to load my file: | | > invalid byte #xE7 in CHARSET:ASCII conversion | > [Condition of type SIMPLE-ERROR] [...] (load "~/Documents/_travail/Programmes/lisp/salut_2.lisp" :external- format :utf-8)
I got yet another error message:
OPEN: illegal :EXTERNAL-FORMAT argument :UTF-8 [Condition of type SIMPLE-TYPE-ERROR]
On clisp, the legal arguments for :EXTERNAL-FORMAT are in the package CHARSET. (load "~/Documents/_travail/Programmes/lisp/salut_2.lisp" :external-format charset:utf-8) (do-external-symbols (cs "CHARSET") (print cs)) -- __Pascal Bourguignon__ http://www.informatimago.com/ Small brave carnivores Kill pine cones and mosquitoes Fear vacuum cleaner

Pascal, Thank you very much for the help. The only place where I could find any kind of reference about :EXTERNAL-FORMAT was the "implementation notes" on the CLISP page. I wonder if there is a more accessible page for people like me :) I don't mind reading docs but I need to have a few things clearly spelled out before I know where to check... Regards, Jean-Christophe On 2006/04/25, at 19:24, Pascal Bourguignon wrote:
On clisp, the legal arguments for :EXTERNAL-FORMAT are in the package CHARSET.
(load "~/Documents/_travail/Programmes/lisp/salut_2.lisp" :external-format charset:utf-8)
(do-external-symbols (cs "CHARSET") (print cs))

Jean-Christophe Helary writes:
The only place where I could find any kind of reference about :EXTERNAL-FORMAT was the "implementation notes" on the CLISP page.
Well, the Hyperspec page about OPEN mentions it, but the only value that you can give to it portably is :DEFAULT http://www.lispworks.com/documentation/HyperSpec/Body/f_open.htm All the other values are implementation dependant, hence the need to look at the specific implementation notes. -- __Pascal_Bourguignon__ _ Software patents are endangering () ASCII ribbon against html email (o_ the computer industry all around /\ 1962:DO20I=1.100 //\ the world http://lpf.ai.mit.edu/ 2001:my($f)=`fortune`; V_/ http://petition.eurolinux.org/

On 2006/04/25, at 20:58, Pascal Bourguignon wrote:
Jean-Christophe Helary writes:
The only place where I could find any kind of reference about :EXTERNAL-FORMAT was the "implementation notes" on the CLISP page.
Well, the Hyperspec page about OPEN mentions it, but the only value that you can give to it portably is :DEFAULT
http://www.lispworks.com/documentation/HyperSpec/Body/f_open.htm
All the other values are implementation dependant, hence the need to look at the specific implementation notes.
How is it possible to give the :external-format argument when doing C- c C-l ? Or rather, is there a way to inform SLIME that the external format is UTF-8 by default ? Jean-Christophe Helary

+ Jean-Christophe Helary <fusion@mx6.tiki.ne.jp>: | How is it possible to give the :external-format argument when doing C- | c C-l ? | Or rather, is there a way to inform SLIME that the external format is | UTF-8 by default ? This answer is getting long-ish, because I want to show you how you could discover the answer to these questions on your own ... In a lisp buffer, type C-h k C-c C-l. You get a help buffer saying C-c C-l runs the command slime-load-file which is an interactive Lisp function in `slime'. Click on the underlined word `slime'. This will take you to the definition of slime-load-file in slime.el: (defun slime-load-file (filename) "Load the Lisp file FILENAME." (interactive (list (read-file-name "Load file: " nil nil nil (if (buffer-file-name) (file-name-nondirectory (buffer-file-name)))))) (let ((lisp-filename (slime-to-lisp-filename (expand-file-name filename)))) (slime-eval-with-transcript `(swank:load-file ,lisp-filename)))) Evidently, there is no ready made way to do what you want: It eventually runs (swank:load-file lisp-filename) in the backend lisp. So you can look up that function: In the slime-repl buffer, run (describe #'swank:load-file). Not terribly helpful. But you can place the cursor over the function name and type M-. (meta-period) which will lead you to the function definition: (defslimefun load-file (filename) (to-string (load filename))) So if you were to say (in-package :swank) (defslimefun load-file (filename) (to-string (load filename :external-format charset:utf-8))) and arrange for this to be loaded after swank.lisp, you should have what you want. The alternative is to tell your lisp to use UTF-8 as the default charset for all load operations. You will have to study the Lisp's documentation for hints on how to do that. - Harald

Jean-Christophe Helary writes:
On 2006/04/25, at 20:58, Pascal Bourguignon wrote:
Jean-Christophe Helary writes:
The only place where I could find any kind of reference about :EXTERNAL-FORMAT was the "implementation notes" on the CLISP page.
Well, the Hyperspec page about OPEN mentions it, but the only value that you can give to it portably is :DEFAULT
http://www.lispworks.com/documentation/HyperSpec/Body/f_open.htm
All the other values are implementation dependant, hence the need to look at the specific implementation notes.
How is it possible to give the :external-format argument when doing C- c C-l ? Or rather, is there a way to inform SLIME that the external format is UTF-8 by default ?
In clisp, by :DEFAULT, CUSTOM:*DEFAULT-FILE-ENCODING* is used. -- __Pascal Bourguignon__ http://www.informatimago.com/ READ THIS BEFORE OPENING PACKAGE: According to certain suggested versions of the Grand Unified Theory, the primary particles constituting this product may decay to nothingness within the next four hundred million years.

How is it possible to give the :external-format argument when doing C- c C-l ? Or rather, is there a way to inform SLIME that the external format is UTF-8 by default ?
In clisp, by :DEFAULT, CUSTOM:*DEFAULT-FILE-ENCODING* is used.
Can I do that from Slime ? Or from Emacs ? Jean-Christophe Helary
participants (4)
-
Harald Hanche-Olsen
-
Ignas Mikalajunas
-
Jean-Christophe Helary
-
Pascal Bourguignon