読者です 読者をやめる 読者になる 読者になる

牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

js2-mode and coffee-mode for Emacs

Emacs Javascript CoffeeScript


mozrepl

MozRepl lets you program Firefox and other Mozilla-based applications from the inside.

https://github.com/bard/mozrepl
Install MozRepl Extension for Firefox

Before it is ready to run the javascript codes in Emacs, an extension of MozRepl for firefox is required. The MozRepl extension is an agent listening the request from Emacs. After the installation, start it from the Tools -> MozRepl -> Start. Now you can run the javascript from within Emacs.

http://michael-yxf.appspot.com/2010/06/28/running-javascript-in-emacs-interactively-with-firefox.html
commands

The following commands are available to use in javascript mode in Emacs.

C-c C-s: open a MozRepl interaction buffer and switch to it
C-c C-l: save the current buffer and load it in MozRepl
C-M-x: send the current function (as recognized by c-mark-function) to MozRepl
C-c C-c: send the current function to MozRepl and switch to the interaction buffer
C-c C-r: send the current region to MozRepl

http://michael-yxf.appspot.com/2010/06/28/running-javascript-in-emacs-interactively-with-firefox.html
init
;; js2-mode forked
;; https://github.com/mooz/js2-mode
(autoload 'js2-mode "js2-mode" nil t)
;; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.\\(js\\|js.erb\\)\\'" . js2-mode)) ;;use rails

(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
(add-hook 'js2-mode-hook 'js2-custom-setup)
(defun js2-custom-setup () (moz-minor-mode 1))

init

;; CoffeeScript Major Mode
;; https://github.com/defunkt/coffee-mode
(require 'coffee-mode)
(add-to-list 'auto-mode-alist
             '("\\.coffee$" . rinari-minor-mode) ;;use rinari-mode
             '("\\.coffee$" . coffee-mode)
             )
(defun coffee-custom ()
  "coffee-mode-hook"
  ;; ;; CoffeeScript uses two spaces.
  ;; (make-local-variable 'tab-width)
  ;; (set 'tab-width 2)
  ;; If you don't have js2-mode
  ;; (setq coffee-js-mode 'javascript-mode)
  ;; ;; if you don't want your compiled files to be wrapped
  ;; (setq coffee-args-compile '("-c" "--bare"))
  ;; ;; *Messages* spam
  ;; (setq coffee-debug-mode t)
  ;; Emacs key binding
  (define-key coffee-mode-map "\C-c\C-c" 'coffee-compile-buffer)
  )
(add-hook 'coffee-mode-hook 'coffee-custom)