在 Emacs 中使用 Node.js 和 JS-comint [英] Using Node.js with JS-comint in Emacs

查看:26
本文介绍了在 Emacs 中使用 Node.js 和 JS-comint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Emacs 24.2.我已经从 MELPA<安装了 js-comintjs-mode/a>,执行 run-js,现在在 REPL 而不是 > 符号我有这个胡言乱语:

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

REPL 本身在 Inferior Javascript 模式下工作得很好,只是 > 符号被改变了.如果您输入未完成的表达式,它甚至会打印 ^[[1G... ^[[0K^[[5G].^[ 是系统字符,不是用复制粘贴复制的,我把它们加起来让你有想法.

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.

在我的初始化文件中:

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

在终端调用 nodejs 产生工作 REPL.

In terminal calling nodejs produces working REPL.

为什么提示会这样?我应该怎么做才能纠正这个问题?

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

推荐答案

(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 "33\[[0-9]+[GK]" "" output)))))

33 是它打印为 ^[ 的转义字符.

33 is the escape character it prints as ^[.

这篇关于在 Emacs 中使用 Node.js 和 JS-comint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