[slime-devel] encoding problem ?

Harald Hanche-Olsen hanche at math.ntnu.no
Tue Apr 25 14:01:11 UTC 2006


+ Jean-Christophe Helary <fusion at 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



More information about the slime-devel mailing list