emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Python src blocks indent
@ 2017-05-16 19:11 Fabrice Popineau
  2017-05-17 12:27 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Fabrice Popineau @ 2017-05-16 19:11 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

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

Hi,

I have a problem with Python src blocks indentation.
At the moment, I export IPython notebooks with ox-ipynb
(https://github.com/jkitchin/scimax/blob/master/ox-ipynb.el
from scimax by John Kitchin)

All the lines but the first one in src code blocks have 2 superfluous
leading spaces.
If I set
(setq org-edit-src-content-indentation 0)
then the code blocks are ok.

Any idea where to look for to track this problem further down ?

Best regards,

Fabrice

[-- Attachment #2: Type: text/html, Size: 740 bytes --]

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

* Re: Python src blocks indent
  2017-05-16 19:11 Python src blocks indent Fabrice Popineau
@ 2017-05-17 12:27 ` Nicolas Goaziou
  2017-05-17 12:45   ` Fabrice Popineau
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2017-05-17 12:27 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: emacs-orgmode@gnu.org

Hello,

Fabrice Popineau <fabrice.popineau@gmail.com> writes:

> I have a problem with Python src blocks indentation.
> At the moment, I export IPython notebooks with ox-ipynb
> (https://github.com/jkitchin/scimax/blob/master/ox-ipynb.el
> from scimax by John Kitchin)
>
> All the lines but the first one in src code blocks have 2 superfluous
> leading spaces.

What do you mean by 2 superfluous leading spaces?
org-edit-src-content-indentation default value is 2. Do yo mean there
are now 4 spaces?

Could you show an ECM?


Regards,

-- 
Nicolas Goaziou

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

* Re: Python src blocks indent
  2017-05-17 12:27 ` Nicolas Goaziou
@ 2017-05-17 12:45   ` Fabrice Popineau
  2017-05-17 13:08     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Fabrice Popineau @ 2017-05-17 12:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org

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

Hi,

I mean that in the Org buffer I have for example :

#+BEGIN_SRC ipython :session
  def fact(n):
      if n == 1:
          return 1
      else:
          return n * fact(n-1)
#+END_SRC

That is, there is a 2 spaces indentation of the whole code block, and the
code block is properly indented.
When I export it, I get :

def fact(n):
      if n == 1:
          return 1
      else:
          return n * fact(n-1)

in the IPython cell (basically, the notebook format is JSON and it is easy
to count those spaces in the code string in the JSON file)
and the 2 org-edit-src-content-indentation have been removed
only on the first line. The other ones have 6 or 10 spaces instead of 4 and
8.

Given that changing org-edit-src-content-indentation to 0 fixes this
problem, I wonder if there
is something wrong in the logic where this variable is used (only one place
in org-src).
But that could well be that it is not taken into account in places where it
should.

Regards,

Fabrice

[-- Attachment #2: Type: text/html, Size: 2678 bytes --]

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

* Re: Python src blocks indent
  2017-05-17 12:45   ` Fabrice Popineau
@ 2017-05-17 13:08     ` Nicolas Goaziou
  2017-05-17 20:49       ` Fabrice Popineau
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2017-05-17 13:08 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: emacs-orgmode@gnu.org

Fabrice Popineau <fabrice.popineau@gmail.com> writes:

> I mean that in the Org buffer I have for example :
>
> #+BEGIN_SRC ipython :session
>   def fact(n):
>       if n == 1:
>           return 1
>       else:
>           return n * fact(n-1)
> #+END_SRC
>
> That is, there is a 2 spaces indentation of the whole code block, and the
> code block is properly indented.
> When I export it, I get :
>
> def fact(n):
>       if n == 1:
>           return 1
>       else:
>           return n * fact(n-1)

FWIW I cannot reproduce it. You may want to debug
`org-export-unravel-code', `org-export-format-code' or
`org-export-format-code-default'.

Regards,

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

* Re: Python src blocks indent
  2017-05-17 13:08     ` Nicolas Goaziou
@ 2017-05-17 20:49       ` Fabrice Popineau
  0 siblings, 0 replies; 5+ messages in thread
From: Fabrice Popineau @ 2017-05-17 20:49 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org

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

Thanks Nicolas.

I should have looked closer at ox-ipynb since the problem is in there.
It should make use of  `org-export-unravel-code' and it doesn't. Instead
it trims leading white spaces from the src code.
I'll report it to the scimax github repository.

Best regards,

2017-05-17 15:08 GMT+02:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:

> Fabrice Popineau <fabrice.popineau@gmail.com> writes:
>
> > I mean that in the Org buffer I have for example :
> >
> > #+BEGIN_SRC ipython :session
> >   def fact(n):
> >       if n == 1:
> >           return 1
> >       else:
> >           return n * fact(n-1)
> > #+END_SRC
> >
> > That is, there is a 2 spaces indentation of the whole code block, and the
> > code block is properly indented.
> > When I export it, I get :
> >
> > def fact(n):
> >       if n == 1:
> >           return 1
> >       else:
> >           return n * fact(n-1)
>
> FWIW I cannot reproduce it. You may want to debug
> `org-export-unravel-code', `org-export-format-code' or
> `org-export-format-code-default'.
>
> Regards,
>

[-- Attachment #2: Type: text/html, Size: 1863 bytes --]

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

end of thread, other threads:[~2017-05-17 20:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 19:11 Python src blocks indent Fabrice Popineau
2017-05-17 12:27 ` Nicolas Goaziou
2017-05-17 12:45   ` Fabrice Popineau
2017-05-17 13:08     ` Nicolas Goaziou
2017-05-17 20:49       ` Fabrice Popineau

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