unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* JSLint integration: Question
@ 2007-04-04 15:40 aundro
  2007-04-05  9:53 ` Kai Grossjohann
       [not found] ` <mailman.1783.1175767033.7795.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: aundro @ 2007-04-04 15:40 UTC (permalink / raw)
  To: help-gnu-emacs


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))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: JSLint integration: Question
  2007-04-04 15:40 JSLint integration: Question aundro
@ 2007-04-05  9:53 ` Kai Grossjohann
       [not found] ` <mailman.1783.1175767033.7795.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Grossjohann @ 2007-04-05  9:53 UTC (permalink / raw)
  To: help-gnu-emacs

aundro@gmail.com writes:

> 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)

Normally, this can be done using compilation-mode.  (You would put
your *jslint output* buffer in compilation-mode.)

There is a variable compilation-error-regexp-alist that tells
compilation-mode how to parse the buffer.  I think all entries there
require that the file name be part of the error message.

Now you have two choices: either you add an entry there for your style
of error messages (after adding the filename), or you modify your
style of error messages to match one of the entries.

Kai

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: JSLint integration: Question
       [not found] ` <mailman.1783.1175767033.7795.help-gnu-emacs@gnu.org>
@ 2007-04-05 12:18   ` Arnaud Diederen (aundro)
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaud Diederen (aundro) @ 2007-04-05 12:18 UTC (permalink / raw)
  To: help-gnu-emacs

Kai Grossjohann <kai@emptydomain.de> writes:
> [...]
> Normally, this can be done using compilation-mode.  (You would put
> your *jslint output* buffer in compilation-mode.)
>
> There is a variable compilation-error-regexp-alist that tells
> compilation-mode how to parse the buffer.  I think all entries there
> require that the file name be part of the error message.
>
> Now you have two choices: either you add an entry there for your style
> of error messages (after adding the filename), or you modify your
> style of error messages to match one of the entries.
>
> Kai

Hello Kai, 

using the compilation-mode's 'compile' function is indeed a much
better solution. 

I just had to re-think a bit the way I was calling the command (the
rhino JS interpreter), and how the output was formatted. 
Also, I needed to set the directory to that of the file I chose to
JSLint, and everything works like a charm!

Best regards,

       A.
 


>
>
>
>

-- 
Arnaud DIEDEREN
Software Developer
IONIC Software
Rue de Wallonie, 18 -  4460 Grace-Hollogne - Belgium
Tel: +32.4.3640364 - Fax: +32.4.2534737
mailto:ad@ionicsoft.com
http://www.ionicsoft.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-05 12:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-04 15:40 JSLint integration: Question aundro
2007-04-05  9:53 ` Kai Grossjohann
     [not found] ` <mailman.1783.1175767033.7795.help-gnu-emacs@gnu.org>
2007-04-05 12:18   ` Arnaud Diederen (aundro)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).