问题
I am connecting to a swank server from my ClojureBox install. I.e. lein swank
from my project directory and then M-x slime-connect
from EmacsW32.
However, when I do this I see the DOS line-endings everywhere in the REPL (^M
). I.e.
user> (doc map)
-------------------------^M
clojure.core/map^M
([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])^M
Returns a lazy sequence consisting of the result of applying f to the
set of first items of each coll, followed by applying f to the set
of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments.^M
nil
user> (println "foo")
foo^M
I'm aware that this has to do with platform encoding, but I'm having trouble figuring out how to suppress them. I poked around in the EmacsW32 menus and tried the java command line system property (in lein.bat) -Dfile.encoding=ISO-8859-1
to no avail.
I've also found other questions about doing global find/replace of ^M within buffers - but I want to filter REPL output.
I also noticed the following in the *inferior-lisp*
buffer:
(do (.. java.net.InetAddress getLocalHost getHostAddress) nil)(swank.swank/start-server "c:/Users/noahz/AppData/Local/Temp/slime.4912" :encoding "iso-latin-1-unix")
回答1:
I have this in my .emacs:
(defun hide-eol ()
"Do not show ^M in files containing mixed UNIX and DOS line endings."
(interactive)
(setq buffer-display-table (make-display-table))
(aset buffer-display-table ?\^M []))
I just call it with M-x hide-eol when required. You could bind a key, or put it in a hook of some sort if you prefer.
Credit is due to persons unknown - I copied this function from somewhere, but I don't remember where.
回答2:
C-x RET f then type unix-undecided or similar. Then save your file. Basically, you want to change the end-of-line convention for the file.
If this is not your file and you cannot save it, you can use M-% then type C-q C-m followed by RET
and then just RET
, to query-replace `C-M' with nothing.
Oops -- scratch all of that. I see now that you are not working with a file, but with REPL output. Dunno whether it will help, but maybe you can still use C-x RET f, but enter dos
so you at least won't see the ^Ms. If that's not good enough, hopefully someone else will have an answer.
来源:https://stackoverflow.com/questions/8707679/how-to-get-suppress-m-characters-in-my-clojurebox-emacsw32-repl-connected-to