【问题标题】:Node REPL in Emacs printing my inputEmacs 中的节点 REPL 打印我的输入
【发布时间】:2014-04-05 05:06:32
【问题描述】:

我在我的节点 REPL 中设置一些细节时遇到了麻烦:

每当我在提示符中键入命令时,都会在我从 REPL 获得真正的输出之前重新打印该命令。例如:

var n = 1; 变量 n = 1; 未定义

我尝试使用来自 balajis repo https://github.com/startup-class/dotfiles/blob/master/.emacs.d/js-comint.el 的一些代码,但之后我的 M-x run-js 命令不起作用。

这是我的初始化文件(我还没有编辑我的 js-comint.el):

(normal-erase-is-backspace-mode 1)


(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "~/.emacs.d/auto-complete/")
; Load the default configuration                                                                             
(require 'auto-complete-config)
; Make sure we can find the dictionaries                                                                     
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/dict")
; Use dictionaries by default                                                                                
(setq-default ac-sources (add-to-list 'ac-sources 'ac-source-dictionary))
(global-auto-complete-mode t)
; Start auto-completion after 2 characters of a word                                                         
(setq ac-auto-start 2)
; case sensitivity is important when finding matches                                                         
(setq ac-ignore-case nil)
(add-to-list 'load-path "~/.emacs.d/yasnippet/")
(require 'yasnippet)
(yas-global-mode 1)
;; Load the snippet files themselves                                                                         
(yas/load-directory "~/.emacs.d/yasnippet/snippets/text-mode/javascript-mode/")
;; Let's have snippets in the auto-complete dropdown                                                         
(add-to-list 'ac-sources 'ac-source-yasnippet)

(add-to-list 'auto-mode-alist (cons (rx ".js" eos) 'js2-mode))

(require 'js-comint)
(setq inferior-js-program-command "/usr/bin/java org.mozilla.javascript.tools.shell.Main")
(setq inferior-js-program-command "node")

(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]+[GKCJ]" "" output)))))

(add-hook 'js2-mode-hook '(lambda ()
                           (local-set-key "\C-x\C-e" 'eval-last-sexp)
                           (local-set-key "\C-cb" 'js-send-buffer)
                           (local-set-key "\C-c\C-b" 'js-send-buffer-and-go)
                           (local-set-key "\C-cl" 'js-load-file-and-go)
                           (local-set-key "\C-c!" 'run-js)
                           (local-set-key "\C-c\C-r" 'js-send-region)
                           (local-set-key "\C-c\C-j" 'js-send-line)
                           (local-set-key "\C-c\C-u" 'whitespace-clean-and-compile)
                           ))

【问题讨论】:

    标签: javascript node.js emacs read-eval-print-loop


    【解决方案1】:

    如果您可以稍微改变解决问题的方法,您可以改用replpad。它适用于任何编辑器,在文件更改时自动更新。

    只需通过以下方式安装它:npm install -g replpad

    然后通过运行来使用它:replpad

    如果您希望它监视当前和所有子目录中的所有文件并在它们更改时将它们通过管道传输到 repl 中:replpad .

    更多详情in this answer

    【讨论】:

      【解决方案2】:

      这应该可以解决它:

      (add-hook 'inferior-js-mode-hook
                (lambda ()
                  (setq comint-process-echoes t)))
      

      【讨论】:

        猜你喜欢
        • 2023-03-19
        • 2014-12-31
        • 2015-10-27
        • 1970-01-01
        • 2015-04-21
        • 2012-11-20
        • 2013-08-27
        • 1970-01-01
        相关资源
        最近更新 更多