Hello {Jambunathan}, I have found that Equations become labelled as Figures in the version I am using: emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) (?I'm not sure if it is the most recent version of contrib/org-odt as the README.org says "This release is is as good as org-20110613" etc) The test equations in latex-mathml.org in this message: http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html are labelled as "Equation" in the odt files but when I export it fresh I get "Figure". Thank you for the recent MathML stuff by the way. Myles
Myles English <mylesenglish@gmail.com> writes: > Hello {Jambunathan}, > > I have found that Equations become labelled as Figures in the version I > am using: > > emacs 23.3.1 > org-mode from git commit 71f1c1be (Oct 26) > The test equations in latex-mathml.org in this message: > > http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html > > are labelled as "Equation" in the odt files but when I export it fresh I get > "Figure". This was a regression. I pushed a fix few moments ago. Could you please pull again? > (?I'm not sure if it is the most recent version of contrib/org-odt as > the README.org says "This release is is as good as org-20110613" etc) I have not updated README.org for a while and please ignore whatever it claims. You are using the right version of odt. So no worries. > Thank you for the recent MathML stuff by the way. > > Myles > > --
>> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said: > Myles English <mylesenglish@gmail.com> writes: >> I have found that Equations become labelled as Figures in the >> version I am using: >> >> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test >> equations in latex-mathml.org in this message: >> >> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html >> >> are labelled as "Equation" in the odt files but when I export it >> fresh I get "Figure". > This was a regression. I pushed a fix few moments ago. Could you > please pull again? Thanks for the push, there are three things I notice now: 1) my document won't open and causes libreoffice to crash! I get: "terminate called after throwing an instance of what(): vector::_M_default_append" on the command line 2) the first equation in latex-mathml.org is not numbered, I would expect this if it was using a begin{equation*} environment but not a begin{equation}. 3) the second equation looks a bit like this: x=root(b) (1) Radicals but I would have expected something like: x=root(b) Equation 1.: Radicals Is there a new variable that I need to set to get (e.g.) "Equation 1."? Just to be explicit, the test file latex-mathml.org I am referring to contains: #+TITLE: latex-mathml.org #+AUTHOR: Jambunathan K #+EMAIL: address@hidden #+DATE: 2011-09-09 Fri #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+LINK_UP: #+LINK_HOME: #+XSLT: * LaTeX Fragments ** LaTeX Fragment1 # See org-format-latex-options There is a equation down below. \begin{equation} e = \frac{1}{2}mv^2 \end{equation} ** LaTeX Fragment2 #+CAPTION: Radicals #+LABEL: Equation:1 \begin{equation} x=\sqrt{b} \end{equation} If $a^2=b$ and \( b=2 \), then the solution must be either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \]. Myles
>> On Mon, 31 Oct 2011 11:54:35 +0000, Myles English said: >> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said: >> Myles English <mylesenglish@gmail.com> writes: >>> I have found that Equations become labelled as Figures in the >>> version I am using: >>> >>> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test >>> equations in latex-mathml.org in this message: >>> >>> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html >>> >>> are labelled as "Equation" in the odt files but when I export it >>> fresh I get "Figure". >> This was a regression. I pushed a fix few moments ago. Could you >> please pull again? > Thanks for the push, there are three things I notice now: > 1) my document won't open and causes libreoffice to crash! I get: > "terminate called after throwing an instance of what(): > vector::_M_default_append" on the command line > 2) the first equation in latex-mathml.org is not numbered, I would > expect this if it was using a begin{equation*} environment but not a > begin{equation}. > 3) the second equation looks a bit like this: > x=root(b) (1) Radicals > but I would have expected something like: > x=root(b) Equation 1.: Radicals Alright, points 2 and 3 are cleared up by me understanding that the asterisk in \begin{equation*} has no visible effect, and that instead of having "Equation 1.:" in the caption below the formula, there is a "(1)" on the RHS. Point 1 is entirely my own problem. Myles
Myles (I have read the followup post to this set of questions) Myles English <mylesenglish@gmail.com> writes: >>> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said: > > > Myles English <mylesenglish@gmail.com> writes: > >> I have found that Equations become labelled as Figures in the > >> version I am using: > >> > >> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test > >> equations in latex-mathml.org in this message: > >> > >> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html > >> > >> are labelled as "Equation" in the odt files but when I export it > >> fresh I get "Figure". > > > This was a regression. I pushed a fix few moments ago. Could you > > please pull again? > > Thanks for the push, there are three things I notice now: > > 1) my document won't open and causes libreoffice to crash! I get: > "terminate called after throwing an instance of > what(): vector::_M_default_append" on the command line 1. You are using custom styles for your latex fragment 2. latex-to-mathml converter - as it stands today - assumes the latex fragment is completed in and of itself and doesn't honor the style settings. Putting 1 and 2 together, I am assuming that the XML created by the ODT emitter contains garbage which is causing LibreOffice to be confused. In my observation, ill-formed XML triggers "file is corrupt and should I repair the file?" from LibreOffice. A crash seems strange to me. 1. http://article.gmane.org/gmane.emacs.orgmode/48714 - Above link has my note on -ncf option to mathtoweb 2. http://orgmode.org/worg/org-faq.html - Above link has a note on how to debug corrupt odt files. (Hint: search for corrupt) > 2) the first equation in latex-mathml.org is not numbered, I would > expect this if it was using a begin{equation*} environment but not a > begin{equation}. Currently the odt exporter doesn't peek in to the latex fragment and infer what manner of equation it is. This is something that I could take up ... ,---- | (defvar org-latex-regexps | '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t) | ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil) | ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p | ("$1" "\\([^$]\\|^\\)\\(\\$[^ \r\n,;.$]\\$\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil) | ("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \r\n,.$]\\)\\$\\)\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil) | ("\\(" "\\\\([^\000]*?\\\\)" 0 nil) | ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil) | ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil)) | "Regular expressions for matching embedded LaTeX.") `---- > 3) the second equation looks a bit like this: > > x=root(b) (1) > Radicals > > but I would have expected something like: > > x=root(b) > Equation 1.: Radicals > > Is there a new variable that I need to set to get (e.g.) "Equation > 1."? Being a non-latex user, I am not familiar with what the usual practice is. If the latter option is how captioned equations are normally typeset I can take it up. Can you confirm that the expectations above are *not* your own but that of *any* user? > Just to be explicit, the test file latex-mathml.org I am referring to > contains: > > #+TITLE: latex-mathml.org > #+AUTHOR: Jambunathan K > #+EMAIL: address@hidden > #+DATE: 2011-09-09 Fri > #+DESCRIPTION: > #+KEYWORDS: > #+LANGUAGE: en > #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t > #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc > > #+EXPORT_SELECT_TAGS: export > #+EXPORT_EXCLUDE_TAGS: noexport > #+LINK_UP: > #+LINK_HOME: > #+XSLT: > > * LaTeX Fragments > > ** LaTeX Fragment1 > # See org-format-latex-options > > There is a equation down below. > > \begin{equation} > e = \frac{1}{2}mv^2 > \end{equation} > > ** LaTeX Fragment2 > > #+CAPTION: Radicals > #+LABEL: Equation:1 > \begin{equation} > x=\sqrt{b} > \end{equation} > > If $a^2=b$ and \( b=2 \), then the solution must be either $$ > a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \]. > > > Myles > > --
>> 2) the first equation in latex-mathml.org is not numbered, I would
>> expect this if it was using a begin{equation*} environment but not a
>> begin{equation}.
>
> Currently the odt exporter doesn't peek in to the latex fragment and
> infer what manner of equation it is. This is something that I could take
> up ...
As thing stand today, to produce a numbered equation just attach
#+LABEL: to it. This is how odt exporter determines when a formula is
numbered or not.
--
Jambunathan, >> On Wed, 02 Nov 2011 01:09:41 +0530, Jambunathan K said: > Myles > (I have read the followup post to this set of questions) > Myles English <mylesenglish@gmail.com> writes: >>>> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said: >> >> > Myles English <mylesenglish@gmail.com> writes: >> I have found >> that Equations become labelled as Figures in the >> version I am >> using: >> >> >> >> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test >> >> equations in latex-mathml.org in this message: >> >> >> >> >> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html >> >> >> >> are labelled as "Equation" in the odt files but when I export it >> >> fresh I get "Figure". >> >> > This was a regression. I pushed a fix few moments ago. Could you >> > please pull again? >> >> Thanks for the push, there are three things I notice now: >> >> 1) my document won't open and causes libreoffice to crash! I get: >> "terminate called after throwing an instance of what(): >> vector::_M_default_append" on the command line > 1. You are using custom styles for your latex fragment > 2. latex-to-mathml converter - as it stands today - assumes the > latex fragment is completed in and of itself and doesn't honor the > style settings. > Putting 1 and 2 together, I am assuming that the XML created by the > ODT emitter contains garbage which is causing LibreOffice to be > confused. In my observation, ill-formed XML triggers "file is > corrupt and should I repair the file?" from LibreOffice. A crash > seems strange to me. There is (git from a couple of days ago) a problem with referring to equations containing an underscore in the label, I am fairly sure it was allowed before, e.g.: --8<---------------cut here---------------start------------->8--- #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation} Referring to an equation with an underscore: \ref{Equation:new_eq} --8<---------------cut here---------------end--------------->8--- I get a libreoffice popup: "Read Error. Format error discovered in the file in sub-document content.xmlat 2236,92(row,col)." I think it was many of these errors that caused the crash. > 1. http://article.gmane.org/gmane.emacs.orgmode/48714 - Above link > has my note on -ncf option to mathtoweb > 2. http://orgmode.org/worg/org-faq.html - Above link has a note on > how to debug corrupt odt files. (Hint: search for corrupt) >> 2) the first equation in latex-mathml.org is not numbered, I would >> expect this if it was using a begin{equation*} environment but not >> a begin{equation}. > Currently the odt exporter doesn't peek in to the latex fragment and > infer what manner of equation it is. This is something that I could > take up ... > ,---- | (defvar org-latex-regexps | '(("begin" "^[ > \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t) > | ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ > \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ > .,?;:'\")]\\|$\\)" 2 nil) | ;; \000 in the following regex is needed > for org-inside-LaTeX-fragment-p | ("$1" "\\([^$]\\|^\\)\\(\\$[^ > \r\n,;.$]\\$\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil) | ("$" > "\\([^$]\\|^\\)\\(\\(\\$\\([^ > \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ > \r\n,.$]\\)\\$\\)\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil) | ("\\(" > "\\\\([^\000]*?\\\\)" 0 nil) | ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 > nil) | ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil)) | "Regular expressions > for matching embedded LaTeX.") `---- Crikey! That's quite a regexp. I think the only consideration is whether you want it to be consistent with pdf export. Taking consistency to an extreme could lead to a new #+begin_equation block (<-- I haven't thought this through at all). Having said that I am happy with the way it works at the moment. >> 3) the second equation looks a bit like this: >> >> x=root(b) (1) Radicals >> >> but I would have expected something like: >> >> x=root(b) Equation 1.: Radicals >> >> Is there a new variable that I need to set to get (e.g.) "Equation >> 1."? > Being a non-latex user, I am not familiar with what the usual > practice is. If the latter option is how captioned equations are > normally typeset I can take it up. Can you confirm that the > expectations above are *not* your own but that of *any* user? Actually I have changed my mind, it does look better like that, it is just that is was different behaviour to what happened before. Myles
Myles English <mylesenglish@gmail.com> wrote:
>
> There is (git from a couple of days ago) a problem with referring to
> equations containing an underscore in the label, I am fairly sure it was
> allowed before, e.g.:
>
> #+LABEL: Equation:new_eq
> \begin{equation}
> x=\sqrt{b}
> \end{equation}
>
> Referring to an equation with an underscore: \ref{Equation:new_eq}
>
> I get a libreoffice popup:
>
> "Read Error. Format error discovered in the file in sub-document
> content.xmlat 2236,92(row,col)."
>
I can reproduce that and it may be a consequence of a change that
I introduced at the top level export engine about six months ago.
Let me take a look.
Nick
Nick,
>> On Wed, 02 Nov 2011 09:38:20 -0400, Nick Dokos said:
> Myles English <mylesenglish@gmail.com> wrote:
>>
>> There is (git from a couple of days ago) a problem with referring
>> to equations containing an underscore in the label, I am fairly
>> sure it was allowed before, e.g.:
>>
>> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation}
>>
>> Referring to an equation with an underscore: \ref{Equation:new_eq}
>>
>> I get a libreoffice popup:
>>
>> "Read Error. Format error discovered in the file in sub-document
>> content.xmlat 2236,92(row,col)."
>>
> I can reproduce that and it may be a consequence of a change that I
> introduced at the top level export engine about six months ago. Let
> me take a look.
> Nick
I may be mistaken but I think it became broken more recently, circa 7th
Oct.
Myles
Myles English <mylesenglish@gmail.com> wrote:
>
> Nick,
>
> >> On Wed, 02 Nov 2011 09:38:20 -0400, Nick Dokos said:
>
> > Myles English <mylesenglish@gmail.com> wrote:
> >>
> >> There is (git from a couple of days ago) a problem with referring
> >> to equations containing an underscore in the label, I am fairly
> >> sure it was allowed before, e.g.:
> >>
> >> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation}
> >>
> >> Referring to an equation with an underscore: \ref{Equation:new_eq}
> >>
> >> I get a libreoffice popup:
> >>
> >> "Read Error. Format error discovered in the file in sub-document
> >> content.xmlat 2236,92(row,col)."
> >>
>
> > I can reproduce that and it may be a consequence of a change that I
> > introduced at the top level export engine about six months ago. Let
> > me take a look.
>
> > Nick
>
> I may be mistaken but I think it became broken more recently, circa 7th
> Oct.
>
OK - phew (although I may not be out of the woods yet). It seems that the
underscore in the link is interpreted as a subscript:
,----
| ...
| Referring to an equation with an underscore: <text:sequence-ref text:ref-name="Equation:new<text:span text:style-name="OrgSubscript">eq</text:span>"/>
`----
Thanks,
Nick
>> >> There is (git from a couple of days ago) a problem with referring
>> >> to equations containing an underscore in the label, I am fairly
>> >> sure it was allowed before, e.g.:
>> >>
>> >> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation}
>> >>
>> >> Referring to an equation with an underscore: \ref{Equation:new_eq}
>> >>
>> >> I get a libreoffice popup:
>> >>
>> >> "Read Error. Format error discovered in the file in sub-document
>> >> content.xmlat 2236,92(row,col)."
>> >>
> OK - phew (although I may not be out of the woods yet). It seems that the
> underscore in the link is interpreted as a subscript:
>
> ,----
> | ...
> | Referring to an equation with an underscore: <text:sequence-ref
> | text:ref-name="Equation:new<text:span
> | text:style-name="OrgSubscript">eq</text:span>"/>
> `----
Nick, Thanks for debugging this and isolating the root cause.
Myles, I have pushed a fix few minutes ago. Hope things are OK now.
--
>> On Wed, 02 Nov 2011 23:51:31 +0530, Jambunathan K said: >> >> There is (git from a couple of days ago) a problem with referring >> >> to equations containing an underscore in the label, I am fairly >> >> sure it was allowed before, e.g.: >> >> >> >> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation} >> >> >> >> Referring to an equation with an underscore: \ref{Equation:new_eq} >> >> >> >> I get a libreoffice popup: >> >> >> >> "Read Error. Format error discovered in the file in sub-document >> >> content.xmlat 2236,92(row,col)." >> >> >> OK - phew (although I may not be out of the woods yet). It seems >> that the underscore in the link is interpreted as a subscript: >> >> ,---- | ... | Referring to an equation with an underscore: >> <text:sequence-ref | text:ref-name="Equation:new<text:span | >> text:style-name="OrgSubscript">eq</text:span>"/> `---- > Nick, Thanks for debugging this and isolating the root cause. > Myles, I have pushed a fix few minutes ago. Hope things are OK now. References work fine now, Thanks. Myles
Hi, I think it should be possible to execute a python block in a session using python-mode.el but get this message: "Symbol's function definition is void: py-toggle-shells" Using the latest git head and opening this file with: $ emacs -Q thisfile.org then executing these src blocks in order, shows the problem: #+BEGIN_SRC emacs-lisp (require 'org) (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) #+END_SRC #+RESULTS: | (python . t) | * A heading This works okay: #+begin_src python :results output :session a import sys #+end_src #+RESULTS: Try with python3: #+begin_src elisp (setq org-babel-python-command "python3" py-python-command "python3" ) #+end_src #+RESULTS: : python3 works also: #+begin_src python :results output :session a import sys #+end_src #+RESULTS: Try using python-mode.el: #+begin_src elisp (setq org-babel-python-mode 'python-mode) (load-file "/usr/share/emacs/site-lisp/python-mode.el") #+end_src #+RESULTS: : t #+begin_src python :results output :session a import sys #+end_src Gives this *Message*: org-babel-python-initiate-session-by-key: Symbol's function definition is void: py-toggle-shells Do I need to configure something else? Thanks, Myles
Myles English <mylesenglish@gmail.com> wrote:
> Hi,
>
> I think it should be possible to execute a python block in a session
> using python-mode.el but get this message:
>
> "Symbol's function definition is void: py-toggle-shells"
>
> Using the latest git head and opening this file with:
>
> $ emacs -Q thisfile.org
>
> then executing these src blocks in order, shows the problem:
>
> #+BEGIN_SRC emacs-lisp
> (require 'org)
> (org-babel-do-load-languages
> 'org-babel-load-languages
> '((python . t)))
> #+END_SRC
>
> #+RESULTS:
> | (python . t) |
>
> * A heading
>
> This works okay:
>
> #+begin_src python :results output :session a
> import sys
> #+end_src
>
> #+RESULTS:
>
> Try with python3:
>
> #+begin_src elisp
> (setq org-babel-python-command "python3"
> py-python-command "python3"
> )
> #+end_src
>
> #+RESULTS:
> : python3
>
> works also:
>
> #+begin_src python :results output :session a
> import sys
> #+end_src
>
> #+RESULTS:
>
> Try using python-mode.el:
>
> #+begin_src elisp
> (setq org-babel-python-mode 'python-mode)
> (load-file "/usr/share/emacs/site-lisp/python-mode.el")
> #+end_src
>
> #+RESULTS:
> : t
>
> #+begin_src python :results output :session a
> import sys
> #+end_src
>
> Gives this *Message*:
>
> org-babel-python-initiate-session-by-key: Symbol's function definition
> is void: py-toggle-shells
>
> Do I need to configure something else?
>
I get in trouble much sooner than you do: when evaluating the first code
block. The error in my case was that run-python was called with the
wrong number of args (from the same function: it's a couple of lines
before py-toggle-shells is called). I'm running
GNU Emacs 24.3.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.4) of 2012-12-29
and run-python does indeed need a required arg in this version:
,----
| run-python is an interactive autoloaded compiled Lisp function in
| `python.el'.
|
| (run-python CMD &optional DEDICATED SHOW)
|
| Run an inferior Python process.
| Input and output via buffer named after
| `python-shell-buffer-name'. If there is a process already
| running in that buffer, just switch to it.
`----
So I changed the call to
(run-python py-python-command)
and then all the code blocks could execute with no problem. Has
run-python changed signature recently?
This may or may not be the problem you are running into however.
Nick
Hi Nick, Nick Dokos writes: > Myles English <mylesenglish@gmail.com> wrote: >> I think it should be possible to execute a python block in a session >> using python-mode.el but get this message: >> >> "Symbol's function definition is void: py-toggle-shells" I have made a bit of progress with the patch below. The breakage may have been due to changes in python-mode.el . The patch works for versions 6.0.10 and 6.1.0. > I get in trouble much sooner than you do: when evaluating the first code > block. The error in my case was that run-python was called with the > wrong number of args (from the same function: it's a couple of lines > before py-toggle-shells is called). I'm running > > GNU Emacs 24.3.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.4) of 2012-12-29 > > and run-python does indeed need a required arg in this version: > > ,---- > | run-python is an interactive autoloaded compiled Lisp function in > | `python.el'. > | > | (run-python CMD &optional DEDICATED SHOW) > | > | Run an inferior Python process. > | Input and output via buffer named after > | `python-shell-buffer-name'. If there is a process already > | running in that buffer, just switch to it. > `---- > > So I changed the call to > > > (run-python py-python-command) > > and then all the code blocks could execute with no problem. Has > run-python changed signature recently? Doing git blame ob-python.el shows that not much has changed in that file over the last couple of years. > This may or may not be the problem you are running into however. I have made some progress and the patch below passes this test: #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/.emacs.d/plugins/org-mode/lisp") (require 'org) (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) (setq org-babel-python-mode 'python-mode) #+END_SRC #+begin_src python :results output :session a import sys #+end_src #+begin_src python :results output :session a print(sys.path) #+end_src Patch: --- lisp/ob-python.el +++ lisp/ob-python.el @@ -32,7 +32,7 @@ (declare-function org-remove-indentation "org" ) (declare-function py-shell "ext:python-mode" (&optional argprompt)) -(declare-function py-toggle-shells "ext:python-mode" (arg)) +(declare-function py-toggle-shell "ext:python-mode" (arg)) (declare-function run-python "ext:python" (&optional cmd noshow new)) (defvar org-babel-tangle-lang-exts) @@ -162,16 +162,17 @@ then create. Return the initialized session." ;; Make sure that py-which-bufname is initialized, as otherwise ;; it will be overwritten the first time a Python buffer is ;; created. - (py-toggle-shells py-default-interpreter) + (py-toggle-shell py-default-interpreter) ;; `py-shell' creates a buffer whose name is the value of ;; `py-which-bufname' with '*'s at the beginning and end (let* ((bufname (if (and python-buffer (buffer-live-p python-buffer)) (replace-regexp-in-string ;; zap surrounding * "^\\*\\([^*]+\\)\\*$" "\\1" python-buffer) (concat "Python-" (symbol-name session)))) - (py-which-bufname bufname)) - (py-shell) - (setq python-buffer (concat "*" bufname "*")))) + (py-buffer-name bufname)) + (setq python-buffer (concat "*" bufname "*")) + (py-shell nil nil nil nil nil python-buffer) + )) (t (error "No function available for running an inferior Python"))) (setq org-babel-python-buffers Myles
Nick Dokos <nicholas.dokos@hp.com> writes:
> (run-python py-python-command)
>
> and then all the code blocks could execute with no problem. Has
> run-python changed signature recently?
Yes, from Emacs 24.1 to Emacs 24.2.
I fixed this, thanks.
--
Bastien
Hi Myles, thanks for digging into this. I'm copying Andreas as the maintainer of python-mode.el. Myles English <mylesenglish@gmail.com> writes: > --- lisp/ob-python.el > +++ lisp/ob-python.el > @@ -32,7 +32,7 @@ > > (declare-function org-remove-indentation "org" ) > (declare-function py-shell "ext:python-mode" (&optional argprompt)) > -(declare-function py-toggle-shells "ext:python-mode" (arg)) > +(declare-function py-toggle-shell "ext:python-mode" (arg)) If this function's name changed, there should be an alias in python-mode.el. > (declare-function run-python "ext:python" (&optional cmd noshow new)) > > (defvar org-babel-tangle-lang-exts) > @@ -162,16 +162,17 @@ then create. Return the initialized session." > ;; Make sure that py-which-bufname is initialized, as otherwise > ;; it will be overwritten the first time a Python buffer is > ;; created. > - (py-toggle-shells py-default-interpreter) > + (py-toggle-shell py-default-interpreter) > ;; `py-shell' creates a buffer whose name is the value of > ;; `py-which-bufname' with '*'s at the beginning and end > (let* ((bufname (if (and python-buffer (buffer-live-p python-buffer)) > (replace-regexp-in-string ;; zap surrounding * > "^\\*\\([^*]+\\)\\*$" "\\1" python-buffer) > (concat "Python-" (symbol-name session)))) > - (py-which-bufname bufname)) > - (py-shell) > - (setq python-buffer (concat "*" bufname "*")))) > + (py-buffer-name bufname)) > + (setq python-buffer (concat "*" bufname "*")) > + (py-shell nil nil nil nil nil python-buffer) > + )) The docstring of py-shell doesn't say much about why python-buffer would be needed as an argument here. Is it so? If yes, we need to make this compatible with previous versions of python-mode.el. (The argument PY-BUFFER-NAME is not documented in latest python-mode.el) Andreas, can you help sorting this out? Thanks, -- Bastien
Am 23.01.2013 14:04, schrieb Bastien: > Hi Myles, > > thanks for digging into this. > > I'm copying Andreas as the maintainer of python-mode.el. > > Myles English <mylesenglish@gmail.com> writes: > >> --- lisp/ob-python.el >> +++ lisp/ob-python.el >> @@ -32,7 +32,7 @@ >> >> (declare-function org-remove-indentation "org" ) >> (declare-function py-shell "ext:python-mode" (&optional argprompt)) >> -(declare-function py-toggle-shells "ext:python-mode" (arg)) >> +(declare-function py-toggle-shell "ext:python-mode" (arg)) > Hi Bastien, > If this function's name changed, there should be an alias in > python-mode.el. > right >> (declare-function run-python "ext:python" (&optional cmd noshow new)) >> >> (defvar org-babel-tangle-lang-exts) >> @@ -162,16 +162,17 @@ then create. Return the initialized session." >> ;; Make sure that py-which-bufname is initialized, as otherwise >> ;; it will be overwritten the first time a Python buffer is >> ;; created. >> - (py-toggle-shells py-default-interpreter) >> + (py-toggle-shell py-default-interpreter) >> ;; `py-shell' creates a buffer whose name is the value of >> ;; `py-which-bufname' with '*'s at the beginning and end >> (let* ((bufname (if (and python-buffer (buffer-live-p python-buffer)) >> (replace-regexp-in-string ;; zap surrounding * >> "^\\*\\([^*]+\\)\\*$" "\\1" python-buffer) >> (concat "Python-" (symbol-name session)))) >> - (py-which-bufname bufname)) >> - (py-shell) >> - (setq python-buffer (concat "*" bufname "*")))) >> + (py-buffer-name bufname)) >> + (setq python-buffer (concat "*" bufname "*")) >> + (py-shell nil nil nil nil nil python-buffer) >> + )) > > The docstring of py-shell doesn't say much about why python-buffer > would be needed as an argument here. Is it so? > > If yes, we need to make this compatible with previous versions of > python-mode.el. > > (The argument PY-BUFFER-NAME is not documented in latest > python-mode.el) > > Andreas, can you help sorting this out? > > Thanks, > Okay, I'll dig into. For the moment: assume this code should not be needed, python-mode.el should act that all. But let me have a closer look, Cheers, Andreas
Hi Andreas,
Andreas Röhler <andreas.roehler@online.de> writes:
> Okay, I'll dig into.
>
> For the moment: assume this code should not be needed,
> python-mode.el should act that all. But let me have a closer look,
Great, thanks a lot!
--
Bastien
[-- Attachment #1: Type: text/plain, Size: 384 bytes --] Am 24.01.2013 15:10, schrieb Bastien: > Hi Andreas, > > Andreas Röhler <andreas.roehler@online.de> writes: > >> Okay, I'll dig into. >> >> For the moment: assume this code should not be needed, >> python-mode.el should act that all. But let me have a closer look, > > Great, thanks a lot! > So let's start with this... BTW, being deeply impressed by org-mode and babel in special. [-- Attachment #2: ob-python.el.diff --] [-- Type: text/x-patch, Size: 994 bytes --] commit e7a5839b5a10d0a27e26b8f1d16296f4c20a1350 Author: Andreas Roehler <andreas.roehler@online.de> Date: Thu Feb 21 20:46:49 2013 +0100 Depend default python-mode from existing feature The former (if (featurep 'xemacs) 'python-mode 'python) makes a wrong assumption, as python-mode.el provides 'python-mode which does not depend from use of XEmacs A next step should enable users to choose environment via defcustom diff --git a/lisp/ob-python.el b/lisp/ob-python.el index 02d762c..1b3b892 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -43,7 +43,7 @@ (defvar org-babel-python-command "python" "Name of the command for executing Python code.") -(defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python) +(defvar org-babel-python-mode (if (featurep 'python-mode) 'python-mode 'python) "Preferred python mode for use in running python interactively. This will typically be either 'python or 'python-mode.")
[-- Attachment #1: Type: text/plain, Size: 353 bytes --] Am 24.01.2013 15:10, schrieb Bastien: > Hi Andreas, > > Andreas Röhler <andreas.roehler@online.de> writes: > >> Okay, I'll dig into. >> >> For the moment: assume this code should not be needed, >> python-mode.el should act that all. But let me have a closer look, > > Great, thanks a lot! > ob-python.el patch again better provision for XEmacs users [-- Attachment #2: ob-python.el.diff --] [-- Type: text/x-patch, Size: 1039 bytes --] commit 0fd2ac7ede3d7c8602a0a71fe1dc1678773baee4 Author: Andreas Roehler <andreas.roehler@online.de> Date: Fri Feb 22 09:08:28 2013 +0100 Depend default python-mode from existing feature The former (if (featurep 'xemacs) 'python-mode 'python) makes a wrong assumption, as python-mode.el provides 'python-mode which does not depend from use of XEmacs python-mode.el should provide a defcustom still to choose environment TINYCHANGE diff --git a/lisp/ob-python.el b/lisp/ob-python.el index 02d762c..c9118e9 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -43,7 +43,7 @@ (defvar org-babel-python-command "python" "Name of the command for executing Python code.") -(defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python) +(defvar org-babel-python-mode (if (or (featurep 'python-mode)(featurep 'xemacs)) 'python-mode 'python) "Preferred python mode for use in running python interactively. This will typically be either 'python or 'python-mode.")
Hi Andreas,
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> ob-python.el patch again
I applied a more complete patch, turning `org-babel-python-command'
and `org-babel-python-mode' into defcustoms.
`org-babel-python-mode' will not default to 'python-mode until
'python-mode is featured, so users will typically want to set
this variable, exposing it as a defcustom is useful IMO.
Thanks for the patch!
--
Bastien