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

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

Re: Compilation error regexp alist doesn't match my compiler anymor


From: Michael Slass
Subject: Re: Compilation error regexp alist doesn't match my compiler anymor
Date: Tue, 25 May 2004 19:24:51 GMT
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl> writes:

>A sample compilation output is:
>
>Classification.nrx:     method getUserObject
>Classification.nrx:     method delete
>Classification.nrx:  965         if
>this.getPublishedSubSchemes().size() \= null then
>Classification.nrx:                                                      ^
>Classification.nrx:          Error: Cannot compare primitive type
>'int' to object reference type 'null'
>Classification.nrx:     method getDeletable
>
>'Classification.nrx' is the file name and '965' is the line number.
>So "^\\(.*\\.nrx:\\)[ \\t]*\\([0-9]+\\)" should be able to match
>it. But then I'm lost in lists.
>
>Any thoughts on matching the above sample output?
>
,----[ C-h v compilation-error-regexp-alist RET ]
| compilation-error-regexp-alist's value is shown below.
| 
| Documentation:
| Alist that specifies how to match errors in compiler output.
| Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
| If REGEXP matches, the FILE-IDX'th subexpression gives the file name, and
| the LINE-IDX'th subexpression gives the line number.  If COLUMN-IDX is
| given, the COLUMN-IDX'th subexpression gives the column number on that line.
| If any FILE-FORMAT is given, each is a format string to produce a file name to
| try; %s in the string is replaced by the text matching the FILE-IDX'th
| subexpression.
| 
| Defined in `compile'.
| 
| Value:
| <snip>
`----

I don't know how much that has changed in the cvs version of emacs,
but the explanation below should let you adapt.

So, you're pretty close: you've got a regex which captures your
filename (and, incorrectly, the trailing colon) into subexp 1, and the
line number in subexp 2.  You want to add an element to
compilation-error-regexp-alist that includes your regex, the capture
index of the filename, and the capture index of the line number, in
that order:
( "^\\(.*\\.nrx\\):[ \\t]*\\([0-9]+\\)" 1 2)
  --- note the colon moved outside the capture parens

Then you want to add the little list above to the place where
compile-mode will find it, compilation-error-regexp-alist.  You do
that with a function called add-to-list
  
Try this:

(add-to-list
 'compilation-error-regexp-alist
 '("^\\(.*\\.nrx\\):[ \\t]*\\([0-9]+\\)" 1 2))

Make sense?
-- 
Mike Slass


reply via email to

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