如何在我的ClojureBox(EmacsW32)REPL中连接到lein swank来抑制^ M个字符

时间:2012-01-03 03:46:23

标签: emacs clojure read-eval-print-loop line-endings

我从我的ClojureBox安装连接到swank服务器。即我的项目目录中有lein swank,然后是来自EmacsW32的M-x slime-connect

然而,当我这样做时,我在REPL(^M)中到处都看到DOS行结尾。即。

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

我知道这与平台编码有关,但我无法弄清楚如何抑制它们。我在EmacsW32菜单中探索并尝试了java命令行系统属性(在lein.bat中)-Dfile.encoding=ISO-8859-1无效。

我还发现了有关在缓冲区中进行全局查找/替换^ M的其他问题 - 但我想过滤REPL输出。

我还注意到*inferior-lisp*缓冲区中的以下内容:

(do (.. java.net.InetAddress getLocalHost getHostAddress) nil)(swank.swank/start-server "c:/Users/noahz/AppData/Local/Temp/slime.4912" :encoding "iso-latin-1-unix")

2 个答案:

答案 0 :(得分:4)

我的.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 []))

我只需要在需要时用M-x hide-eol调用它。您可以绑定一个键,或者如果您愿意,可以将它放在某种钩子中。

归功于未知的人 - 我从某个地方复制了这个功能,但我不记得在哪里。

答案 1 :(得分:0)

C-x RET f 然后键入unix-undecided或类似的。然后保存您的文件。基本上,您希望更改文件的行尾约定。

如果这不是您的文件而您无法保存,则可以使用 M - %然后键入 Cq Cm ,然后键入RET,然后只需{ {1}},用什么来查询替换`CM'。


糟糕 - 抓住所有这些。我现在看到你没有使用文件,而是使用REPL输出。不知道它是否有用,但也许你仍然可以使用 C-x RET f ,但输入RET,这样你至少看不到^ Ms。如果这还不够好,希望其他人能得到答案。