emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [odt] equation labels
@ 2011-08-23 14:36 Myles English
  2011-08-26 19:36 ` Jambunathan K
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Myles English @ 2011-08-23 14:36 UTC (permalink / raw)
  To: emacs-orgmode


Hello,

I am using the excellent org-odt, so thanks to Jambunathan K, and
everyone who has ever contributed to orgmode.

This may be quite simple so I am asking before making an minimal
example.  Does anyone know how to cause a label such as "Figure 1." in
the odt (for the resulting png), and set the caption for an equation
such as:

#+CAPTION: some caption
#+LABEL: eqn:psychrometric
\begin{equation*}
\label{eq:psychrometric}
 \capillaryPressure = ln(RH)\cdot \dens_w\frac{RT}{M_w}
\end{equation*}

?

The orgmode manual says that captions and labels are for images and
tables so unless there is a special trick I would probably try to wrap
the latex in something first, for dvipng to return the png to org, to
apply the CAPTION to, before exporting to odt.

Extra points for making it "Equation 1." instead of "Figure 1.".

Thanks,

Myles

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-23 14:36 [odt] equation labels Myles English
@ 2011-08-26 19:36 ` Jambunathan K
  2011-08-27 22:02 ` Jambunathan K
  2011-09-17 19:48 ` Jambunathan K
  2 siblings, 0 replies; 31+ messages in thread
From: Jambunathan K @ 2011-08-26 19:36 UTC (permalink / raw)
  To: emacs-orgmode


Hello Myles

> \begin{equation*}
> \label{eq:psychrometric}
>  \capillaryPressure = ln(RH)\cdot \dens_w\frac{RT}{M_w}
> \end{equation*}

dvipng refuses to produce png tex snippet above. I am not at all
 familiar with latex. I am not sure what is wrong.

If you have a good number of equations in your orgfile can you share it
with me? I can use it as a real-life example and cook up a preliminary
latex->mathml support using mathtoweb.

Do you have any quick opinions on mathtoweb? See my earlier post
http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html

Regarding your captions request, I will cook up something. But I would
like to fold it as part of latex->mathml work. Let's see.

Jambunathan K.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-23 14:36 [odt] equation labels Myles English
  2011-08-26 19:36 ` Jambunathan K
@ 2011-08-27 22:02 ` Jambunathan K
  2011-08-31 11:09   ` Myles English
  2011-09-17 19:48 ` Jambunathan K
  2 siblings, 1 reply; 31+ messages in thread
From: Jambunathan K @ 2011-08-27 22:02 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1972 bytes --]


Myles

> Does anyone know how to cause a label such as "Figure 1." in the odt
> (for the resulting png), and set the caption for an equation such as:
>
> #+CAPTION: some caption
> #+LABEL: eqn:psychrometric
> \begin{equation*}
> \label{eq:psychrometric}
>  \capillaryPressure = ln(RH)\cdot \dens_w\frac{RT}{M_w}
> \end{equation*}
>
> ?
>
> The orgmode manual says that captions and labels are for images and
> tables so unless there is a special trick I would probably try to wrap
> the latex in something first, for dvipng to return the png to org, to
> apply the CAPTION to, before exporting to odt.
>
> Extra points for making it "Equation 1." instead of "Figure 1.".

I have added support for honoring captions, label and attributes for
images that are dervied from latex fragments. Checkout the git repo and
let me know if there are any rough edges that need to be ironed out.

Note that the odt exporter treats Labels and their references in a
special way.

For example, if the label is defined as follows,

#+LABEL: Equation:1

Equation is considered as a "Category" [1] and "1" is considered as
sequence number. So this "category:seq-no" is the recommended form of
labels for odt export. Note that the seq-no found in Org file need not
be sequential. The odt exporter will faithfully reproduce the seqnos as
seen Org file to the odt file. You can auto-generate the "right" seqnos
by using Tools->Update->Update All.

If you are averse to launching the gui for updating of indices you can
do a odt->odt (yes, odt->odt) conversion for sanitizing of indices [2].

