Open chrisalcantara opened 3 years ago
How about adding a hook which removes ^M
as below ?
(defun my/quickrun-after-hook ()
(save-excursion
(let ((buffer-read-only nil))
(goto-char (point-min))
(while (re-search-forward "^M" nil t) ;; You need to type `C-q C-m` for inserting `^M` character. This is not two characters `^` and `M`
(replace-match "")))))
(add-hook 'quickrun-after-run-hook #'my/quickrun-after-hook)
Thanks for the suggestion, @syohex. But the regex looks like it's searching for the letter M
at the beginning of each line.
Running a script like this:
main() {
echo "Hello"
}
main()
Turns into this:
ain() {
echo "Hello"
}
ain()
I wonder if this is legal regex syntax: re-search-forward "\\^M" nil t)
using two backslashes to escape the caret?
As I commented, it is not ^
and M
characters, it's carriage return(\r
) character. Can you try to type it by C-q C-m
or M-x quoted-insert
and C-m
.
Got it, @syohex! I didn't read your comment carefully, and now I understand what you meant with c-q c-m
.
For me, I keep getting the
^M
new line character for output. Here is an example when running an emacs-lisp file:I have this is my
init.el
to set the coding system, but it doesn't seem to work.(setq default-buffer-file-coding-system 'utf-8-auto)
I'd appreciate the help.