From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrice Popineau Subject: Python src blocks indent Date: Tue, 16 May 2017 21:11:13 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c05b01ea21d93054fa8f055" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAhsd-0008Kg-OK for emacs-orgmode@gnu.org; Tue, 16 May 2017 15:11:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAhsc-0003mu-Sj for emacs-orgmode@gnu.org; Tue, 16 May 2017 15:11:35 -0400 Received: from mail-qk0-x229.google.com ([2607:f8b0:400d:c09::229]:36091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dAhsc-0003me-O3 for emacs-orgmode@gnu.org; Tue, 16 May 2017 15:11:34 -0400 Received: by mail-qk0-x229.google.com with SMTP id u75so138119418qka.3 for ; Tue, 16 May 2017 12:11:34 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "emacs-orgmode@gnu.org" --94eb2c05b01ea21d93054fa8f055 Content-Type: text/plain; charset="UTF-8" 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 --94eb2c05b01ea21d93054fa8f055 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable --94eb2c05b01ea21d93054fa8f055-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Python src blocks indent Date: Wed, 17 May 2017 14:27:52 +0200 Message-ID: <87mvabr7lj.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAy3o-0001jb-9H for emacs-orgmode@gnu.org; Wed, 17 May 2017 08:28:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAy3n-0004mw-Ew for emacs-orgmode@gnu.org; Wed, 17 May 2017 08:28:12 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:46871) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAy3n-0004mQ-8c for emacs-orgmode@gnu.org; Wed, 17 May 2017 08:28:11 -0400 In-Reply-To: (Fabrice Popineau's message of "Tue, 16 May 2017 21:11:13 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Fabrice Popineau Cc: "emacs-orgmode@gnu.org" Hello, Fabrice Popineau 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrice Popineau Subject: Re: Python src blocks indent Date: Wed, 17 May 2017 14:45:53 +0200 Message-ID: References: <87mvabr7lj.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114035986e91ca054fb7ac0a" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAyLI-00040t-1T for emacs-orgmode@gnu.org; Wed, 17 May 2017 08:46:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAyLH-0003Kl-4w for emacs-orgmode@gnu.org; Wed, 17 May 2017 08:46:16 -0400 Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]:35715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dAyLH-0003Kg-13 for emacs-orgmode@gnu.org; Wed, 17 May 2017 08:46:15 -0400 Received: by mail-qt0-x235.google.com with SMTP id v27so8062372qtg.2 for ; Wed, 17 May 2017 05:46:14 -0700 (PDT) In-Reply-To: <87mvabr7lj.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" --001a114035986e91ca054fb7ac0a Content-Type: text/plain; charset="UTF-8" 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 --001a114035986e91ca054fb7ac0a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I mean that in the Org buffer I hav= e for example :

#+BEGIN_SRC ipython :session
=C2=A0 def fact(n):
=C2=A0 =C2=A0 =C2=A0 if n =3D=3D 1:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1
=C2=A0 =C2=A0 =C2=A0 else:<= /font>
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 return n * fact(n-1)
#+END_SRC

That is, there is a 2 spaces indentation of the whole code block, a= nd the code block is properly indented.
Whe= n I export it, I get :

= def fact(n):
=C2= =A0 =C2=A0 =C2=A0 if n =3D=3D 1:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1
=C2=A0 =C2=A0 =C2=A0 else:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 re= turn n * fact(n-1)

in the IPython cell (basically, the notebook form= at is JSON and it is easy to count those spaces in the code string in the J= SON file)
and = the 2 org-edit-src-content-indentation have been removed
<= font face=3D"arial, helvetica, sans-serif">only on the first line. The othe= r ones have 6 or 10 spaces instead of 4 and 8.

Given that changing=C2=A0org-edit-src-content-= indentation to 0 fixes this problem, I won= der 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
=


--001a114035986e91ca054fb7ac0a-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Python src blocks indent Date: Wed, 17 May 2017 15:08:03 +0200 Message-ID: <87a86br5qk.fsf@nicolasgoaziou.fr> References: <87mvabr7lj.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAygX-0005ly-4G for emacs-orgmode@gnu.org; Wed, 17 May 2017 09:08:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAygR-0002YQ-IJ for emacs-orgmode@gnu.org; Wed, 17 May 2017 09:08:13 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:40102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAygR-0002Y5-Bw for emacs-orgmode@gnu.org; Wed, 17 May 2017 09:08:07 -0400 In-Reply-To: (Fabrice Popineau's message of "Wed, 17 May 2017 14:45:53 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Fabrice Popineau Cc: "emacs-orgmode@gnu.org" Fabrice Popineau 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, From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrice Popineau Subject: Re: Python src blocks indent Date: Wed, 17 May 2017 22:49:07 +0200 Message-ID: References: <87mvabr7lj.fsf@nicolasgoaziou.fr> <87a86br5qk.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c05f7589803dd054fbe6cf8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB5sv-0001Wr-Rh for emacs-orgmode@gnu.org; Wed, 17 May 2017 16:49:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB5su-0001mh-Rf for emacs-orgmode@gnu.org; Wed, 17 May 2017 16:49:29 -0400 Received: from mail-qk0-x22f.google.com ([2607:f8b0:400d:c09::22f]:36601) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB5su-0001mM-N1 for emacs-orgmode@gnu.org; Wed, 17 May 2017 16:49:28 -0400 Received: by mail-qk0-x22f.google.com with SMTP id u75so20682329qka.3 for ; Wed, 17 May 2017 13:49:28 -0700 (PDT) In-Reply-To: <87a86br5qk.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" --94eb2c05f7589803dd054fbe6cf8 Content-Type: text/plain; charset="UTF-8" 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 : > Fabrice Popineau 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, > --94eb2c05f7589803dd054fbe6cf8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks Nicolas.

I should have looked cl= oser at ox-ipynb since the problem is in there.
It should make us= e of =C2=A0`org-export-unravel-code&#= 39; and it doesn't. Instead
it trims leading white spaces from the src code.
I&= #39;ll report it to the scimax github repository.

= Best regards,

2017-05-17 15:08 GMT+02:00 Nicolas Goaziou <mail@nicolasgoazi= ou.fr>:
Fa= brice Popineau <fabrice.po= pineau@gmail.com> writes:

> I mean that in the Org buffer I have for example :
>
> #+BEGIN_SRC ipython :session
>=C2=A0 =C2=A0def fact(n):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if n =3D=3D 1:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 1
>=C2=A0 =C2=A0 =C2=A0 =C2=A0else:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 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):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if n =3D=3D 1:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 1
>=C2=A0 =C2=A0 =C2=A0 =C2=A0else:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 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,

--94eb2c05f7589803dd054fbe6cf8--