Documentation pop up text shows "^M" on Windows
wrn opened this issue · 4 comments
Now the text will show fully in the pop up, but the end of line "^M" are still there. Can be fixed with an extra replace-regexp-in-string "\r" "".
(defun ac-nrepl-documentation (symbol)
"Return documentation for the given SYMBOL, if available."
(substring-no-properties
(replace-regexp-in-string "\r" "" ;; remove "^M" on Windows
(replace-regexp-in-string
"^( |-------------------------\r?\n)" ""
(plist-get (nrepl-send-string-sync
(format "(clojure.repl/doc %s)" symbol)
(nrepl-current-ns))
:stdout)))))
Hmm, okay, I see what you mean; I think it's probably due to having unix line endings in your source code files, but windows line endings for the backend. I'm not sure that your fix is safe in all configurations, but let's try it and see what happens.
Thanks for taking the fix. I did not test it on Linux so maybe other people can verify it works there.
I don't think the cause is related to my source code file. This happens in a nREPL client buffer. I think it is due to Clojure "doc" function or/and its internal doc string storage. Given Java (and hence Clojure) is supposed to be cross-platform yet the line-endings cannot adapt to the local OS, that does not give a good first impression for people using Windows. I hope someone can fix the issue in Clojure.
Consider also the possibility that popup.el (used by auto-complete) is not handling the native line endings correctly. I'm not convinced that there's anything wrong with Java or Clojure's behaviour here.
That's possible but does not seem like the case, because even the string displayed with "(doc list)" in a nREPL buffer, or with M-x nrepl-doc has the extra "^M". I even looked at the hex bytes of the doc string and clearly there is an extra "\r" character at every line ending.