Search code examples
emacsclojureslimetermination

^M Character showing in clojure slime-repl


Each (println...) in my code results in a terminating ^M character appearing in the REPL. I have a lein swank running in a separate window, and I've connected via M-x slime-connect

I think this might be the same issue as Emacs showing ^M in a process buffer but I haven't tried that fix yet.

I've tried changing end-of-line style to unix/dos/mac, and followed some of the other prescriptions I've found online, but I think most of those have to do with actually replacing the ^M either in the file or in the buffer, or writing some elisp which I think is probably overkill. This really should be a check-box someplace, if not literally at least conceptually.

I'm using Emacs 24 + clojure mode + slime + swank on Win7 x64.


Solution

  • This method worked for me: https://stackoverflow.com/a/750933

    Basically just add this code to your .emacs:

    (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 'slime-repl-mode-hook 'remove-dos-eol) ;Remove ^M from clojure repl in windows