[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: matching different line number format in grep-mode
From: |
Aurélien Aptel |
Subject: |
Re: matching different line number format in grep-mode |
Date: |
Wed, 27 Jun 2012 13:41:38 +0200 |
On Wed, Jun 27, 2012 at 10:31 AM, Jim Newton
<jimka.velizy@googlemail.com> wrote:
> can you show me how to do this with define-compilation-mode?
I don't know what define-compilation-mode is, but why can't you use
the compilation-mode and the compilation-error-regexp-alist variable?
Eval this in your scratch buffer (select everything and run M-x eval-region):
(require 'compile)
(add-to-list 'compilation-error-regexp-alist '("^at line
\\([0-9]+\\) in file \\(.+\\)$" 2 1))
I've used this as a test (it works):
M-x compile RET echo at line 42 in file /foo/bar RET
To make it permanent you can add this to your .emacs:
(eval-after-load "compile"
'(add-to-list 'compilation-error-regexp-alist '("^at line
\\([0-9]+\\) in file \\(.+\\)$" 2 1)))
You have to use eval-after-load in your .emacs because the variable
compilation-...-alist is defined only once compile.el is loaded. And
it is automatically loaded when you call M-x compile or any autoloaded
function in compile.el (the ones with the ;;;###autoload cookie
above).
Alternatively you could just copy what you've pasted in *scratch* in
your .emacs but it load compile.el every time you start emacs i.e. it
will slightly slowdown your emacs startup time.
I'm sorry if all of this is obvious to you.