Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

next-buffer skipping buffers when window is split in emacs

Tags:

emacs

emacs24

I'm a new Emacs user, and learning how to split the window vertically and cycling the buffers in each pane.

However, after opening a new file in one pane, next-buffer does not cycle through this file in the other pane, but only after it has appeared once in the new pane. This can be reproduced as follows:

Open 2 files A and B in a new emacs session.

Split the windows vertically using 'split-window-right'.

'next-buffer' cycles through A and B in PaneLeft and PaneRight.

Open file C in PaneLeft.

'next-buffer' cycles through A, B, C in PaneLeft.

Ensure C is focused in PaneLeft, then switch to PaneRight. 'next-buffer' only cycles through A and B in PaneRight. It skips C possibly because C is already visible in PaneLeft.

Switch back to PaneLeft, and ensure A or B is focused in PaneLeft.

Switch back to PaneRight, now 'next-buffer' cycles through A, B, and C, regardless of what is visible in PaneLeft.

Is this the intended behaviour? How would I get it to work as I intended?

Note: I'm running without any custom extensions, and my .emacs is pretty much empty.

like image 464
Justin Wong Avatar asked Nov 04 '22 05:11

Justin Wong


1 Answers

There is switch-to-visible-buffer variable to control this behavior. From GNU Emacs 24.2's documentation:

switch-to-visible-buffer is a variable defined in `window.el'.
Its value is t

Documentation:
If non-nil, allow switching to an already visible buffer.
If this variable is non-nil, `switch-to-prev-buffer' and
`switch-to-next-buffer' may switch to an already visible buffer
provided the buffer was shown in the argument window before.  If
this variable is nil, `switch-to-prev-buffer' and
`switch-to-next-buffer' always try to avoid switching to a buffer
that is already visible in another window on the same frame.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 24.1 of Emacs.

If this doesn't work as it is supposed to work, there probably is a bug.

like image 138
Praveen Kumar Avatar answered Dec 23 '22 22:12

Praveen Kumar