elisp compile, add a regexp to error detection

Posted by Gauthier on Stack Overflow See other posts from Stack Overflow or by Gauthier
Published on 2010-03-19T15:49:32Z Indexed on 2010/03/19 19:01 UTC
Read the original article Hit count: 532

Filed under:
|
|
|

I am starting with emacs, and don't know much elisp. Nearly nothing, really.

I want to use ack as a replacement of grep.

These are the instructions I followed to use ack from within emacs: http://www.rooijan.za.net/?q=ack_el

Now I don't like the output format that is used in this el file, I would like the output to be that of ack --group.

So I changed:

(read-string "Ack arguments: " "-i" nil "-i" nil)

to:

(read-string "Ack arguments: " "-i --group" nil "-i --group" nil)

So far so good. But this made me lose the ability to click-press_enter on the rows of the output buffer. In the original behaviour, compile-mode was used to be able to jump to the selected line.

I figured I should add a regexp to the ack-mode. The ack-mode is defined like this:

(define-compilation-mode ack-mode "Ack"
  "Specialization of compilation-mode for use with ack."
   nil)

and I want to add the regexp [0-9]+: to be detected as an error too, since it is what every row of the output bugger includes (line number).

I've tried to modify the define-compilation-modeabove to add the regexp, but I failed miserably.

How can I make the output buffer of ack let me click on its rows?

--- EDIT, I tried also: ---

(defvar ack-regexp-alist 
    '(("[0-9]+:"
     2 3))
  "Alist that specifies how to match rows in ack output.")

(setq compilation-error-regexp-alist
      (append compilation-error-regexp-alist
          ack-regexp-alist))

I stole that somewhere and tried to adapt to my needs. No luck.

© Stack Overflow or respective owner

Related posts about emacs

Related posts about elisp