An Emacs mode for editing Python code

org-mode :session

Reported by Andreas Roehler on 2013-02-08
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
High
Andreas Roehler

Bug Description

Am 07.02.2013 22:53, schrieb Myles English:>
> Hi Andreas,
>
> Andreas Röhler writes:
>
>> Am 06.02.2013 16:17, schrieb John Kitchin:
>>> Thanks for the -Q reminder. I get the same output if I run with emacs -Q
>>> (although I do have to add :results output to each block. I had that set as
>>> a default in my init files).
>>>
>>> I had the problem described in the footnote you listed, and that is why I
>>> am using python-mode 5.2, which doesn't have that issue.
>>>
>>> John
>>
>>
>> Should be fixed in current trunk.
>>
>> bzr branch lp:python-mode
>
> Thanks for looking at this Andreas, I have tried the bzr trunk and still
> have problems.
>
> John, I hope I am not hijacking your thread but I am not sure what
> problem is meant to be have been fixed above so I am just jumping in and
> assuming that we would both like to fix the same thing.
>
> Using org-mode from git, commit b810431 from Jan 22.
>
> If I start emacs like this:
>
> $ emacs -Q testPy.org -l init.el
>
> then executing the src blocks in order, *restarting Emacs between
> attempts*, shows the problems.
>
> -----/ init.el /------------------------------------------
> ;; use the git trunk for org mode
> (add-to-list 'load-path "~/.emacs.d/plugins/org-mode/lisp")
> (add-to-list 'load-path "~/.emacs.d/plugins/org-mode/contrib/lisp" t)
> (require 'org)
>
> ;; use the bzr trunk for python-mode
> (setq py-install-directory "/home/myles/.emacs.d/plugins/python-mode")
> (add-to-list 'load-path py-install-directory)
> (require 'python-mode)
>
> (org-babel-do-load-languages
> 'org-babel-load-languages
> '((python . t)))
> ---------------------------------------/ end init.el /-------
>
> -----/ testPy.org /------------------------------------------
> * First attempt :doesnotwork:
>
> #+begin_src python :results output :session a
> import sys
> #+end_src
>
> Message:
>
> inferior-python-mode: Wrong type argument: keymapp, py-down-exception
>
> * Second attempt: set org-babel-python-mode first :doesnotwork:
>
> #+begin_src elisp
> (setq org-babel-python-mode 'python-mode)
> (setq org-babel-python-command "python2"
> py-python-command "python2")
> #+end_src
>
> I would expect this to open a Python 2 session, however it opens a
> Python 3 session:
>
> #+begin_src python :results output :session a
> import sys
> print(sys.path)
> #+end_src
>
> * Third attempt: try python3 :works:
>
> #+begin_src elisp
> (setq org-babel-python-mode 'python-mode)
> (setq org-babel-python-command "python3"
> py-python-command "python3")
> #+end_src
>
> #+begin_src python :results output :session a
> import sys
> print(sys.path)
> #+end_src
>
> Works ok.
> ---------------------------------------/ end testPy.org /-------
>
> Perhaps I am not using it correctly?
>
> Thanks,
>
> Myles
>

Changed in python-mode:
importance: Undecided → Medium
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.1.2
Changed in python-mode:
importance: Medium → High
status: New → Triaged

This patch got sessions working for me:

=== modified file 'python-mode.el'
--- python-mode.el 2013-02-15 19:59:16 +0000
+++ python-mode.el 2013-02-24 12:01:38 +0000
@@ -1692,7 +1692,8 @@
         (define-key map [tab] 'py-complete-function)
       (define-key map [tab] 'py-completion-at-point))
     (define-key map "\C-c-" 'py-up-exception)
- (define-key map "\C-c=" 'py-down-exception)))
+ (define-key map "\C-c=" 'py-down-exception)
+ map))

 (defvar py-menu)

Please check if it solves your issues, too. (You can simple add the word "map" manually in python-mode.el at the position shown above.)

Am 24.02.2013 13:05, schrieb Alexander Boettcher:
> This patch got sessions working for me:
>
> === modified file 'python-mode.el'
> --- python-mode.el 2013-02-15 19:59:16 +0000
> +++ python-mode.el 2013-02-24 12:01:38 +0000
> @@ -1692,7 +1692,8 @@
> (define-key map [tab] 'py-complete-function)
> (define-key map [tab] 'py-completion-at-point))
> (define-key map "\C-c-" 'py-up-exception)
> - (define-key map "\C-c=" 'py-down-exception)))
> + (define-key map "\C-c=" 'py-down-exception)
> + map))
>
> (defvar py-menu)
>
> Please check if it solves your issues, too. (You can simple add the word "map" manually in python-mode.el at the position shown above.)
>

Your change is correct, thanks, will apply it. Probably some more bugs are around though...

summary: - org-mode session:
+ org-mode :session
Changed in python-mode:
status: Triaged → 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

Related blueprints