all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Babel : python generate org source block with an extra comma before * characters
@ 2014-07-13 13:51 Roland DONAT
  2014-07-13 14:37 ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Roland DONAT @ 2014-07-13 13:51 UTC (permalink / raw)
  To: emacs-orgmode

Dear Orgmode community,

Thanks in advance to take some time to help me with my problem...

Here is what is making me very sad :

I have a python (python 3 interpreter) source block that I use to generate 
parts of a report written in Orgmode. Suppose we have this little example :

#+NAME: test
#+BEGIN_SRC python :results value org :session test

report = """*** header 1
My pretty report

*** header 2
Ah ah! With that stuff, I will increase my *productivity*!!!
"""

report
#+END_SRC

What I get is :
#+RESULTS: test
#+BEGIN_SRC org
,*** header 1
My pretty report

,*** header 2
Ah ah, with that stuff, I will increase my *productivity*!!!
#+END_SRC

My question : Why Orgmode adds the comma before the star character???

In the manual, I read some things about comma-escaping in Org source block 
so my intuition tells me that my problem has something to do with that but I 
wasn't able to solve it for now.

My configuration :
- Org 8.2.5h on Linux Mint 16. 
- Python 3

Any help would be much appreciated! Thanks.

Roland.

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

* Re: Babel : python generate org source block with an extra comma before * characters
  2014-07-13 13:51 Babel : python generate org source block with an extra comma before * characters Roland DONAT
@ 2014-07-13 14:37 ` Thorsten Jolitz
  2014-07-13 18:07   ` Roland DONAT
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2014-07-13 14:37 UTC (permalink / raw)
  To: emacs-orgmode

Roland DONAT <roland.donat@gmail.com> writes:

> Dear Orgmode community,
>
> Thanks in advance to take some time to help me with my problem...
>
> Here is what is making me very sad :
>
> I have a python (python 3 interpreter) source block that I use to generate 
> parts of a report written in Orgmode. Suppose we have this little example :
>
> #+NAME: test
> #+BEGIN_SRC python :results value org :session test
>
> report = """*** header 1
> My pretty report
>
> *** header 2
> Ah ah! With that stuff, I will increase my *productivity*!!!
> """
>
> report
> #+END_SRC
>
> What I get is :
> #+RESULTS: test
> #+BEGIN_SRC org
> ,*** header 1
> My pretty report
>
> ,*** header 2
> Ah ah, with that stuff, I will increase my *productivity*!!!
> #+END_SRC
>
> My question : Why Orgmode adds the comma before the star character???
>
> In the manual, I read some things about comma-escaping in Org source block 
> so my intuition tells me that my problem has something to do with that
> but I
> wasn't able to solve it for now.
>
> My configuration :
> - Org 8.2.5h on Linux Mint 16. 
> - Python 3
>
> Any help would be much appreciated! Thanks.

This is because this function was applied to the results

,----[ C-h f org-escape-code-in-region RET ]
| org-escape-code-in-region is an interactive compiled Lisp function in
| `org-src.el'.
| 
| (org-escape-code-in-region BEG END)
| 
| Escape lines between BEG and END.
| Escaping happens when a line starts with "*", "#+", ",*" or
| ",#+" by appending a comma to it.
| 
| [back]
`----

Not sure how to get rid of this, maybe via :results raw? I'm not aware
of a configuration variable for this, but it surely exists. 

-- 
cheers,
Thorsten

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

* Re: Babel : python generate org source block with an extra comma before * characters
  2014-07-13 14:37 ` Thorsten Jolitz
@ 2014-07-13 18:07   ` Roland DONAT
  2014-07-14  0:15     ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Roland DONAT @ 2014-07-13 18:07 UTC (permalink / raw)
  To: emacs-orgmode

Thorsten Jolitz <tjolitz <at> gmail.com> writes:


> 
> This is because this function was applied to the results
> 
> ,----[ C-h f org-escape-code-in-region RET ]
> | org-escape-code-in-region is an interactive compiled Lisp function in
> | `org-src.el'.
> | 
> | (org-escape-code-in-region BEG END)
> | 
> | Escape lines between BEG and END.
> | Escaping happens when a line starts with "*", "#+", ",*" or
> | ",#+" by appending a comma to it.
> | 
> | [back]
> `----
> 
> Not sure how to get rid of this, maybe via :results raw? I'm not aware
> of a configuration variable for this, but it surely exists. 
> 

Thank you. It helps me much!

Based on your answer, I copy-paste the code of the function "org-escape-
code-in-region" in a source block in my org buffer and modify the code to 
prevent it from inserting the comma. It's a little bit dirty but it works.

Using the raw option produces a correct result but I need the generated code 
to be decorated with a drawer to automatically replace the result at each 
code execution.

To do so, I tried to use de "drawer" option. It gives me the good result 
with a drawer but then when I export my org buffer to latex, the drawers 
":RESULTS:" is also exported which is not cool...

Well, thanks again!

Roland.




 

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

* Re: Babel : python generate org source block with an extra comma before * characters
  2014-07-13 18:07   ` Roland DONAT
@ 2014-07-14  0:15     ` Thorsten Jolitz
  2014-07-15 15:35       ` Roland DONAT
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2014-07-14  0:15 UTC (permalink / raw)
  To: emacs-orgmode

Roland DONAT <roland.donat@gmail.com> writes:

> To do so, I tried to use de "drawer" option. It gives me the good result 
> with a drawer but then when I export my org buffer to latex, the drawers 
> ":RESULTS:" is also exported which is not cool...

Did you try header args ':exports code ' or ':exports none'?

-- 
cheers,
Thorsten

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

* Re: Babel : python generate org source block with an extra comma before * characters
  2014-07-14  0:15     ` Thorsten Jolitz
@ 2014-07-15 15:35       ` Roland DONAT
  0 siblings, 0 replies; 5+ messages in thread
From: Roland DONAT @ 2014-07-15 15:35 UTC (permalink / raw)
  To: emacs-orgmode

Thorsten Jolitz <tjolitz <at> gmail.com> writes:

> 
> Roland DONAT <roland.donat <at> gmail.com> writes:
> 
> > To do so, I tried to use de "drawer" option. It gives me the good result 
> > with a drawer but then when I export my org buffer to latex, the drawers 
> > ":RESULTS:" is also exported which is not cool...
> 
> Did you try header args ':exports code ' or ':exports none'?
> 

Sorry for the late reply and thanks for your post.

Yes I did and it does't work since these options do exactly what they are 
supposed to. So :  
- :exports code just exports my python source code.
- :exports none exports nothing.

But unfortunately I realised that the "BEGIN_ORG" drawer was also exported 
which is not what I want.

So, I will create another post on that specific subject.

Cheers.

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

end of thread, other threads:[~2014-07-15 15:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-13 13:51 Babel : python generate org source block with an extra comma before * characters Roland DONAT
2014-07-13 14:37 ` Thorsten Jolitz
2014-07-13 18:07   ` Roland DONAT
2014-07-14  0:15     ` Thorsten Jolitz
2014-07-15 15:35       ` Roland DONAT

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.