Subject: Re: bug#1073: 23.0.60; Bad interaction between compilation-scroll-output and dedicated windows

From: "Lennart Borgman (gmail)" <[email-masked]>
Date: Fri, 03 Oct 2008 15:18:25 +0200

martin rudalics wrote:
>> When this code in `compilation-start' is executed:
>>
>>     (if (buffer-local-value 'compilation-scroll-output outbuf)
>>     (save-selected-window
>>       (select-window outwin)
>>       (goto-char (point-max))))
>>
>> outwin is #<window 13 on *compilation*>
>> and after the select-window call (selected-window) is #<window 13
>> on *compilation*>.  However, at this point (current-buffer)
>> returns *test*, rather than *compilation*.
> 
> This is a very, very great nuisance of `select-window'.  Would the
> attached patch DTRT?

I did not try the patch so maybe I misunderstand it. But is not the
problem that (current-buffer) is not the same as (window-buffer)?

If so then perhaps using

  (save-selected-window
    (select-window outwin)
    (with-current-buffer (window-buffer)
      (goto-char (point-max)))

would do the expected thing?

But it looks strange to me. How does one know that this will change the
point in outwin? It would be much cleaner with something like a defmacro
`with-window-buffer' which would take a window as its first argument.
With that defmacro the code would be

  (with-window-buffer outwin
    (goto-char (point-max))