Using Node.js with JS-comint in Emacs

╄→гoц情女王★ 提交于 2020-01-09 07:14:31

问题


I use Emacs 24.2. I've installed js-comint and js-mode from MELPA, executed run-js, and now in REPL instead of > sign i have this gibberish:

^[[1G> ^[[0K^[[3G

The REPL itself in Inferior Javascript mode works just fine, just the > sign is changed. If you enter unfinished expression, it even prints ^[[1G... ^[[0K^[[5G. The ^[ are system characters, that are not copied with copy-paste, i add them for you to have an idea.

In my init-file:

(require 'js-comint)
(setq inferior-js-program-command "nodejs")

In terminal calling nodejs produces working REPL.

Why prompt behaves this way? What should i do to correct this?


回答1:


(setq inferior-js-mode-hook
      (lambda ()
        ;; We like nice colors
        (ansi-color-for-comint-mode-on)
        ;; Deal with some prompt nonsense
        (add-to-list
         'comint-preoutput-filter-functions
         (lambda (output)
           (replace-regexp-in-string "\033\\[[0-9]+[GK]" "" output)))))

\033 is the escape character it prints as ^[.




回答2:


Just add one line in your .emacs:

(setenv "NODE_NO_READLINE" "1")

Answer come from this post: Node.js prompt '>' can not show in eshell




回答3:


Not sure how recent, but now one can download and use the nodejs-repl.



来源:https://stackoverflow.com/questions/13862471/using-node-js-with-js-comint-in-emacs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!