Comment 20 for bug 1018996

Revision history for this message
Thomas Caswell (tcaswell-gmail) wrote :

(I apologize now for muddling the terms around emacs windows/buffers...still trying to grok it all)
(also, sorry if this should get it's own issue, but it seems people who care about this are already following this bug)

I think we need the extra switch is necessary for the following reason.

I interpret the new switch as meaning 'try to make sure that the output buffer is visible after the code runs' ( py-on-execute-buffer-management-p )

If buffer management is disabled then everything else is ignored and emacs will not change anything about your buffers/windows.

If buffer management is enabled, then I interpret the switch flag as meaning 'make sure the current buffer/window after execution is the output buffer' and the split flag as 'if needed, emacs may create a new window by splitting the code buffer using the specified method'

This leads to the following logic

I) If there is only one window and splitting is disabled, then
    If switching is on, then we need to set the buffer in that window to the output buffer.
    If switching is off, nothing should change. (this is the one branch where emacs fails to make the output buffer visible)

II) if splitting is enabled and output buffer is not visible
IIa) if the number of windows is less than the maximum
  we split the code window, put the output in the new window, jump to III)
IIb) if the number of windows is not less than the maximum
  we select the least recently used window and set it to display the output buffer

III) if output buffer is visible
    we switch to it depending on if switching is enabled

I have re-written py-shell-manage-windows (and added a helper function) to implement this logic and removed the (delete-other-frames) for else where in the code. Patch is attached (I am working off a git mirror, I'll also try to get this as a branch on lp).