It is also worth noting that the attached file uses the as yet
undocumented 

#+ATTR_ODT: (:scale 2) 

to scale the image to twice the original size.

Jambunathan K.

> Thanks,
>
> Myles
>
>

Footnotes: 

[1]  Other "Categories" could be Illustration, Table, Text etc.
[2]  I have never used unoconv myself. But the source code does update
indices of the input document before further conversion.

-- 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: eqns.org --]
[-- Type: text/x-org, Size: 712 bytes --]

#+TITLE:     eqns.org
#+AUTHOR:    Jambunathan K
#+EMAIL:     kjambunathan@gmail.com
#+DATE:      2011-08-26 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:dvipng 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:

* Equations

  There is a equation down below.

#+CAPTION: Kinetic Energy
#+LABEL: Equation:1
#+ATTR_ODT: (:scale 2)

  \begin{equation*}
  e = \frac{1}{2}mv^2
  \end{equation*}

#+CAPTION: Kinetic Energy
#+LABEL: Equation:2
#+ATTR_ODT: (:scale 0.5)

  \begin{equation*}
  e = \frac{1}{2}mv^2
  \end{equation*}

[-- Attachment #3: eqns.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 9498 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-27 22:02 ` Jambunathan K
@ 2011-08-31 11:09   ` Myles English
  2011-08-31 11:37     ` suvayu ali
                       ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Myles English @ 2011-08-31 11:09 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode


Jambunathan,

>> On Sun, 28 Aug 2011 03:32:10 +0530, Jambunathan K said:

  > Myles

  >> Does anyone know how to cause a label such as "Figure 1." in the
  >> odt (for the resulting png), and set the caption for an equation
  >> such as:
  >> 
  >> #+CAPTION: some caption #+LABEL: eqn:psychrometric
  >> \begin{equation*} \label{eq:psychrometric} \capillaryPressure =
  >> ln(RH)\cdot \dens_w\frac{RT}{M_w} \end{equation*}

Sorry for the red herring: the equation above would never have worked
without mystyle.sty whose content includes:

\newcommand{\pressure}{p}
\newcommand{\capillaryPressure}{{\pressure_{c}}}
\newcommand{\dens_w}{\rho_w}

and is included by:

#+LATEX_HEADER: \usepackage{/home/myles/path/to/report/mystyle}

  > I have added support for honoring captions, label and attributes for
  > images that are dervied from latex fragments. Checkout the git repo
  > and let me know if there are any rough edges that need to be ironed
  > out.

Thank you!  I have just got around to trying this out and it works
great.  The only issue now is that the resolution of the pngs is low and
looks terrible.  I vaguely remember changing it deep in my latex
installation somewhere.

  > Note that the odt exporter treats Labels and their references in a
  > special way.

  > For example, if the label is defined as follows,

  > #+LABEL: Equation:1

  > Equation is considered as a "Category" [1] and "1" is considered as
  > sequence number. So this "category:seq-no" is the recommended form
  > of labels for odt export. Note that the seq-no found in Org file
  > need not be sequential. The odt exporter will faithfully reproduce
  > the seqnos as seen Org file to the odt file. You can auto-generate
  > the "right" seqnos by using Tools->Update->Update All.

  > If you are averse to launching the gui for updating of indices you
  > can do a odt->odt (yes, odt->odt) conversion for sanitizing of
  > indices [2].

  > It is also worth noting that the attached file uses the as yet
  > undocumented

  > #+ATTR_ODT: (:scale 2)

  > to scale the image to twice the original size.

  > Jambunathan K.

I your previous post you asked for my org file but I think that it is
superseded by your attachment?  When I have finished this report I am
working on I'll cut it down and offer it as an example if you like.

Myles

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-31 11:09   ` Myles English
@ 2011-08-31 11:37     ` suvayu ali
  2011-08-31 11:50     ` Myles English
  2011-08-31 14:07     ` Jambunathan K
  2 siblings, 0 replies; 31+ messages in thread
From: suvayu ali @ 2011-08-31 11:37 UTC (permalink / raw)
  To: Myles English, emacs-orgmode; +Cc: Jambunathan K

On Wed, Aug 31, 2011 at 1:09 PM, Myles English <mylesenglish@gmail.com> wrote:
> I your previous post you asked for my org file but I think that it is
> superseded by your attachment?  When I have finished this report I am
> working on I'll cut it down and offer it as an example if you like.

Examples like these are always a welcome addition to Worg. :)

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-31 11:09   ` Myles English
  2011-08-31 11:37     ` suvayu ali
