1

I'm a ClojureScript newbie using emacs, cider, cljsbuild, and austin with slimerjs on a Windows machine. I've noted that sometimes when I type into the clojurescript repl, an extra ^M character and nil are appended to the output (but the return value is not nil, as indicated by the output of the repl enclosed below). The output before the ^M is colored red, while the nil output is black. What could be causing this, and how can I fix this? (Should I be reporting this as an issue to one of the project's trackers?)

cljs.user> 1
1
cljs.user> true
true
cljs.user> (reduce + [1 2 3])
6
cljs.user> (list [1 2 3])
([1 2 3])
cljs.user> reduce
#<function (a,e,f){switch(arguments.length){case 2:return b.call(this,
a,e);case 3:return c.call(this,a,e,f)}throw Error("Invalid arity: "+arguments.length);}>^M
nil
cljs.user> js/document
#<[object HTMLDocument]>^M
nil
cljs.user> (def d js/document)
#<[object HTMLDocument]>^M
nil
cljs.user> (nil? d)
false
juan.facorro
  • 9,791
  • 2
  • 33
  • 41
Anonymous
  • 739
  • 7
  • 15

1 Answers1

2

^M is windows line ending. Answer how ho hide it in Emacs can be found here.

Printing of nil in general is normal behaviour and it's not specific to Clojurescript or Emacs. All forms return a value (which may be nil) and also may produce side-effects:

cljs.user> (println 1) 
1 ; Side effect - printed value
nil ; Result of evaluation

However returning nil for js/document, (def d js/document) and similar "not-nil" forms is Austin specific behaviour and probably can be treated as minor bug.

Community
  • 1
  • 1
Jarlax
  • 1,586
  • 10
  • 20
  • Thanks! I also added `(add-hook 'cider-repl-mode-hook 'remove-dos-eol)` to activate remove-dos-eol whenever I was in a REPL. – Anonymous Jan 28 '15 at 16:25