From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 UPsaCN6uiWSkVwAASxT56A (envelope-from ) for ; Wed, 14 Jun 2023 14:13:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 2EQYB96uiWQEHwAAG6o9tA (envelope-from ) for ; Wed, 14 Jun 2023 14:13:18 +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 7745E3B89 for ; Wed, 14 Jun 2023 14:13:17 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9PML-0006Xs-3R; Wed, 14 Jun 2023 08:12:21 -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 1q9PME-0006HX-Au for emacs-orgmode@gnu.org; Wed, 14 Jun 2023 08:12:14 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9PMB-0004om-6q for emacs-orgmode@gnu.org; Wed, 14 Jun 2023 08:12:13 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 246B8240027 for ; Wed, 14 Jun 2023 14:12:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686744725; bh=CcnTlSSbvp4WRuZbpuXGVBzEp5yTtgbiWM/mIptLils=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=AtunPI/y92ghBGR276qr2sfmvUC3Mcnc5h+kNUi1m9+lw5k10xXkK7BmpkCr5zUp2 UHFU6yKX4s7mwhB08lsrdxv2dilDZ8QDFzaWjhA2QlBM/sKPlCDYysNyB+sbtyyMzn s0Wmoy15rI3tpr71eb6i1kiAE7EVsZDwTa13WPcGE6yLm5sZzdVY8ab8NMt/UPu8Qw 26ODnVgsrYH4A7Lj2vKcS2ERj+8IaW0++t11dMZn9bHCNI3hzcs/bqeCjRzlvHT6+W QPV7D7vfZmLeXVMTo+LEj9czyX8NRv3DsPANbccyMAMwxkj7vjJAj8jALpea0/47Fn 1F6NK7iMEz+iA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qh46X14ycz9rxF; Wed, 14 Jun 2023 14:12:03 +0200 (CEST) From: Ihor Radchenko To: wolf , Bastien , =?utf-8?Q?S=C3=A9basti?= =?utf-8?Q?en?= Miquel 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: References: Date: Wed, 14 Jun 2023 12:16:58 +0000 Message-ID: <87ttva8chx.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.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=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1686744797; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Havf0xyvn6zOe8QBEF63WHG1bBNmZNFrtTwOTaxEZhQ=; b=bLhG+ekUbx+6J4KjUM9S8xtr7LkU7xlgXXkE4L57tlANlX1FfVwFcJPGouX3St7gBy/Ier jqfxj9VEimoM7F5y6K1bqNYVSF7JL7TY+h/fjJk5NGpoGShFzYtD6d75lTQy4jHZwYKN6S NENmS6v0AuLDKIEk4gr4gxo+4gKCzkO7waxUdPv5jvW6QmpWTmqu728cxKLfiUsc4wnuqk Dbl4t76auhz1aPRFRzuGKwLJHVqm98xu519choTVdDlG8XYqv95dinznuiU5gPN9nCjLLL cAJeWsH2PmQPXYnqRnEhj8o9iTtm+m8W7nznDMrHm0gTprdLRkLNQV1sfr9VJA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="AtunPI/y"; 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-Seal: i=1; s=key1; d=yhetil.org; t=1686744797; a=rsa-sha256; cv=none; b=H6TtW2TlNQIuUldMcT6/62N9a2O2wUuwdfZerwDWsS9X71m0BRrtw8acNf3SvM9tXZIuXf PtSPF7kkCcYNVBBCwIf5DWXcKknjNWZ3X9o/yrw/9fes9XcCYu6GasuCqJzKZ5oIty+mYR Ev64bjqOHUmRsGxhf9WkuHQNVD0nmLFxGxOP6bBmjuEQPnElQZKy+zolKYTYEonLF/cn9z KyDuAAZKSQwDSALT0UvZ3d5Om2eJybsrWjfhDWEhGARBSH2Y+qKZ0JPZ5u/beIXDTNLEzS vqjRwwqjojFcX27x4RKsuRuOqzFvdOBPaYpRSwo64LwJf+n5UhJX5OkcyJNCmQ== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -4.69 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="AtunPI/y"; 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-Queue-Id: 7745E3B89 X-Spam-Score: -4.69 X-TUID: 1sE4jnx0Vmpt --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable wolf writes: > Reproduction steps: > 1. Have org-mode and yaml-mode installed. > 2. C-x C-f /tmp/x.org RET > 3. Type in: > > #+begin_src yaml > a: > b: > c: > d: > #+end_src > > After each line, press RET to go to the next one. RET is bound to org-re= turn. > Notice that when you press RET after `c:', emacs will insert a TAB charac= ter, > instead of expected 8 spaces. Confirmed. This is caused by `org-src--contents-for-write-back' not adjusting blank line indentation in some cases. The attached diff will fix the issue, but git log reveals that the whole thing is fragile - we adjusted code in this area multiple times with a number of tricky special cases: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3De1c49af76 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3D70e65a202 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3Dee0fd1ec3 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3D70e65a202 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3D857ae366b https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3D91236a3db https://orgmode.org/list/0f961d3b-a4ef-fbbf-ab16-7ff1af8b2070@gmail.com https://orgmode.org/list/5DCBAF63-0E88-44AC-B892-1260F37E7E00@manicmind.ear= th CCing Bastien and S=C3=A9bastien, the authors of the previous commits in th= is area. I feel that the whole approach we use now with preserve-fl, use-tabs?, and preserve-blank-line is overcomplicated. Maybe someone can explain why we need all these special cases? The code does not reveal a whole lot. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=test.diff diff --git a/lisp/org-src.el b/lisp/org-src.el index 317682844..876310867 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -499,12 +499,9 @@ (defun org-src--contents-for-write-back (write-back-buf) (when preserve-fl (forward-line)) (while (not (eobp)) (skip-chars-forward " \t") - (when (or (not (eolp)) ; not a blank line - (and (eq (point) (marker-position marker)) ; current line - preserve-blank-line)) - (let ((i (current-column))) - (delete-region (line-beginning-position) (point)) - (indent-to (+ i indentation-offset)))) + (let ((i (current-column))) + (delete-region (line-beginning-position) (point)) + (indent-to (+ i indentation-offset))) (forward-line))) (set-marker marker nil)))) --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--