other-buffer
takes an optional third argument that says it's
okay to use buffers visible in other windows. The relevant bit of
the docstring:
(other-buffer &optional BUFFER VISIBLE-OK FRAME)
Return most recently selected buffer other than BUFFER.
Buffers not visible in windows are preferred to visible buffers, unless
optional second argument VISIBLE-OK is non-nil. Ignore the argument
BUFFER unless it denotes a live buffer. If the optional third argument
FRAME specifies a live frame, then use that frame’s buffer list instead
of the selected frame’s buffer list.
So: the following code should do what you want:
(switch-to-buffer (other-buffer (current-buffer) t))
That's a lot to type, however, so you may as well wrap it in a
command that you can bind to your key of choice:
(defun switcheroo ()
"Switch to the most recent other buffer, even if it's visible
in another window."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) t)))