From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YE2aA45QvV4KFwAA0tVLHw (envelope-from ) for ; Thu, 14 May 2020 14:07:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id sBtkOY1QvV67JQAAbx9fmQ (envelope-from ) for ; Thu, 14 May 2020 14:07:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 137E89400BF for ; Thu, 14 May 2020 14:07:07 +0000 (UTC) Received: from localhost ([::1]:50042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZEVv-0006WV-Nw for larch@yhetil.org; Thu, 14 May 2020 10:07:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZEVY-0006WD-Ii for emacs-orgmode@gnu.org; Thu, 14 May 2020 10:06:44 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:42875) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZEVX-0002TJ-3R for emacs-orgmode@gnu.org; Thu, 14 May 2020 10:06:43 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 7A779C000E; Thu, 14 May 2020 14:06:39 +0000 (UTC) From: Nicolas Goaziou To: =?utf-8?B?R8O2a3R1xJ8=?= Kayaalp Subject: Re: =?utf-8?Q?=E2=80=98org-test-with-temp-text=E2=80=99?= fails weirdly References: <87h7wsjxgf.fsf@gkayaalp.com> Mail-Followup-To: =?utf-8?B?R8O2a3R1xJ8=?= Kayaalp , emacs-orgmode@gnu.org Date: Thu, 14 May 2020 16:06:38 +0200 In-Reply-To: <87h7wsjxgf.fsf@gkayaalp.com> (=?utf-8?B?IkfDtmt0dcSf?= Kayaalp"'s message of "Thu, 07 May 2020 05:22:24 +0300") Message-ID: <87pnb68vbl.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=217.70.183.198; envelope-from=mail@nicolasgoaziou.fr; helo=relay6-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 10:06:40 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URIBL_SBL=1.623, URIBL_SBL_A=0.1 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: 0.49 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [0.49 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.53837440057217]; HAS_XOIP(0.00)[]; MX_INVALID(1.00)[cached]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.05), country: US(-0.00), ip: 209.51.188.17(-0.54)]; DWL_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; RCPT_COUNT_TWO(0.00)[2]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; FROM_NEQ_ENVFROM(0.00)[mail@nicolasgoaziou.fr,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[gkayaalp.com:email]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[nicolasgoaziou.fr]; HAS_LIST_UNSUB(-0.01)[]; DNSWL_BLOCKED(0.00)[209.51.188.17:from]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: 8Yxo9hkoAQ+M Hello, G=C3=B6ktu=C4=9F Kayaalp writes: > I was trying to have spurious indentation removed from Python source > blocks before execution so that such blocks can be indented in Org mode > buffers. Removing indentation from Python blocks sounds like a bad idea. Do you have an example demonstrating what you need? > I think the cause is the modifications to the code blocks body (deletion > of spurious indentation from an indented src block), but I=E2=80=99m not = sure > how exactly. > > This is weird because the in-buffer text doesn=E2=80=99t change. Do you have a reproducer for this? Ideally, using Emacs Lisp instead of Python. > In any case I=E2=80=99m also proposing the attached patch as a new featur= e. > Could start a new thread for it if necessary. > +(defun org-babel-python--clean-spurious-indentation (body) > + (let* ((extra-indentation > + (save-match-data > + (string-match "\\`\\([ \t]+\\)" body) > + (match-string 1 body))) > + (xlen (length extra-indentation))) > + (if (zerop xlen) > + body > + (mapconcat > + (lambda (line) (if (<=3D (length line) xlen) > + line > + (if (string=3D extra-indentation > + (substring line 0 xlen)) > + (substring line xlen) > + line))) > + (split-string body "\n") > + "\n")))) I think `org-remove-indentation' does about the same. It does not systematically use first line as reference, though. Regards, --=20 Nicolas Goaziou