> You should be able to fix this problem by setting
> hl-line-range-function to a suitable function (which should be quite
> simple, AFAIU).
Not really. I tried, setting hl-line-range-function to the next-error
buffer message line after turning on hl-line:
> (with-current-buffer next-error-last-buffer
> (make-variable-buffer-local 'hl-line-range-function)
> (setf hl-line-range-function
> (lambda ()
> (goto-char compilation-current-error)
> (let ((range
> (cons (line-beginning-position) (line-end-position))))
> (message "hl-line-range-function caled. range is %s" range)
See gif below where hl-line-function is not called after commands invoked outside of the next-error buffer:
> Basically, the difference is that hl-line uses post-command-hooks to track the current line and put an overlay
> on it, whereas in this case highlighting only changes whenever next-error-hook is invoked.
>> Is this really important? Those are just implementation details, no?
No, this is exactly the reason why hl-line-range-function doesn't work in the above example. These are
different concepts with different hooks involved that are invoked under different conditions.
post-command-hook means hook is invoked after movement commands, which should not affect err msg line
highlighting, it also means that it may not necessarily be invoked upon next-error.
> (if hl-line-mode
> ;; In case `kill-all-local-variables' is called.
> (add-hook 'change-major-mode-hook #'hl-line-unhighlight nil t)
> (setq hl-line-overlay-buffer (current-buffer))
> (add-hook 'post-command-hook #'hl-line-highlight nil t)
> (add-hook 'post-command-hook #'hl-line-maybe-unhighlight nil t))
> (remove-hook 'post-command-hook #'hl-line-highlight t)
> (remove-hook 'change-major-mode-hook #'hl-line-unhighlight t)
> (remove-hook 'post-command-hook #'hl-line-maybe-unhighlight t)))
Whereas for this enhancement, the only event that affects highlight region is next-error.
Additionally, hl-line and error message highlight and face should be independent:
the user may want current-line highlighting in addition to error message highlighting.