【问题标题】:How to get suppress ^M characters in my ClojureBox (EmacsW32) REPL connected to lein swank如何在连接到 lein swank 的 ClojureBox (EmacsW32) REPL 中抑制 ^M 字符
【发布时间】:2012-02-01 05:19:31
【问题描述】:

我正在从我的 ClojureBox 安装连接到一个 swank 服务器。 IE。 lein swank 来自我的项目目录,然后M-x slime-connect 来自 EmacsW32。

但是,当我这样做时,我会在 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")

【问题讨论】:

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


    【解决方案1】:

    我的 .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 调用它。您可以绑定一个键,或者如果您愿意,可以将其放入某种钩子中。

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

    【讨论】:

      【解决方案2】:

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

      如果这不是您的文件并且您无法保存它,您可以使用 M-% 然后键入 Cq Cm 后跟 RET 然后只需 RET , 以查询替换“CM”。


      糟糕——从头开始。我现在看到您不是在使用文件,而是使用 REPL 输出。不知道它是否有帮助,但也许你仍然可以使用 C-x RET f,但输入 dos 这样你至少不会看到 ^Ms。如果这还不够好,希望其他人能给出答案。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多