next-error scroll the compilation-errors buffer, so that the current error shows as the first line of the window?
If not, doesn't it at least put the cursor on the current error line? If it does, and if the cursor is not visible enough for you, consider using
hl-line-mode to highlight the current line. Or consider using library
crosshairs to highlight the current line and current column.
Update after your comment
I thought you were invoking
next-error in buffer
*compilation*. If you do that then the line is scrolled to the top, as I described.
But if you are invoking
next-error outside buffer
*compilation* then you need to use
next-error-hook to, in buffer
*compilation*, highlight the current line or fringe or whatever, in whatever way you like.
Here is a quick-and-dirty example:
(defun foo ()
(add-hook 'next-error-hook 'foo)
(Of course, you really only need to turn on
hl-line-mode once in that buffer.
Doing it as shown above is overkill, but it doesn't hurt.
You might think that you could just add
compilation-mode-hook. But when those hooks are invoked there is no
There are two user options that control the ways to indicate the hit in the source buffer (not in the compilation buffer):
next-error-highlight-no-select. They offer the same possibilities, but they are used by different commands. The possibilities include using a fringe arrow or highlighting the match for a certain time.
But there is no such option controlling indication of the current hit in buffer
*compilation*. So Emacs offers two options (where one would probably be enough) for the source buffer but no option for the compilation buffer.
You might consider filing an enhancement request, to get a similar option for the compilation (including grep) buffer:
M-x report-emacs-bug. Using a hook with your own function to perform the highlighting is OK, but it shouldn't be necessary.
And if you just want to change the fringe indicator, you can do this (use whatever fringe bitmap you want, instead of
filled-rectangle -- see (elisp) Fringe Bitmaps for a list of the predefined ones):
(defun bar ()
(unless (eq 'filled-rectangle (cdr (assq 'overlay-arrow fringe-indicator-alist)))
(cons '(overlay-arrow . filled-rectangle) fringe-indicator-alist)))))
(add-hook 'next-error-hook 'bar)
I just discovered that if you turn off showing the left fringe then you will see the behavior I described in the beginning: the window is scrolled to put the current error at the top. So that is another possibility. (It is the behavior I see in my setup, since I do not show fringe.)
There is a bug in this behavior, which I just reported (#20829). What counts (currently, until the bug is fixed) is whether the left fringe is showing in the selected window when you do
C-x ` (
next-error). It is (currently) not enough that the window showing the compilation buffer does not show the left fringe.