Skip to content

Instantly share code, notes, and snippets.

@sharapeco sharapeco/jshint.l
Created Dec 4, 2013

Embed
What would you like to do?
xyzzy で JSHint
(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
You can’t perform that action at this time.