@ 2011-08-31 11:50     ` Myles English
  2011-08-31 13:52       ` Jambunathan K
  2011-08-31 14:07     ` Jambunathan K
  2 siblings, 1 reply; 31+ messages in thread
From: Myles English @ 2011-08-31 11:50 UTC (permalink / raw)
  To: emacs-orgmode



>> On Wed, 31 Aug 2011 12:09:58 +0100, Myles English said:

  >> I have added support for honoring captions, label and attributes
  >> for images that are dervied from latex fragments. Checkout the git
  >> repo and let me know if there are any rough edges that need to be
  >> ironed out.

  > Thank you!  I have just got around to trying this out and it works
  > great.  The only issue now is that the resolution of the pngs is low
  > and looks terrible.  I vaguely remember changing it deep in my latex
  > installation somewhere.

Actually there is an old (2006) thread including a patch about a file
option to change the resolution:

http://lists.gnu.org/archive/html/emacs-orgmode/2006-09/msg00010.html

But I don't think it was applied and I am not sure how it would fit in
the current scheme.  Can anyone advise?

Myles

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-31 11:50     ` Myles English
@ 2011-08-31 13:52       ` Jambunathan K
  0 siblings, 0 replies; 31+ messages in thread
From: Jambunathan K @ 2011-08-31 13:52 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode

Myles English <mylesenglish@gmail.com> writes:

>>> On Wed, 31 Aug 2011 12:09:58 +0100, Myles English said:
>
>   >> I have added support for honoring captions, label and attributes
>   >> for images that are dervied from latex fragments. Checkout the git
>   >> repo and let me know if there are any rough edges that need to be
>   >> ironed out.
>
>   > Thank you!  I have just got around to trying this out and it works
>   > great.  The only issue now is that the resolution of the pngs is low
>   > and looks terrible.  I vaguely remember changing it deep in my latex
>   > installation somewhere.
>
> Actually there is an old (2006) thread including a patch about a file
> option to change the resolution:
>
> http://lists.gnu.org/archive/html/emacs-orgmode/2006-09/msg00010.html

INCREASING the `:html-scale' scale property in
`org-format-latex-options' will INCREASE the `-D' option by same factor.

I believe the above setting together with a "suitable" value of
#+ATTR_ODT: (:scale xxx) will achieve the required balance.

If you have lots of equations then applying #+ATTR_ODT option to each of
the images is a bit cumbersome. In that case you can tweak
`org-export-odt-pixels-per-inch' (The default value of this variable is
same as `display-pixels-per-inch' variable of Emacs session). HALVING
this variable will DOUBLE the size of all images uniformly.

Note for posterity:
1. ODT expects that the image size be specified in cms or inches. I
   believe image files have no "physical" dimensions associated with
   them but only pixel size. Mapping from pixels to cms or inches is
   again determined by display properties (ie, the same image will
   appear in different physical dimensions on different monitors.)

2. On my Netbook, MS Paint uses a pixels-per-inch of 96.0 while Emacs'
   display-pixels-per-inch reports a value of 72.0

Image sizes are a grey area to me. If there is an expert out there
willing to educate me I am all ears.

Jambunathan K.

> But I don't think it was applied and I am not sure how it would fit in
> the current scheme.  Can anyone advise?
>
> Myles
>
>
>

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-31 11:09   ` Myles English
  2011-08-31 11:37     ` suvayu ali
  2011-08-31 11:50     ` Myles English
@ 2011-08-31 14:07     ` Jambunathan K
  2 siblings, 0 replies; 31+ messages in thread
