Subject: 25.0.50; next-error-find-buffer chooses non-current buffer without good reason

From: Dmitry Gutov <[email-masked]>
Date: Sun, 03 May 2015 02:17:43 +0300

I've been trying to understand why when the current file-vising buffer
has next-error-function set localy, sometimes `next-error' uses it, and
sometimes it uses next-error-function from next-error-last-buffer.

Looking at the current `next-error-find-buffer', the logic is this:

- If a buffer visible in the current frame has next-error-function set,
  *and* if there's only one such buffer, use it.

- If next-error-last-buffer has it set, use that.

Othewise, if both of the above fail,

- If the current buffer has next-error-function set, use it.

That's nonsense. Why should the question of whether the current buffer's
next-error-function is used be decided by whether there are any other
visible buffers with that variable set.

Apparently, this peculiarity has been there for 10.5 years now,
introduced in 03e75c7e0 by Juri Linkov. But there's no bug reference, nor
a link to a discussion.

I'm guessing it was an attempt to solve a problem of
next-error-last-buffer never being used if the current buffer has
next-error-function. But I think the solution is worse than the problem.
It least the previous behavior was consistent.

In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
 of 2015-05-02 on axl
Windowing system distributor `The X.Org Foundation', version 11.0.11601901
System Description:	Ubuntu 14.10