help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

JSLint integration: Question


From: aundro
Subject: JSLint integration: Question
Date: 4 Apr 2007 08:40:18 -0700
User-agent: G2/1.0

Hello all,

[I've been searching on the internet and reading the lisp reference
for quite some time now, but there was no real luck..]

First of all, the context: I have been using emacs for quite some
time, without customizing it that much, really.

Now, the problem:
 * I've been coding quite a fair amount of JavaScript for work, lately
 * There's no 'syntactic checking' in emacs, for the JavaScript
language/mode at least
 * I thought I'd integrate the JSLint (http://www.jslint.com/
lint.html) verifier into emacs. To do that, I have added a "write-
contents-hooks" that calls an external program that calls jslint with
the contents of the buffer.
 * The results of JSLint are "collected" by myself, and output to
stdout. That means I have the control on what's output.
 * That output is then collected by emacs, and displayed in a buffer
called *jslint output*

All that works very nicely. The reference and tutorials on the web
have been a great help.

However, I'd like to go a little bit further, and make those lines
that appear in the *jslint output* clickable (pretty much like the
grep output in the *grep* buffer)

That's where I'm stuck; I couldn't find how to 'parse' such lines and
make them "activable" (i.e., clickable, or even <enter>-able).

Could you give me pointers on how to implement that?

Best regards,

          Arnaud.

PS: Here's the code that runs the "jslint" verifier. If anyone wants
to comment it, he's of course welcome, since this is my very first bit
of "real" emacs configuring:

PPS: The 'wraplint.js' file basically builds a string from stdin
(thus, those characters provided by emacs; the contents of the
buffer), passes that string to JSLint, and outputs the errors.

PPPS: Here's a typical error message, the way I format them:
"Error (6,9): Assignment in control part.; while (l = rdr.performSthg
()) {"


------------------------

(add-hook 'javascript-mode-hook 'add-jslint-check)


(defun add-jslint-check ()
  (add-hook 'write-contents-hooks 'jslint-check))


;; JavaScript JSLint hook
(defun jslint-check ()
  (interactive)
  (do-exec-jslint)
  ;; nil from a function in `write-contents-hooks' means
  ;; to continue and write the file as normal
  nil)

(global-set-key "\C-c\C-l" 'jslint-check)


(defun do-exec-jslint ()
  (interactive)
  (shell-command-on-region
   (point-min)
   (point-max)
   "/opt/LINKS/bin/java -jar ~/src/jslint/rhino-1.6R5.jar -f ~/src/
jslint/jslint.js  -f ~/src/jslint/wraplint.js"
   "*jslint output*")
  (display-buffer "*jslint output*" t))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]