From: Jambunathan K @ 2011-08-31 14:07 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode


Myles

> I your previous post you asked for my org file but I think that it is
> superseded by your attachment?  

The example I used is from my own unit test file.

> When I have finished this report I am working on I'll cut it down and
> offer it as an example if you like.

Sure, I would very much want to receive a copy of your file with
equations. I will be adding support for LaTeX->MathML in another few
days time and I need some real life equations to assess the suitability
of mathtoweb converter and prototype my changes [1].

Using mathml for equations will also ensure that the equations are first
class citizens in the document and "scale" with the document settings.

Jambunathan K.

Footnotes: 

[1] Bonus points if your file has all manners of equations - equations
that flow with the text AND equations that are rendered as
paragraph. ODT exporter might have to tweak the "anchoring - character?
or paragraph?" properties of the resulting embedded object depending on
what manner of equation it is.

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-08-23 14:36 [odt] equation labels Myles English
  2011-08-26 19:36 ` Jambunathan K
  2011-08-27 22:02 ` Jambunathan K
@ 2011-09-17 19:48 ` Jambunathan K
  2 siblings, 0 replies; 31+ messages in thread
From: Jambunathan K @ 2011-09-17 19:48 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode


Myles 

Subsequent to our last interaction I added support LaTeX to MathML
conversion[1] and also enhanced the support for how the equations are
numbered.

You may want to look at all three posts in this thread.
http://www.mail-archive.com/emacs-orgmode@gnu.org/msg46437.html

Any feedback or comment is welcome. 

TIA,
Jambunathan K.

Footnotes: 
[1]  The patch is pending and has not hit the git repo yet

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [odt] equation labels
@ 2011-10-28  1:23 Myles English
  2011-10-30 22:11 ` Jambunathan K
  0 siblings, 1 reply; 31+ messages in thread
From: Myles English @ 2011-10-28  1:23 UTC (permalink / raw)
  To: emacs-orgmode


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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-10-28  1:23 [odt] equation labels Myles English
@ 2011-10-30 22:11 ` Jambunathan K
  2011-10-31 11:54   ` Myles English
  0 siblings, 1 reply; 31+ messages in thread
From: Jambunathan K @ 2011-10-30 22:11 UTC (permalink / raw)
  To: emacs-orgmode

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
>
>

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-10-30 22:11 ` Jambunathan K
@ 2011-10-31 11:54   ` Myles English
  2011-11-01 11:17     ` Myles English
  2011-11-01 19:39     ` Jambunathan K
  0 siblings, 2 replies; 31+ messages in thread
From: Myles English @ 2011-10-31 11:54 UTC (permalink / raw)
  To: emacs-orgmode


>> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-10-31 11:54   ` Myles English
@ 2011-11-01 11:17     ` Myles English
  2011-11-01 19:39     ` Jambunathan K
  1 sibling, 0 replies; 31+ messages in thread
From: Myles English @ 2011-11-01 11:17 UTC (permalink / raw)
  To: emacs-orgmode

>> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-10-31 11:54   ` Myles English
  2011-11-01 11:17     ` Myles English
@ 2011-11-01 19:39     ` Jambunathan K
  2011-11-01 19:49       ` Jambunathan K
  2011-11-02 13:18       ` Myles English
  1 sibling, 2 replies; 31+ messages in thread
From: Jambunathan K @ 2011-11-01 19:39 UTC (permalink / raw)
  To: emacs-orgmode


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
>
>

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-11-01 19:39     ` Jambunathan K
@ 2011-11-01 19:49       ` Jambunathan K
  2011-11-02 13:18       ` Myles English
  1 sibling, 0 replies; 31+ messages in thread
From: Jambunathan K @ 2011-11-01 19:49 UTC (permalink / raw)
  To: emacs-orgmode


>> 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.
-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-11-01 19:39     ` Jambunathan K
  2011-11-01 19:49       ` Jambunathan K
@ 2011-11-02 13:18       ` Myles English
       [not found]         ` <mylesenglish@gmail.com>
  1 sibling, 1 reply; 31+ messages in thread
From: Myles English @ 2011-11-02 13:18 UTC (permalink / raw)
  To: emacs-orgmode


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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
       [not found]         ` <mylesenglish@gmail.com>
