Created
December 4, 2013 06:03
-
-
Save sharapeco/7783075 to your computer and use it in GitHub Desktop.
xyzzy で JSHint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun jshint (&optional (filename (get-buffer-file-name))) | |
"jscript-mode: このファイルの文法チェック" | |
(interactive) | |
(let (command | |
(bufname "*JSHint*") | |
(noerror-message "No errors detected") | |
buf | |
line | |
col | |
(error-message nil)) | |
(when filename | |
(save-window-excursion | |
(execute-shell-command | |
(concat "jshint \"" filename "\"") nil bufname) | |
(switch-to-buffer bufname) | |
(goto-char (point-min)) | |
(unless (looking-for noerror-message) | |
(when (scan-buffer "^.+: line \\([0-9]+\\), col \\([0-9]+\\), .+$" :regexp t) | |
(setq error-message (match-string 0) | |
noerror-message (match-string 0) | |
line (parse-integer (match-string 1)) | |
col (parse-integer (match-string 2)) | |
))) | |
(kill-buffer bufname)) | |
(when error-message | |
(setq buf (get-file-buffer filename)) | |
(unless buf | |
(setq buf (create-file-buffer filename))) | |
(switch-to-buffer buf) | |
(goto-line line) | |
(reverse-region (progn (goto-eol) (point)) | |
(progn (goto-bol) (point)) t) | |
(goto-column (- col 1)) | |
(ding)) | |
(message noerror-message)))) | |
(define-key *jscript-mode-map* '(#\C-c #\l) 'jshint) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment