An Emacs mode for editing Python code

Script buffer appears instead of python shell buffer

Reported by Richard Stanton on 2012-03-17
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Medium
Andreas Roehler

Bug Description

Using today's (3/16) current version of python-mode under Windows (Emacs 24.0.94), things are getting very close to working properly! Just a minor buffer visibility problem. E.g.,

1) Open run.py.

2) Press C-c !, the window splits and an ipython buffer opens as desired

3) In the script buffer, press C-c C-c.

The good: The script runs properly, and inside the same ipython buffer opened in step 2.

The bad: The ipython buffer disappears from view, and the split window now displays two copies of the original python script.

Am 17.03.2012 01:18, schrieb Richard Stanton:
> Public bug reported:
>
> Using today's (3/16)

Hi Richard,

thanks a lot for all your valuable reports, thus making it progress.
Just to optimize reporting a little bit: when referring to trunk, "today" isn't
that meaningful for me, as I may push serveral times. If possible, please indicate the revisions number.
At

https://code.launchpad.net/python-mode

column "Last commit" displays it, also

bzr log -l 1

  current version of python-mode under Windows (Emacs
> 24.0.94), things are getting very close to working properly! Just a
> minor buffer visibility problem. E.g.,
>
> 1) Open run.py.
>
> 2) Press C-c !, the window splits and an ipython buffer opens as desired
>
> 3) In the script buffer, press C-c C-c.
>
> The good: The script runs properly, and inside the same ipython buffer
> opened in step 2.
>
> The bad: The ipython buffer disappears from view, and the split window
> now displays two copies of the original python script.
>
> ** Affects: python-mode
> Importance: Undecided
> Status: New
>

Changed in python-mode:
importance: Undecided → Medium
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.6

> thanks a lot for all your valuable reports, thus making it progress.
> Just to optimize reporting a little bit: when referring to trunk, "today" isn't
> that meaningful for me, as I may push serveral times. If possible, please
> indicate the revisions number.

Aha! I'll do this in future. The revision I'm talking about here is 896.

Richard Stanton (a-stanton) wrote :

The same problem exists in r911. I have some additional information:

The splitting problem seems to depend on what python shell is selected.

If I edit the following script file and press C-c C-c, all works as expected. The window splits in two, one half shows the script file, and the other half shows the python buffer:

---------------

#!/usr/bin/python
print "Hi, Richard"

------------

If I add one character to this file, changing "python" in line 1 to "ipython", then press C-c C-c, the window now splits OK, but instead of one half showing the (i)python buffer, both halves of the window now display the original python script.

set py-split-windows-on-execute-p to nil via
'toggle-py-split-windows-on-execute. This disables the splitting
which fixes the problem for me.

On Tue, Mar 27, 2012 at 16:00, Richard Stanton
<email address hidden> wrote:
> The same problem exists in r911. I have some additional information:
>
> The splitting problem seems to depend on what python shell is selected.
>
> If I edit the following script file and press C-c C-c, all works as
> expected. The window splits in two, one half shows the script file, and
> the other half shows the python buffer:
>
> ---------------
>
> #!/usr/bin/python
> print "Hi, Richard"
>
> ------------
>
> If I add one character to this file, changing "python" in line 1 to
> "ipython", then press C-c C-c, the window now splits OK, but instead of
> one half showing the (i)python buffer, both halves of the window now
> display the original python script.
>
> --
> You received this bug notification because you are a member of python-
> mode.el developers, which is the registrant for python-mode.el.
> https://bugs.launchpad.net/bugs/957561
>
> Title:
>  Script buffer appears instead of python shell buffer
>
> Status in An Emacs mode for editing Python code:
>  New
>
> Bug description:
>  Using today's (3/16) current version of python-mode under Windows
>  (Emacs 24.0.94), things are getting very close to working properly!
>  Just a minor buffer visibility problem. E.g.,
>
>  1) Open run.py.
>
>  2) Press C-c !, the window splits and an ipython buffer opens as
>  desired
>
>  3) In the script buffer, press C-c C-c.
>
>  The good: The script runs properly, and inside the same ipython buffer
>  opened in step 2.
>
>  The bad: The ipython buffer disappears from view, and the split window
>  now displays two copies of the original python script.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/python-mode/+bug/957561/+subscriptions