@ 2011-11-02 13:38           ` Nick Dokos
  2011-11-02 14:49             ` Myles English
  2011-11-02 14:52           ` Nick Dokos
  1 sibling, 1 reply; 31+ messages in thread
From: Nick Dokos @ 2011-11-02 13:38 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: nicholas.dokos

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-11-02 13:38           ` Nick Dokos
@ 2011-11-02 14:49             ` Myles English
  0 siblings, 0 replies; 31+ messages in thread
From: Myles English @ 2011-11-02 14:49 UTC (permalink / raw)
  To: emacs-orgmode


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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
       [not found]         ` <mylesenglish@gmail.com>
  2011-11-02 13:38           ` Nick Dokos
@ 2011-11-02 14:52           ` Nick Dokos
  2011-11-02 18:21             ` Jambunathan K
  1 sibling, 1 reply; 31+ messages in thread
From: Nick Dokos @ 2011-11-02 14:52 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: nicholas.dokos

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-11-02 14:52           ` Nick Dokos
@ 2011-11-02 18:21             ` Jambunathan K
  2011-11-02 21:33               ` Myles English
  0 siblings, 1 reply; 31+ messages in thread
From: Jambunathan K @ 2011-11-02 18:21 UTC (permalink / raw)
  To: Myles English; +Cc: nicholas.dokos, emacs-orgmode


>>   >> 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.

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [odt] equation labels
  2011-11-02 18:21             ` Jambunathan K
@ 2011-11-02 21:33               ` Myles English
  0 siblings, 0 replies; 31+ messages in thread
From: Myles English @ 2011-11-02 21:33 UTC (permalink / raw)
  To: emacs-orgmode

>> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* session with python-mode.el complains of void py-toggle-shells
@ 2013-01-23  2:47 Myles English
  2013-01-23  4:11 ` Nick Dokos
  0 siblings, 1 reply; 31+ messages in thread
From: Myles English @ 2013-01-23  2:47 UTC (permalink / raw)
  To: Emacs-orgmode

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: session with python-mode.el complains of void py-toggle-shells
  2013-01-23  2:47 session with python-mode.el complains of void py-toggle-shells Myles English
@ 2013-01-23  4:11 ` Nick Dokos
  2013-01-23 12:46   ` [PATCH] " Myles English
  2013-01-23 13:00   ` Bastien
  0 siblings, 2 replies; 31+ messages in thread
From: Nick Dokos @ 2013-01-23  4:11 UTC (permalink / raw)
  To: Myles English; +Cc: Emacs-orgmode

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] session with python-mode.el complains of void py-toggle-shells
  2013-01-23  4:11 ` Nick Dokos
@ 2013-01-23 12:46   ` Myles English
  2013-01-23 13:04     ` Bastien
  2013-01-23 13:00   ` Bastien
  1 sibling, 1 reply; 31+ messages in thread
From: Myles English @ 2013-01-23 12:46 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Emacs-orgmode


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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: session with python-mode.el complains of void py-toggle-shells
  2013-01-23  4:11 ` Nick Dokos
  2013-01-23 12:46   ` [PATCH] " Myles English
@ 2013-01-23 13:00   ` Bastien
  1 sibling, 0 replies; 31+ messages in thread
From: Bastien @ 2013-01-23 13:00 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Myles English, Emacs-orgmode

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] session with python-mode.el complains of void py-toggle-shells
  2013-01-23 12:46   ` [PATCH] " Myles English
@ 2013-01-23 13:04     ` Bastien
  2013-01-23 18:02       ` Andreas Röhler
  0 siblings, 1 reply; 31+ messages in thread
