From mboxrd@z Thu Jan 1 00:00:00 1970 From: Norman Walsh Subject: =?UTF-8?B?4oCcTGl0ZXJhdGXigJ0gcHl0aG9uPw==?= Date: Fri, 29 Nov 2019 11:54:33 -0600 Message-ID: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46690) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iakTm-0006bH-Mt for emacs-orgmode@gnu.org; Fri, 29 Nov 2019 12:54:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iakTh-0003Oy-GH for emacs-orgmode@gnu.org; Fri, 29 Nov 2019 12:54:51 -0500 Received: from outbound1g.eu.mailhop.org ([52.28.6.212]:13276) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iakTf-0003EF-QV for emacs-orgmode@gnu.org; Fri, 29 Nov 2019 12:54:49 -0500 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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, I=E2=80=99ve seen a couple of pointers recently to using Org mode and tangle to write more literate Emacs configurations. I use Org+babel all the time to write =E2=80=9Cinteractive=E2=80=9D documents, so I thought I=E2=80= =99d try out tangle from Org. I didn=E2=80=99t want to start with something as comlicated as my Emacs config :-) so I figured I=E2=80=99d kick the tires with a small python program. That did not end well. Consider: #+TITLE: Python literate programming #+OPTIONS: html-postamble:nil It starts off as a completely standard Python3 program. =2D--%<------------------------------------------------------ #+BEGIN_SRC python :tangle yes :weave no #!/usr/bin/env python3 #+END_SRC It defines ~a~. #+BEGIN_SRC python :tangle yes def a(): print("a") #+END_SRC And ~b~. #+BEGIN_SRC python :tangle yes def b(): print("b") #+END_SRC Now ~c~ is a little more complicated: #+BEGIN_SRC python :tangle yes def c(): print("c") #+END_SRC Not only does ~c~ print =E2=80=9Cc=E2=80=9D, it calls ~a()~ and ~b()~. #+BEGIN_SRC python :tangle yes b() a() #+END_SRC Finally, make it importable. Not that you=E2=80=99d want to. #+BEGIN_SRC python :tangle yes if __name__ =3D=3D "__main__": main() #+END_SRC =2D-->%------------------------------------------------------ That=E2=80=99s the script. It weaves into HTML more-or-less ok (there=E2=80= =99s a weird black box at the front of indented lines, but I can come back to that later). It=E2=80=99s a complete mess when tangled. The extra blank lines between functions (to make pylint happy with some PEP guideline) have disappeared. I guess I could live with that, but the complete failure to preserve indention in the penultimate code block is a show stopper: #!/usr/bin/env python3 def a(): print("a") def b(): print("b") def c(): print("c") b() a() if __name__ =3D=3D "__main__": main() (Also, why is there an extra blank line before the incorrectly indented block?) Is this user error on my part somehow? I suppose I could write my own version of tangle, though I=E2=80=99m not clear if the whitespace is lost in the tangle function or in the Org mode data model. Thoughts? Be seeing you, norm =2D-=20 Norman Walsh | We discover in ourselves what others http://nwalsh.com/ | hide from us, and we recognize in | others what we hide from | ourselves.--Vauvenargues --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIyBAEBCAAdFiEE1ury//rzuvqf7fN/hVWfHhJMAHkFAl3hW1kACgkQhVWfHhJM AHnvNA/4yRG4dLwBGclQ8p48goLPeGj0x4fxoF1HItbV20YQB8f2JoEpbrZe0RDd XTAxfI1slwCVgTQpnil71qgUPLAT50mFYbAH/ZN0X2F0IGmRFxrUTkWKjBEraGbF vZizpeVnt0ebzZKxHz3wrCJtZSPanoKrMP0hU/RutIoCg6uUKnQWoy1u0RI6D6a9 l2Flv0QY5/isIFShVOUeRnBwFZYwzqGo/ADxwxTNuW+8N7pAcfwVdmMe9wPBrTnP /qQ0NDOSAoSASIzpOfWeqThvn0+mBFqyy//uxDwAZz2ChFkCYgZECKGwlGGABBwg Wz2W/p0QwlPe/6v9yjkQ3jItp+4nXCwR73bNuwyOO9Em/Ufgig+E47zsUYZ+LZPu uuM8aNwlWmftgluQxYMWyXkTYx204QeE+tY3w5Eznmxh6oCq46LaMbWY7AdSqNI+ 4px9mbEmZF7AfSXW1Vd3oZ0kTky09TvoanZ0wIX5E2kOVBD186rk847tV5w2AFIK i5T8JWD2fdmJ3sPdfaBqsKgjxuje6X8PUkJSshewAAvPCxgewSxFYnE05FlJimOo lYoJoDhJCdsErEqWp98mQKmtOsFrUmKGr5qKaWql1jd0+GiNZprSMsr9KGlGX9C4 ipe7Khp282cDVeKLWsB2dMU///I8embwvBvDBk/Wygx7OATrDg== =NFde -----END PGP SIGNATURE----- --=-=-=--