牌語備忘録 -pygo

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

牌語備忘録 -pygo

js2-mode forked and Flymake Google Closure Linter


(MacOSX10.7, Emacs24.1)

js2-mode forked

init.el
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.\\(js\\|js.erb\\)\\'" . js2-mode))
(add-hook 'js2-mode-hook
          #'(lambda ()
              (require 'js)
              (setq js2-basic-offset 2
                    indent-tabs-mode nil)
              (define-key js2-mode-map (kbd "C-m") 'newline-and-indent)
              (define-key js2-mode-map (kbd "<return>") 'newline-and-indent)
              ))

Google Closure Linter

The Closure Linter is a utility that checks JavaScript files for style issues such as operator placement, missing semicolons, spacing, the presence of JsDoc annotations, and more.

install
sudo port install closure-linter
init.el

flymake Closure Linter

(defun flymake-gjslint-init ()
  "Initialize flymake for gjslint"
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                     'flymake-create-temp-inplace)))
    ;; (list "gjslint" (list temp-file "--nosummary"))))
    (list "gjslint" (list temp-file "--nosummary"))))
(add-to-list 'flymake-allowed-file-name-masks
             '(".+\\.js$"
               flymake-gjslint-init
               flymake-simple-cleanup
               flymake-get-real-file-name))
(add-to-list 'flymake-err-line-patterns
             '("^Line \\([[:digit:]]+\\), E:[[:digit:]]+: "
               nil 1 nil))
(add-hook 'js2-mode-hook (lambda () (flymake-mode t)))