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

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

Re: how to make next-error work on non-grep non-compilation


From: Stefan Monnier
Subject: Re: how to make next-error work on non-grep non-compilation
Date: Fri, 20 May 2011 09:53:25 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Hi elisp experts,  I have a file which contains grep/compilation style
> output.

Does its name have something specific to its format (e.g. it uses
a particular extension)?

> I'd like to insert that into an Emacs buffer and provide the next-
> error capability to the user.

Do you also want it to be editable at the same time?

> I can't seem to make it work, but I feel like I'm almost there.

Maybe you need to set compilation-error-regexp-alist.

> Any suggestions?  I cannot use the normal compile nor grep interface,
> because the information in the mini-buffer is precious and cannot be
> changed.

Your code seems to add a "-*- grep -*-".  If it can be added to the file
rather than to the buffer, it can reduce the needed code even further.

> (defun skill-vlint-present (file-name)
>   (let ((interesting-output nil)
>         (buf (get-buffer-create " vlint")))
>     (with-current-buffer buf
>       (let ((inhibit-read-only t))
>         (erase-buffer)
>         (compilation-shell-minor-mode t)
>         (setq compilation-auto-jump-to-first-error t)
>         (setq next-error-function `(lambda (n &optional reset)
>                                      (set-buffer ,buf)
>                                      (setq next-error-last-
> buffer ,buf)
>                                      (compilation-next-error n
> reset)))
>         (insert "-*- mode: " "grep-mode"
>                 "; default-directory: " (prin1-to-string default-
> directory)
>                 " -*-\n\n")
>         (let ((pos (point-max)))
>           (insert-file-contents-literally file-name)
>           (setq interesting-output (not (equal pos (point-max)))))

>         (font-lock-fontify-buffer)
>         (goto-char 0)
>         (compilation-compat-parse-errors (point-max))))

Calling `compilation-compat-parse-errors' is a bad idea: just remove the
call, it should not make any difference.
I'd recommend you try something simpler based around something like:

 (let ((buf (find-file-noselect file-name)))
   (grep-mode))


-- Stefan


reply via email to

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