Download full text (3.5 KiB)

Yes, that seems to help. I like having it split for me the first time, but as a work-around it's not that hard to split once manually, then I can run the code as often as I want without changing the window layout.

Thanks.

> -----Original Message-----
> From: <email address hidden> [mailto:<email address hidden>] On Behalf
> Of Thomas Caswell
> Sent: Friday, March 30, 2012 8:13 PM
> To: Richard Stanton
> Subject: Re: [Bug 957561] Re: Script buffer appears instead of python shell
> buffer
>
> set py-split-windows-on-execute-p to nil via 'toggle-py-split-windows-on-
> execute. This disables the splitting which fixes the problem for me.
>
>
> On Tue, Mar 27, 2012 at 16:00, Richard Stanton
> <email address hidden> wrote:
> > The same problem exists in r911. I have some additional information:
> >
> > The splitting problem seems to depend on what python shell is selected.
> >
> > If I edit the following script file and press C-c C-c, all works as
> > expected. The window splits in two, one half shows the script file,
> > and the other half shows the python buffer:
> >
> > ---------------
> >
> > #!/usr/bin/python
> > print "Hi, Richard"
> >
> > ------------
> >
> > If I add one character to this file, changing "python" in line 1 to
> > "ipython", then press C-c C-c, the window now splits OK, but instead
> > of one half showing the (i)python buffer, both halves of the window
> > now display the original python script.
> >
> > --
> > You received this bug notification because you are a member of python-
> > mode.el developers, which is the registrant for python-mode.el.
> > https://bugs.launchpad.net/bugs/957561
> >
> > Title:
> >  Script buffer appears instead of python shell buffer
> >
> > Status in An Emacs mode for editing Python code:
> >  New
> >
> > Bug description:
> >  Using today's (3/16) current version of python-mode under Windows
> >  (Emacs 24.0.94), things are getting very close to working properly!
> >  Just a minor buffer visibility problem. E.g.,
> >
> >  1) Open run.py.
> >
> >  2) Press C-c !, the window splits and an ipython buffer opens as
> >  desired
> >
> >  3) In the script buffer, press C-c C-c.
> >
> >  The good: The script runs properly, and inside the same ipython
> > buffer
> >  opened in step 2.
> >
> >  The bad: The ipython buffer disappears from view, and the split
> > window
> >  now displays two copies of the original python script.
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/python-mode/+bug/957561/+subscriptions
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/957561
>
> Title:
> Script buffer appears instead of python shell buffer
>
> Status in An Emacs mode for editing Python code:
> New
>
> Bug description:
> Using today's (3/16) current version of python-mode under Windows
> (Emacs 24.0.94), things are getting very close to working properly!
> Just a minor buffer visibility problem. E.g.,
>
> 1) Open run.py.
>
> 2) Press C-c !, the window splits and an ipython buffer opens as
...

Read more...

Am 27.03.2012 23:00, schrieb Richard Stanton:
> The same problem exists in r911. I have some additional information:
>
> The splitting problem seems to depend on what python shell is selected.
>

fixed it that way. Please re-open if not done.

Changed in python-mode:
status: New → Fix Committed
Richard Stanton (a-stanton) wrote :
Download full text (5.6 KiB)

r 916: It now seems to be trying to switch to the (non-existent) buffer "IPython" (the buffer is actually called "*IPython*"), and throws the following error:

