Comment 7 for bug 1579309

Revision history for this message
vkoch@lbl.gov (vkoch) wrote : Re: [Bug 1579309] python buffer window on top when using python3

Thanks for the help to get started with edebug:
So I played around with this and identified the area where things go wrong as indicated by the comment below in the code snippet of py—shell-manage-windows

     ((and
       (eq py-split-window-on-execute 'just-two)
       (not py-switch-buffers-on-execute-p))
      (switch-to-buffer py-exception-buffer)
      (delete-other-windows)
      (unless
   (member (get-buffer-window output-buffer)(window-list))
 (py--manage-windows-split py-exception-buffer output-buffer)) ###### POINT 1
      ;; Fixme: otherwise new window appears above
      (save-excursion
 (other-window 1)
      ;;(pop-to-buffer output-buffer) ##### for whatever reason pop-to-buffer behaves differently for buffer name *Python* and *Python3*
 (switch-to-buffer output-buffer) #### using instead switch to buffer does the trick (so far ….)
 (goto-char (point-max))
 (other-window 1)))
      ((and
       py-split-window-on-execute
       (not py-switch-buffers-on-execute-p))
      ;; https://bugs.launchpad.net/python-mode/+bug/1478122
      ;; > If the shell is visible in any of the windows it should re-use that window
      ;; > I did double check and py-keep-window-configuration is nil and py-split-window-on-execute is t.

So what happens is the following
1) I start with one window with the python code
2) After completing ### POINT 1 (py--manage-windows-split py-exception-buffer output-buffer))
    I have tow windows BOTH containing the python code and the focus is on the TOP window
3) (other-window 1) changes focus to the BOTTOM window
4) (pop-to-buffer output-buffer) now put the out-buffer in the TOP window for buffer name *Python3* and in the BOTTOM window for buffer name *Python*
I can actually reproduce this somewhat erratic behavior if I do this directly from the window containing the python source code.

Not sure if this is a full fix but so far it its working for me. Probably there iris a deep reason to use (pop-to-buffer) instead of (switch-to-buffer) but this is certainly beyond my lisp skills

Thanks
Volker

> On May 17, 2016, at 11:06 PM, Andreas Roehler <email address hidden> wrote:
>
> On 17.05.2016 23:56, <email address hidden> wrote:
>> I just upgraded to emacs 25.09, no change. Still the same problem.
>
> You could call M-x edebug-defun RET when in source.
> Than normally call your commands. Debugger will jump in.
>
> However, without some elisp, this won't tell you much.
>
> Will keep that bug in eye and work with it, as soon I have an example
> which triggers it.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1579309
>
> Title:
> python buffer window on top when using python3
>
> Status in python-mode.el:
> Incomplete
>
> Bug description:
> When using python3 as either the py-shell-name or as shebang (#! /usr/env python3) after pressing C-c C-c the python shell window pops up on top of my python file instead of below, which happens if I user "python" for the py-shell name (or shebang). This is annoying and re-aranging the buffers does not help, since the next C-c C-c messes it up again.
> Interestingly it also happens if I set python2 in py-shell-nam (or shebang). So it seems it has to do with the number at the end. Same behavior if I replace python -> python. Number at the end messes things up.
> This happened on a mac with OS X 10.11.4 in either aquamacs (emacs 24.4.25) or on emacs proper version 24.4.
> Thanks for you help
> Volker
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/python-mode/+bug/1579309/+subscriptions

-------------------------------------------------------------
Nuclear Science Division, MS70R0319
Lawrence Berkeley National Laboratory
Berkeley, CA 94720-8169, USA
Tel:+1-510-486-5323 Fax: +1-510-486-4794
-------------------------------------------------------------