Subject: Re: bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buffers

From: Juri Linkov <[email-masked]>
Date: Tue, 20 Nov 2018 00:28:40 +0200

>>>> Right, we need to support prefix args of C-x <left> and C-x <right>.
>>>
>>> Could you do that please?
>>
>> Like this?
>
> I doubt that
>
> !         (while (<= 0 (setq arg (1- arg)))
> !           (switch-to-next-buffer))))))
>
> and
>
> !         (while (<= 0 (setq arg (1- arg)))
> !           (switch-to-prev-buffer))))))
>
> will DTRT.  They pretend that all these buffers were actually shown in
> the window and thus "presented" to the user.  As a consequence,
> switching from a buffer B to the fourth previous buffer and
> subsequently switching to the next buffer would not get us back to B
> but to the third previous buffer of B at the time we switched to the
> previous buffer.  I suppose you won't like that.

Why not?  'C-2 C-x <left>' could be just a shortcut for
'C-x <left> C-x <left>'.

> What we should probably do instead here is to get the fourth buffer of
> what 'window-prev-buffers' returns and try to switch to that buffer
> either via 'switch-to-buffer' or 'pop-to-buffer-same-window'.

But what if the users don't want to break the chain of
previous/next buffers?  For example:

[buffer-A] [buffer-B] [buffer-C] [buffer-D] [buffer-E]
prev-buffers          current-buffer      next-buffers

After 'C-2 C-x <left>' I'd want to have the same sequence of buffers,
just changing the current buffer:

[buffer-A] [buffer-B] [buffer-C] [buffer-D] [buffer-E]
current-buffer                            next-buffers

Not what you seems to suggest that takes ARGth previous buffer
to display and breaks the order of buffers:

[buffer-B] [buffer-C] [buffer-A] [buffer-D] [buffer-E]
                      current-buffer

IOW, I use 'C-x <left>' and 'C-x <right>' to "scroll" the list
of prev/next buffers.