Re: next-error-last-buffer

From:

Juri Linkov

Subject:

Re: next-error-last-buffer

Date:

Sat, 29 May 2004 00:55:32 +0300

User-agent:

Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:
> A less intrusive (and hence less complete) solution:
>
> - Create a new compilation-last-source-buffer variable.
> - At the end of next-error, set this new variable to the buffer just being
> displayed.
> - at the beginning of next-error check compilation-last-source-buffer:
> if it is equal to current-buffer, then don't consider this buffer as
> a "compilation" buffer (i.e. ignore its next-error-function).
>
> This way if a C-x ` lands us in a diff-mode buffer (because of a *grep* that
> points to a patch file), a subsequent C-x ` in the same buffer will not
> mistakenly step through the diffs of this buffer but will go to the next
> grep match.
For clarity I'd rewrite your solution as a next-error-find-buffer rule:
1. If the current next-error capable buffer is not the last source buffer.
2. If one window on the selected frame displays such buffer, return it.
3. If next-error-last-buffer is set to a live buffer, use that.
...
This will solve the problem.
Perhaps there are situations where it may not work, for example, when
the user switches the source buffers. But it's impossible to guess
whether he switched the source buffer with the intention to start
going through the diffs or he wants to continue visiting grep results.
In the latter case, he can select the *grep* window and type C-m or C-c C-c
to go to the next grep match instead of starting to visit the diffs.
So I think your solution will produce the expected behavior.
--
Juri Linkov
http://www.jurta.org/emacs/