2013年10月9日水曜日

[Clojure][Emacs] Windows環境のnreplで表示される^Mを消す

Windows環境でnreplを使うと、改行文字の^Mが表示されてしまい、とても目障りだ。

user> (dotimes [i 5] (println (str "hello" i)))
hello0^M ←◆これが目障り
hello1^M
hello2^M
hello3^M
hello4^M
nil
user>

Emacs Lispを使いbuffer-display-tableで^Mを表示しないように設定して、対処した。
もっと簡単な方法は無いのかな?

^Mを消すためのEmacs Lisp

(defun remove-dos-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 []))

(add-hook 'nrepl-repl-mode-hook
 'remove-dos-eol)

適用後

user> (dotimes [i 5] (println (str "hello" i)))
hello0 ← ^M が消えてスッキリ
hello1
hello2
hello3
hello4
nil
user> 

参考





0 件のコメント:

コメントを投稿