From: Bastien @ 2013-01-23 13:04 UTC (permalink / raw)
  To: Myles English; +Cc: andreas, nicholas.dokos, Emacs-orgmode

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] session with python-mode.el complains of void py-toggle-shells
  2013-01-23 13:04     ` Bastien
@ 2013-01-23 18:02       ` Andreas Röhler
  2013-01-24 14:10         ` Bastien
  0 siblings, 1 reply; 31+ messages in thread
From: Andreas Röhler @ 2013-01-23 18:02 UTC (permalink / raw)
  To: Bastien; +Cc: Myles English, Emacs-orgmode, nicholas.dokos

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] session with python-mode.el complains of void py-toggle-shells
  2013-01-23 18:02       ` Andreas Röhler
@ 2013-01-24 14:10         ` Bastien
  2013-02-21 20:08           ` Andreas Röhler
  2013-02-22  8:25           ` Andreas Röhler
  0 siblings, 2 replies; 31+ messages in thread
From: Bastien @ 2013-01-24 14:10 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: Myles English, Emacs-orgmode, nicholas.dokos

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] session with python-mode.el complains of void py-toggle-shells
  2013-01-24 14:10         ` Bastien
@ 2013-02-21 20:08           ` Andreas Röhler
  2013-02-22  8:25           ` Andreas Röhler
  1 sibling, 0 replies; 31+ messages in thread
From: Andreas Röhler @ 2013-02-21 20:08 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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.")
 

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] session with python-mode.el complains of void py-toggle-shells
  2013-01-24 14:10         ` Bastien
  2013-02-21 20:08           ` Andreas Röhler
@ 2013-02-22  8:25           ` Andreas Röhler
  2013-02-23  9:29             ` Bastien
  1 sibling, 1 reply; 31+ messages in thread
From: Andreas Röhler @ 2013-02-22  8:25 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bastien

[-- 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.")
 

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] session with python-mode.el complains of void py-toggle-shells
  2013-02-22  8:25           ` Andreas Röhler
@ 2013-02-23  9:29             ` Bastien
  0 siblings, 0 replies; 31+ messages in thread
From: Bastien @ 2013-02-23  9:29 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2013-02-23 10:48 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-28  1:23 [odt] equation labels Myles English
2011-10-30 22:11 ` Jambunathan K
2011-10-31 11:54   ` Myles English
2011-11-01 11:17     ` Myles English
2011-11-01 19:39     ` Jambunathan K
2011-11-01 19:49       ` Jambunathan K
2011-11-02 13:18       ` Myles English
     [not found]         ` <mylesenglish@gmail.com>
2011-11-02 13:38           ` Nick Dokos
2011-11-02 14:49             ` Myles English
2011-11-02 14:52           ` Nick Dokos
2011-11-02 18:21             ` Jambunathan K
2011-11-02 21:33               ` Myles English
  -- strict thread matches above, loose matches on Subject: below --
2013-01-23  2:47 session with python-mode.el complains of void py-toggle-shells Myles English
2013-01-23  4:11 ` Nick Dokos
2013-01-23 12:46   ` [PATCH] " Myles English
2013-01-23 13:04     ` Bastien
2013-01-23 18:02       ` Andreas Röhler
2013-01-24 14:10         ` Bastien
2013-02-21 20:08           ` Andreas Röhler
2013-02-22  8:25           ` Andreas Röhler
2013-02-23  9:29             ` Bastien
2013-01-23 13:00   ` Bastien
2011-08-23 14:36 [odt] equation labels Myles English
2011-08-26 19:36 ` Jambunathan K
2011-08-27 22:02 ` Jambunathan K
2011-08-31 11:09   ` Myles English
2011-08-31 11:37     ` suvayu ali
2011-08-31 11:50     ` Myles English
2011-08-31 13:52       ` Jambunathan K
2011-08-31 14:07     ` Jambunathan K
2011-09-17 19:48 ` Jambunathan K

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).