Debugger entered--Lisp error: (error "No buffer named IPython")
  set-buffer("IPython")
  (cond ((unless (eq switch (quote noswitch)) (and py-split-windows-on-execute-p (or (eq switch (quote switch)) py-shell-switch-buffers-on-execute-p))) (unless (string-match "[Ii][Pp]ython" py-buffer-name) (delete-other-windows)) (when (window-full-height-p) (funcall py-split-windows-on-execute-function)) (pop-to-buffer py-buffer-name)) ((and py-split-windows-on-execute-p (or (eq switch (quote noswitch)) (not (eq switch (quote switch))))) (when (window-full-height-p) (funcall py-split-windows-on-execute-function)) (set-buffer py-buffer-name) (switch-to-buffer (current-buffer)) (other-window 1)) ((or (eq switch (quote switch)) (and (not (eq switch (quote noswitch))) py-shell-switch-buffers-on-execute-p)) (pop-to-buffer py-buffer-name) (goto-char (point-max))) ((or (eq switch (quote noswitch)) (not py-shell-switch-buffers-on-execute-p)) (set-buffer oldbuf) (switch-to-buffer (current-buffer))))
  py-shell-manage-windows(nil t nil #<buffer run.py> "IPython")
  (progn (when (string-match "ipython" (process-name proc)) (sit-for py-ipython-execute-delay)) (setq erg (py-execute-file-base proc file pec)) (setq py-exception-buffer (cons file (current-buffer))) (py-shell-manage-windows switch py-split-windows-on-execute-p py-shell-switch-buffers-on-execute-p oldbuf procbuf) (unless (string= (buffer-name (current-buffer)) procbuf) (when py-verbose-p (message "Output buffer: %s" procbuf))) (sit-for 0.1) (unless py-execute-keep-temporary-file-p (delete-file file) (when (buffer-live-p file) (kill-buffer file))) erg)
  (if (file-readable-p file) (progn (when (string-match "ipython" (process-name proc)) (sit-for py-ipython-execute-delay)) (setq erg (py-execute-file-base proc file pec)) (setq py-exception-buffer (cons file (current-buffer))) (py-shell-manage-windows switch py-split-windows-on-execute-p py-shell-switch-buffers-on-execute-p oldbuf procbuf) (unless (string= (buffer-name (current-buffer)) procbuf) (when py-verbose-p (message "Output buffer: %s" procbuf))) (sit-for 0.1) (unless py-execute-keep-temporary-file-p (delete-file file) (when (buffer-live-p file) (kill-buffer file))) erg) (message "%s not readable. %s" file "Do you have write permissions?"))
  (let* ((oldbuf (current-buffer)) (shell (or shell (py-choose-shell))) (regbuf (current-buffer)) (py-execute-directory (or (ignore-errors (file-name-directory (buffer-file-name))) (getenv "WORKON_HOME") (getenv "HOME"))) (strg (buffer-substring-no-properties start end)) (sepchar (or sepchar (py-separator-char))) (name (py-buffer-name-prepare shell sepchar)) (temp (make-temp-name shell)) (file (concat (expand-file-name temp py-temp-directory) ".py")) (filebuf (get-buffer-create file)) (proc (if dedicated (get-buffer-process (py-shell nil dedicated (or shell (downcase shell)) switch sepchar nil t)) (or (get-buffer-process shell) (get-buffer-process (py-shell nil dedicated (or shell ...) switch sepchar nil t))))) (procbuf (if dedicated (buffer-name (get-buffer ...

Read more...

Changed in python-mode:
status: Fix Committed → In Progress
Andreas Roehler (a-roehler) wrote :

Am 03.04.2012 23:03, schrieb Richard Stanton:
> r 916: It now seems to be trying to switch to the (non-existent) buffer
> "IPython" (the buffer is actually called "*IPython*"), and throws the
> following error:

ah, sorry, wrote a test meanwhile, so we should not see this kind of errors...
please try again, thx

Changed in python-mode:
status: In Progress → Fix Committed
Richard Stanton (a-stanton) wrote :
Download full text (5.8 KiB)

r918: This problem seems to have gone away on my Mac, but it's still there under Windows. For example, if I open a script file containing the text:

print "Hi, Richard"

and press C-c C-c, I get an error dump again (see below). It's trying to switch to a buffer called *IPython*, while the actual buffer name is *c:/python27/Scripts/IPython.bat*

The dump is as follows:

Debugger entered--Lisp error: (error "No buffer named *IPython*")
  set-buffer("*IPython*")
  (cond ((unless (eq switch (quote noswitch)) (and py-split-windows-on-execute-p (or (eq switch (quote switch)) py-shell-switch-buffers-on-execute-p))) (unless (string-match "[Ii][Pp]ython" py-buffer-name) (delete-other-windows)) (when (window-full-height-p) (funcall py-split-windows-on-execute-function)) (pop-to-buffer py-buffer-name)) ((and py-split-windows-on-execute-p (or (eq switch (quote noswitch)) (not (eq switch (quote switch))))) (when (window-full-height-p) (funcall py-split-windows-on-execute-function)) (set-buffer py-buffer-name) (switch-to-buffer (current-buffer)) (other-window 1)) ((or (eq switch (quote switch)) (and (not (eq switch (quote noswitch))) py-shell-switch-buffers-on-execute-p)) (pop-to-buffer py-buffer-name) (goto-char (point-max))) ((or (eq switch (quote noswitch)) (not py-shell-switch-buffers-on-execute-p)) (set-buffer oldbuf) (switch-to-buffer (current-buffer))))
  py-shell-manage-windows(nil t nil #<buffer run.py> "*IPython*")
  (progn (when (string-match "ipython" (process-name proc)) (sit-for py-ipython-execute-delay)) (setq erg (py-execute-file-base proc file pec)) (setq py-exception-buffer (cons file (current-buffer))) (py-shell-manage-windows switch py-split-windows-on-execute-p py-shell-switch-buffers-on-execute-p oldbuf procbuf) (unless (string= (buffer-name (current-buffer)) procbuf) (when py-verbose-p (message "Output buffer: %s" procbuf))) (sit-for 0.1) (unless py-execute-keep-temporary-file-p (delete-file file) (when (buffer-live-p file) (kill-buffer file))) erg)
  (if (file-readable-p file) (progn (when (string-match "ipython" (process-name proc)) (sit-for py-ipython-execute-delay)) (setq erg (py-execute-file-base proc file pec)) (setq py-exception-buffer (cons file (current-buffer))) (py-shell-manage-windows switch py-split-windows-on-execute-p py-shell-switch-buffers-on-execute-p oldbuf procbuf) (unless (string= (buffer-name (current-buffer)) procbuf) (when py-verbose-p (message "Output buffer: %s" procbuf))) (sit-for 0.1) (unless py-execute-keep-temporary-file-p (delete-file file) (when (buffer-live-p file) (kill-buffer file))) erg) (message "%s not readable. %s" file "Do you have write permissions?"))
  (let* ((oldbuf (current-buffer)) (shell (or shell (py-choose-shell))) (regbuf (current-buffer)) (py-execute-directory (or (ignore-errors (file-name-directory (buffer-file-name))) (getenv "WORKON_HOME") (getenv "HOME"))) (strg (buffer-substring-no-properties start end)) (sepchar (or sepchar (py-separator-char))) (name (py-buffer-name-prepare shell sepchar)) (temp (make-temp-name shell)) (file (concat (expand-file-name temp py-temp-directory) ".py")) (filebuf (get-buffer-create file)) (proc (if dedicated (get-buffer-process (py-shell nil dedicat...

Read more...

Changed in python-mode:
status: Fix Committed → In Progress
Changed in python-mode:
status: In Progress → New
Andreas Roehler (a-roehler) wrote :

seems gone with last commit, please flag "new" again if not

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

Other bug subscribers