3

The output of certain compilers (e.g., LaTeX) is incredibly difficult to parse using an error format string. There are always edge cases that leave out the context of errors. So, is there any way I can see the context of the error in the quickfix window? By more context, I mean the ability to jump to the position in the error log corresponding to an error.

  • What's your current errorformat setting? – Rich Dec 19 '16 at 16:19
  • @Rich, something similar to :help errorformat-LaTeX. The thing is that, the error output produced by LaTeX is so garbled that parsing it using an error format becomes cumbersome. I know I could write a filter script that filters the error output, but I was wondering if I could use a rudimentary error format that'll list the all the errors (with/without the context) and then move to the relevant line in the error log from the QuickFix window. – StrangeAttractor Dec 19 '16 at 16:40
  • 1
    I wrote an answer below. I don't have any experience with LaTeX errorformats specifically, but I do have experience with writing rudimentary errorformats and then reading the rest of the necessary information from context, so hopefully this helps! ;) – Rich Dec 20 '16 at 10:39
2

I'm not aware of any built-in mechanism of jumping to the location of an error in the error log.

However, the default behaviour of errorformat is to include all of the makeprg output, so context can be seen in the quickfix window itself.

The errorformat described in :help errorformat-LaTeX includes a number of patterns specifically intended to hide matching lines from the quickfix window (see :help efm-ignore):

\%-GSee\ the\ LaTeX%m,
\%-GType\ \ H\ <return>%m,
\%-G\ ...%.%#,
\%-G%.%#\ (C)\ %.%#,
\%-G(see\ the\ transcript%.%#),
\%-G\\s%#,

Removing these should result in the entire log being displayed.

If that doesn't work, you could also try adding a catch-all pattern to the very end of your errorformat:

set efm+=%+G%.%#

This will match ALL lines which have not already been matched by an earlier pattern in your errorformat. The disadvantage of doing this is that commands like :cnext and :cprevious will no longer skip over these lines, as they would do if you left them unmatched.

(It's more usual to use the negative analogue of this: %-G%.%# as a catch-all to remove all previously unmatched lines from the output.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.