Node.js npm don';t在emacs eshell下正确显示提示
这个问题解决了节点repl的问题,但当您从npm调用节点时,该解决方案不起作用 举个例子,如果我Node.js npm don';t在emacs eshell下正确显示提示,node.js,emacs,npm,Node.js,Emacs,Npm,这个问题解决了节点repl的问题,但当您从npm调用节点时,该解决方案不起作用 举个例子,如果我 $ npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sane defaults. See `npm help json` for definitive documentation on
$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sane defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
^[[1G^[[0Jname: (nodo1) ^[[15G
我知道这个问题可以用“start”来解决:“env NODE\u NO\u READLINE=1 NODE”,但在任何地方写这个并不是一个找到解决方案的方法。也许包的其他用户不使用emacs,需要以其他方式设置env var
我尝试使用npm的别名设置NODE_NO_READLINE=1,但结果相同
alias npm='env NODE_NO_READLINE=1 npm'
这是comint模式,过滤许多shell前端用于为文本着色的特殊字符。如果您曾经通过Emacs与shell程序进行交互,那么您可能熟悉“使用哑终端或Emacs终端”之类的消息。有些可以检测到使用了Emacs或dumb终端,并且不会发送那些无法解释的字符,但Node不会这样做。无论如何,您可以使用以下内容:
(add-to-list
'comint-preoutput-filter-functions
(lambda (output)
(replace-regexp-in-string "\\[[0-9]+[GK]" "" output)))
在你的.emacs中的某个地方
Stackoverflow无法正确复制控制字符,regexp中的第一个字符(引号之后和斜杠之前)是
^[
字符。您可以通过执行C-q 0 3 3在Emacs中输入它。接下来键入的任何内容都会导致将控制字符插入当前缓冲区。您的解决方案在shell上工作,但在eshell中不工作。eshell使用eshell输出过滤器函数进行过滤,因此使用类似的方法(添加到列表“eshell输出过滤器函数”)(lambda()(保存偏移(替换regexp“\[[0-9]+[GKJ]”nil-eshell last output start-eshell last output end)))可以工作,但速度很慢。我想的是如何告诉npm使用节点\u NO\u READLINE=1I get:>console.log('这是以奇怪的方式剪切内容吗?')console.lo('这是以奇怪的方式剪切内容吗?'))这将停止特殊字符,但我不再有g。comint特殊字符格式是什么样的,才能生成正则表达式?正则表达式必须是“\033\[[0-9]+[GK]”,mw才能在将替换表达式修改为“^H”的基础上工作对一些人来说可能更喜欢..例如-显示省略号;当然-它应该是Ctrl-H后跟句号。
(add-to-list
'comint-preoutput-filter-functions
(lambda (output)
(replace-regexp-in-string "\\[[0-9]+[GK]" "" output)))