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 UDC7GQ/EomRDlAAASxT56A (envelope-from ) for ; Mon, 03 Jul 2023 14:50:23 +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 sOTKGA/EomQhTwEAG6o9tA (envelope-from ) for ; Mon, 03 Jul 2023 14:50:23 +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 E6A1A3E54 for ; Mon, 3 Jul 2023 14:50:22 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGIzy-000882-5q; Mon, 03 Jul 2023 08:49:47 -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 1qGIze-0007y5-Hx for emacs-orgmode@gnu.org; Mon, 03 Jul 2023 08:49:26 -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 1qGIzb-00085P-W5 for emacs-orgmode@gnu.org; Mon, 03 Jul 2023 08:49:26 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2F6F3240101 for ; Mon, 3 Jul 2023 14:49:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.eu; s=2017; t=1688388558; bh=sIyplIMZcrtpS5wD0CUrKrFfHosgA3euYJK13gptMLk=; h=Message-ID:Date:MIME-Version:Reply-To:Subject:To:Cc:From: Content-Transfer-Encoding:From; b=nyWjXzobbHF5jpusydgtpti7S2QfXi7H1nB+KWtLxtXXF2OWsliMW2VL/XdORatNG RNm4M+SgUgfKhyZwLvnUfAeiKC1M7JfeEw9lHo9BO0dMC58ycg+CujyEvRtT5s/MA9 nikvKVrKNt/LXjbJRTk1PXAjvmLxUS3YcG/iLLT/pReRSSTY9vKwp6U0JSZked5JFA kABTO5S0oK31JqT3k1tqFEbPCU0psinX2A0HbUzbQ6m79HROtIRKkBmmJ5EzfBUVu/ 4fdxTCp0zpfYRCJLrkFS4GqbSg92h6HJcLntFi1sg8hq4wBvO1AiqcjyPjdkYw21n/ eEVrLGFcr6skw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qvm2j5Hw3z9rxF; Mon, 3 Jul 2023 14:49:17 +0200 (CEST) Message-ID: <8d6dd95e-5bce-44c3-638a-52351b69cc66@posteo.eu> Date: Mon, 3 Jul 2023 12:49:17 +0000 MIME-Version: 1.0 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/)] To: Ihor Radchenko Cc: emacs-orgmode@gnu.org 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> <874jml8ggm.fsf@localhost> Content-Language: fr From: =?UTF-8?Q?S=c3=a9bastien_Miquel?= In-Reply-To: <874jml8ggm.fsf@localhost> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.67.36.66; envelope-from=sebastien.miquel@posteo.eu; helo=mout02.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=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: , Reply-To: sebastien.miquel@posteo.eu 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=1688388623; h=from:from:sender:sender:reply-to: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=qvFgmWbnSWAcV+gB2MZf80siK5h1vw54tnlGzeXcQOk=; b=Rlj1ShCAyZUbiRfElFX6UJ7B9K96jiH7kIh+YASFQXTe9wDEu3PxhlAT8UrJKQo2I9jTDc hTNzJUF3BVjfyWn0r90UrtaFdZhzE9UcqhWIDEmVEaGC0o9oOduM5f+7ylaNVjM94cJVaW KHogtCqYXwerd4WTnspI+woj4geVpQnDogxmV4YtYdJZWL6dLmNAwjukdF7GPDz5kPPE92 ke50DCYV1A9u1ygP8Iv0mLO2AZxEU3zIC2Ufoctf2yni4VME1RiIaTPINoY9dRcj+/aueg 5lMMVFyFpzdKqm2Z0fBbBK4ZMVca/ZgrlblwreRNZVTS4kH0pQrDIPOJQZLCeQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.eu header.s=2017 header.b=nyWjXzob; dmarc=pass (policy=none) header.from=posteo.eu; 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=1688388623; a=rsa-sha256; cv=none; b=j09YwbNPSymQc+4K5/rSn2hZirfUl0XI3INU3Gek0gqGw5PGGPJhHBdBKsCMnt3AK8knKb huE096eI5X6vcsTajVzqgbNDZ8SxOVoX18HLArp/KxFjWVBQZo93XzyX6c6efvpET5rKbg 5SejX6U7chdineMim5jKG/HE+ihR72uwh36bUgplngfxo9uINL/PT913Di2X5BPbCcyOKi 9RIIQoF99TiG2NdCkEERirRW/8FkJ/P9ClZBQZctXFBP9MAZmm72RilLkEzG2RqDHGWorx tSdvz+9BfdBKy+G1S3VV9xY3CIw/FLkhXJelXzCaTEjNYyXc0527snENiqbsng== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -6.61 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.eu header.s=2017 header.b=nyWjXzob; dmarc=pass (policy=none) header.from=posteo.eu; 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: E6A1A3E54 X-Spam-Score: -6.61 X-TUID: 4h3HW4OKFTIE Ihor Radchenko writes: >> 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. You're at the end of a line, you press =org-return-and-indent=. 1. It adds a newline character. 2. =org-indent-line= adds the org indentation, _before_ calling =org-babel-do-key-sequence-in-edit-buffer= 3. The native edit call removes the common indentation, before calling tab in the native buffer. 4. Calling tab in the native buffer possibly does nothing. 5. =org-src--contents-for-write-back= sees the current line is empty, but it should indent it (with org indentation) nonetheless. >> --- 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. I don't understand. With this change, the function only stops if it finds a non blank line with less than n indentation (same as before). When a blank line with less than n indentation is found, it is emptied (same as before), and execution continues. >> * 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? Are you advocating for computing N using blank lines as well ? 1. It isn't consistent with the previous behaviour. 2. If I mistakenly add a space to an empty line in a src block, an edit-special round trip will add indentation to every line. Is there any benefit ? -- Sébastien Miquel