From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id YKzmDJcaqWUjlgAAqHPOHw:P1 (envelope-from ) for ; Thu, 18 Jan 2024 13:33:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id YKzmDJcaqWUjlgAAqHPOHw (envelope-from ) for ; Thu, 18 Jan 2024 13:33:27 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Kg9Xwuya; 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=1705581207; 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=ZmP8rIBNed+jgtF34SyTkqFFYIcnUROmTVrXgyUCOR8=; b=PA8OAi1b2IFGEDGWlejGoxk99H+UFN36unU2KzppWSTyWbYQx7clWxNXponW5pI2KXZXZD pxFaGopG8ojmFuSInMsK8PP/AgFCID/OpHxXRDje4L+VGKWcuR+NZc7/IgGgWosPBiVaBb M9lpT9UdsF4kOL0ZCZiVLZ9V/lLlrj0ATGkvb+X9nUH8fAkUl41p4w+VixdJOFl5/a75J5 uh8M0gKXdBroaH3Ku7Fq8Tj0OI3LIGvyABvHqrgZIsrqziQKn7H744HCsK5vZC3nF78zs9 22kVYdGyUh0Mk2Pkvxrx3dzMn8L1//Mn1Y/RU0J7JGuDddJ0xmgO3naHN2ey5w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Kg9Xwuya; 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=1705581207; a=rsa-sha256; cv=none; b=rYcDnqWhxwSfDajwiif1HwonPgsIKR6pYfdlZH2im5AlD/uhZReduTV/OYFxuLoswaDrj9 r1nWmkQRAvhj8XMjULsJCbiVbWQb4H2nrMegNpJV588mwZtPSXHPJY9CiqhqycYK7wgkrK 0Xw607hGnMwPEmui+28EjmX1YrL0pPBr2O/hJ4ozqjsxF2fsy28VR74UMg+Ds006KeD2hT xUtnnpl7pA9rbA8OKHVuJYUxg4L6u/fyGQOt/Fbf4TUw1W8lSPLp39djts/YPxG6y/bi4a 7evbdPdWbDzXHt0h0FO+JiIL/t+mjAvBDgwfSmEeGwzrVSPqU+pE6PXoib7OBw== 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 010C715CC5 for ; Thu, 18 Jan 2024 13:33:27 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQRZZ-0008W0-Ir; Thu, 18 Jan 2024 07:32:41 -0500 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 1rQRZJ-0008Ux-FX for emacs-orgmode@gnu.org; Thu, 18 Jan 2024 07:32:25 -0500 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 1rQRZE-0000Mj-Pn for emacs-orgmode@gnu.org; Thu, 18 Jan 2024 07:32:23 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A5E17240028 for ; Thu, 18 Jan 2024 13:32:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1705581138; bh=ZmP8rIBNed+jgtF34SyTkqFFYIcnUROmTVrXgyUCOR8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=Kg9XwuyadN9quh214SS1yGEPbg6QEIcKCukAJWYpLKB8yi+8pJAZ4w1YlGvw3SV/l xx9HkxNTFbSeP2IgkS2BXnXzhPJ+aVSn7hQcRZ7ssvkqcQleB72g/c5ieWFIjrmUrh YRfdwSL7ikbO7x32UCbIp7bspKAokQMdFV1aSZ63sabTECf6jPDYxV4pJNuSEmaEex CKQiQIAKkUAPtdWy2vi+D0kZOGv4KEy63DrUz32JApkbb4Po8OeSInEA14vhGkTpL+ C4ZkQu92UMCyYzeadiT6JH7A8fimbmXbCjtg5ZP6LkkMTxC8w0MMVSU+JZvsIri05S pts18y1ho5Ccw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TG2FF20qDz6tw7; Thu, 18 Jan 2024 13:32:17 +0100 (CET) From: Ihor Radchenko To: sebastien.miquel@posteo.eu Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] defaults make it hard to edit Elisp blocks in org buffers In-Reply-To: References: Date: Thu, 18 Jan 2024 12:35:32 +0000 Message-ID: <878r4makff.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.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=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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -7.03 X-Spam-Score: -7.03 X-Migadu-Queue-Id: 010C715CC5 X-Migadu-Scanner: mx12.migadu.com X-TUID: lVdFZin/UYSW S=C3=A9bastien Miquel writes: > The issue is that when you press return, you insert a newline, with no > indentation, then call =3Dorg-indent-line=3D which edits the block in a > native buffer. This is supposed to remove any common indentation, but > there is now none. Then it reinserts the code in the org-buffer, > adding a new common indentation to the block. Exactly. Confirmed. > If I recall correctly, in order to fix this, in =3Dorg-indent-line=3D, > before calling =3DTAB=3D in the native buffer, one should check the > current line indentation and if it is less than =3Dblock-content-ind=3D, > start by adding this much indentation to the current line. > > This could be a bit fragile, and in particular it assumes that the > rest of the block has this =3Dblock-content-ind=3D, which might not be the > case. One could possibly at least check that the first line of the > block does have this much indentation. If it doesn't, just do > whatever. What about a simpler approach - indent the line at point to block's expected indentation (if it is not yet there) and then rely upon the code block's major mode to do the right thing? Even when we are in a situation when the user did not just press C-j or , things should still work with the described approach. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at