py-shell-switch-buffers-on-execute not honored

Bug #822409 reported by Gennady N. Uraltsev
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
High
Andreas Roehler

Bug Description

The py-shell-switch-buffers-on-execute doesn't get honored. In the code the value of this variable gets checked only in py-comint-output-filter-function and nowhere else. Elsewhere pop-to-buffer get's called without any checks.

Revision history for this message
Gennady N. Uraltsev (gennady-uraltsev) wrote :
Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
Changed in python-mode:
importance: Undecided → Medium
milestone: none → 6.1
Changed in python-mode:
importance: Medium → High
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi,

the whole section deserves some consideration IMHO,

Could you describe what you are trying to get, what it should do for what reasons?

Maybe we should drop that var completely, displaying result-buffers only when interactively called?

Thanks,

Andreas

Revision history for this message
Gennady N. Uraltsev (gennady-uraltsev) wrote :
Download full text (3.3 KiB)

Hello.

Let's suppose that I am editing a .py file with py code. I decide to run the code that I wrote. I can do so by various means:

I can chose to execute the entire buffer by running py-execute-buffer or by selecting a region and and doing py-execute-region

****
What happens now:

py-execute-buffer:
if the same frame contains a *Python* interpeter window in position strictly adjacent to the window with the source code the code is executed there and the focus is switched back to the window containing the source code. If there is no window containing the *Python* buffer among the windows stricty adjacent to the source code window a new window is created (if there were none) or an existing adjacent window is used to display the *Python* buffer. If there were, for whatever reason, more than one window with the source code buffer opened then the focus may be restored to the "wrong" window, i.e. not the one from which the py-execute-buffer was called.

py-execute-region:
the same thing happens as with py-execute-buffer but the focus is never returned to the source code buffer window. This is particularly frustrating in my case

This happens independently of what py-shell-switch-buffers-on-execute is set to (nil or t)

This behavior was observed in SYNC mode with the *Python* buffer and not the *Python Output* buffers
I am also having serious problems with ASYNC mode of those 2 commands (actually it seems I cannot get anything to be executed at all in ASYNC mode). I will study this better and if I find something out something maybe it is material for another bug report...
*****

What IMHO is a more reasonable behaviour:

py-execute-region and py-execute-buffer should behave in the same manner. The questions to answer are:

1) should the focus be returned to the calling source-code window when calling the functions above?
2a) If a *Python* interpreter window is present in the same frame ( (aa) or any frame, maybe? however this should at least be configurable since it is reasonable to have frames on remote machines) should no window be created?
2b) if there is No *Python* buffer visible in any window should a window be created and the contents displayed?
3) if there was no *Python* buffer opened AT ALL, (in most cases, the first time you call the execute functions), once created, should a visible window be created and the *Python* buffer displayed?

The variable py-shell-switch-buffers-on-execute could control all, or a subset of these options.

This is my proposal:

Generally I suppose that it is reasonable that the answer to (3) should always be yes (always open the *python* buffer window on the inital startup of the buffer. (2b) Should absolutely be configurable! (2a) IMHO should not create any window if there are windows already visible. The check on (2aa) should not be implemented. That functionality can be obtained by configuring (2b) not to create windows and manually opening a window in an other frame. Finally, as for (1), I think focus should always be returned and the code to remember the exact original window should be fixed up, however this can also be made configurable.

Anyway, sorry for so much talk! I have some experience in...

Read more...

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Gennady,

thanks a lot. I'll dig into it as soon as remaining indent-issues permit.

Should you have a patch, don't hesitate to present it.

Andreas

Changed in python-mode:
status: New → Confirmed
Changed in python-mode:
status: Confirmed → Fix Committed
Revision history for this message
Gennady N. Uraltsev (gennady-uraltsev) wrote :

Hello Andreas,

I saw you fixed this bug and now it works as expected as far as I could see while testing it if one does a small fix removing two lines from the source code.
However I think you forgot to remove lines:

L2232-2233 in py-execute-base:
    (when (one-window-p)
      (split-window-vertically))

And actually what happened when I tried out the functionality was:
the buffer didn't pop BUT the frame got split in two identical windows if the window was originally only one.

Thanks for the fix and I hope that I diagnosed the little residue problem correctly!

Gennady.

Changed in python-mode:
status: Fix Committed → Incomplete
status: Incomplete → In Progress
Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 822409] Re: py-shell-switch-buffers-on-execute not honored

Am 14.08.2011 15:12, schrieb Gennady N. Uraltsev:
> Hello Andreas,
>
> I saw you fixed this bug and now it works as expected as far as I could see while testing it if one does a small fix removing two lines from the source code.
> However I think you forgot to remove lines:
>
> L2232-2233 in py-execute-base:
> (when (one-window-p)
> (split-window-vertically))
>

hmm, something went wrong with my branch management.
Have identical commit messages but a diff here in code.

thanks,

Andreas

Changed in python-mode:
status: In Progress → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.