From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id kGmNGeSbomSjaQAASxT56A (envelope-from ) for ; Mon, 03 Jul 2023 11:59:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cOUYGeSbomRJ5gAAauVa8A (envelope-from ) for ; Mon, 03 Jul 2023 11:59:00 +0200 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 1774C2CD0A for ; Mon, 3 Jul 2023 11:59:00 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGJu-0000Ol-7k; Mon, 03 Jul 2023 05:58:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGGJs-0000OU-K6 for emacs-orgmode@gnu.org; Mon, 03 Jul 2023 05:58:08 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGGJq-0004GN-6f for emacs-orgmode@gnu.org; Mon, 03 Jul 2023 05:58:08 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 87842240103 for ; Mon, 3 Jul 2023 11:58:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1688378283; bh=SoP0Y6gHyWSlGzHKRMP9FfLMtBX4HUO5QsAnqXjbk4w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=lN3Fo6UnezfLZ34Ejj3OUbnxx8SnDBAyLpOl4soVNY6ZBbEvg2t2PHk94EUSXczN0 ymcRfpxibdpxZUrW93IS199+wZLv8QkXcVrpAVVrC3ZChzkjVtnbKbOAITk/5ewXDx tfDyQT2IsDMJsJoeWF5zITThSHpyFrS6hqm6Mwm9CPDVOK27aV8zfeH3HYDT2ofA60 Jw3ODTQY692XKGBdBTJEH54KDIHsqj7m9Cr9oaPTyvBztOzvnDKdqJaLbsEizH4ksy SP7iRCRfa0eCZcNDQE+KMQ4uvtWsKj4dYRrcGYxNevRzCzJoTqiontVSrNVKmk8mGs Uo3vi0bZV2VXA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QvhF65tW1z6tsf; Mon, 3 Jul 2023 11:58:02 +0200 (CEST) From: Ihor Radchenko To: sebastien.miquel@posteo.eu Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)] In-Reply-To: <4eb9a5ad-2d91-15ae-ccd9-894c0303cca2@posteo.eu> References: <87ttva8chx.fsf@localhost> <8d8642c9-ced3-b254-0f49-f7b9c06311ff@posteo.eu> <87352p9g13.fsf@localhost> <87zg4vsof6.fsf@localhost> <37d86bbf-c0e2-6337-efc2-cdf63dbf4580@posteo.eu> <87sfamsb7m.fsf@localhost> <274bbd61-790d-8e19-d3a0-0793126c3bb0@posteo.eu> <87cz1itp8k.fsf@localhost> <1a97917c-bbab-4d7f-b629-0c84807448f2@posteo.eu> <87a5wmtmug.fsf@localhost> <87o7l0vt5z.fsf@localhost> <1d145455-2047-2b7a-8222-8eadc2529c8c@posteo.eu> <87edltqiox.fsf@localhost> <87sfa7opo9.fsf@localhost> <4eb9a5ad-2d91-15ae-ccd9-894c0303cca2@posteo.eu> Date: Mon, 03 Jul 2023 09:58:01 +0000 Message-ID: <874jml8ggm.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1688378340; a=rsa-sha256; cv=none; b=LsFdlh3STuWu9xo5uDANiVZLOtJ5ZdbRHNWzfMHs2KbGVJxZgHf+hOjDlISQXvQUf0p9yu hn44j8vmnozMhGHmG0BGe8Yj62IupMEPIANkKy05XIru7vzNVGlyCY/11Pk7UmTB5FLidm Mp6Q3HNgkGg8IZ9qrUYVYnw5PtVBkRhevvloxt+zqJoWpfzwjqYmLTXRgStuZBY/8oIRo8 rDHDHpEF4FkmB+BOaG+a34sB6GawE9dis9k1VvaGpwkO7Y49QuhMhRzjqLkXNsA5jrLhbW Zx6DzqEkIfMAKGtExs+fVvtNZsUk5NM3qTgny6Vi2cXTMXuWXsejsPMSvrowjA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=lN3Fo6Un; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1688378340; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=GFBpSKKNgICw52FapkT6SM265uZtbB9gb9qbHjo6KTw=; b=nkO4PaoumrQWmtse6Z+XmmfZCuiNi43FecEHaxCng1ofuyqAHbKdptNBFjWGlicLEsT7u4 Q6fCnF0mEHleGUSL6gFzA3Ybc1fc8TE/swT7yXtgNoDRL6163ImALBxOE5n1jCFcZhQXg+ Zj5xbwi3Kqun1LSdx3CIJVyPphv/Xuc1BwTHLwtm3GByAXF00SpUox/AwZO7C8PHVdmOzj qeCchvwIMzotxNuDeZz5N6iwZEwn5cptS074wVdENrrzY6ODU6+Q6dHeMNrxRz0eBx1q6u c18wrYoSiq1zrFL5B3CUvjfXQg7RBeOANQYcaz7VNysd6LYG4imIh0mdshkvfg== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=lN3Fo6Un; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -7.53 X-Spam-Score: -7.53 X-Migadu-Queue-Id: 1774C2CD0A X-TUID: Pj4H0iOyXiQz S=C3=A9bastien Miquel writes: > On second thought, I don't think moving the LaTeX fragment logic away > from `org-src--contents-for-write-back` makes sense. This part of the > function does the opposite of `org-do-remove-indentation`, and the > latter has a boolean argument `skip-fl`, so it makes sense to keep it > the same here. It is simple enough. > > If you're worried about consistency with inline src blocks, I find it > weird for them to have newlines, let alone newlines mixed with org's > indentation. But if we do want to treat them the same, then we also > need to modify `org-do-remove-indentation` to skip the first line for > them as well. > > I've taken this part off the patch for now. Ok. I am not that much worried about consistency with inline src blocks. Rather do not like the mix of org-src buffer local variables and checking the block type. But we can leave this refactoring to another day. It is not just about preserve-fl. (also indentation-offset) > What happens is: in the org buffer, the line is not empty, because it > has the org indentation (which was possibly just added by > org-indent-line), but in the edit buffer, the line is empty, because > the common org indentation was removed. In that case, we want to add > back the org indentation. May you please provide an example when it is necessary? `org-indent-line' will run `org-babel-do-key-sequence-in-edit-buffer', so it should still use `org-src--contents-for-write-back' and will not modify the org buffer text directly. > --- a/lisp/org-macs.el > +++ b/lisp/org-macs.el > @@ -483,9 +483,12 @@ line. Return nil if it fails." > (when skip-fl (forward-line)) > (while (not (eobp)) > (let ((ind (progn (skip-chars-forward " \t") (current-column)))) > - (cond ((eolp) (delete-region (line-beginning-position) (point))) > - ((< ind n) (throw :exit nil)) > - (t (indent-line-to (- ind n)))) > + (cond ((< ind n) > + (if (eolp) (delete-region (line-beginning-position) (= point)) > + (throw :exit nil))) This function is actually confusing both before and after the change. According to the docstring: When optional argument N is a positive integer, remove exactly that much characters from indentation, if possible. But the function can actually remove less than N characters. Before your change, all the blank non-empty lines were unconditionally removed. After your change, the first such line is removed and the function returns nil without continuing. > * lisp/org-macs.el (org-do-remove-indentation): Preserve > indentation (spaces vs tabs) past the common indentation to remove. > Do not empty blank lines. Since not removing blank lines is intentional after the change, why doing it on a single line that is indented less than N? --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at