1

我正在观看 Jim Weirich 关于在 Emacs 中使用 JavaScript 的 Y 组合器的演讲之一,网址为http://v.youku.com/v_show/id_XNDQ4NDY0NjM2.html

(我认为,演示文稿与他在 RubyConf 2012 上使用 Ruby 而不是 javascript 给出的内容非常相似。http: //confreaks.com/videos/1287-rubyconf2012-y-not-adventures-in-functional-programming )

我注意到他正在通过“Cc v”快捷方式从 Emacs 内部评估缓冲区中的 JS(通过 node.js,如显示的一些错误消息),并且还将输出返回到另一个缓冲区。

我想知道是否有关于如何在 Windows 上的最新 Emacs 上获取该设置的简单说明(在深入研究 comint/call-process 详细信息之前) ...我搜索过,但到目前为止没有成功。顺便说一句,我已经安装了 node.exe,并且可以按照文章“setting-up-emacs-as-a-javascript-editing-”中的说明,通过“Mx run-js”在 Emacs 中以 REPL 交互方式运行节点以营利为目的的环境”(抱歉不能发布超过 2 个链接……)

谢谢,

/布鲁因

4

2 回答 2

1

我定义了以下函数及其键映射。到目前为止它有效。

(defun node-js-eval-region-or-buffer ()
  "Evaluate the current buffer (or region if mark-active),
   and return the result into another buffer,
   which is to be shown in a window."
  (interactive)
  (let ((debug-on-error t) (start 1) (end 1))
    (cond
     (mark-active
      (setq start (point))
      (setq end (mark)))
     (t
      (setq start (point-min))
      (setq end (point-max))))
    (call-process-region
     start end     ; seems the order does not matter
     "node"        ; node.js
     nil           ; don't delete region
     "node.js"     ; output buffer
     nil)          ; no redisply during output
    (message "Region or buffer evaluated!")
    (setq deactivate-mark t))) ; deactive the region, regardless

(define-key global-map (kbd "C-c v") 'node-js-eval-region-or-buffer)

我还有一点要挖掘:如何自动分屏显示输出缓冲区?我想应该不会太难...

顺便说一句,我为 Windows 安装了 Git 和 Node.js,并将“node.exe”复制到 Git 的“/bin”目录(在安装过程中已添加到 PATH 环境中)。

于 2013-11-05T14:02:51.893 回答
1

安装 js3 模式

然后:

(require 'js-comint)
(setq inferior-js-program-command "node --interactive")
(setenv "NODE_NO_READLINE" "1")
;; Use your favorited js mode here:
(add-hook 'js3-mode-hook '(lambda () 
                (local-set-key "\C-x\C-e" 
                       'js-send-last-sexp)
                (local-set-key "\C-\M-x" 
                       'js-send-last-sexp-and-go)
                (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)
                ))
于 2015-10-20T18:59:34.140 回答