From unknown Sun Jun 22 00:15:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68185: [PATCH] Ensure indent-region argument order is correct Resent-From: Morgan Willcock Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 Dec 2023 21:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68185 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 68185@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170405764513311 (code B ref -1); Sun, 31 Dec 2023 21:21:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Dec 2023 21:20:45 +0000 Received: from localhost ([127.0.0.1]:47124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rK3Ej-0003Sc-8k for submit@debbugs.gnu.org; Sun, 31 Dec 2023 16:20:45 -0500 Received: from lists.gnu.org ([2001:470:142::17]:43404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rK3Eg-0003SJ-Up for submit@debbugs.gnu.org; Sun, 31 Dec 2023 16:20:43 -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 1rK3EW-00015S-JJ for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2023 16:20:32 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rK3EK-0001PF-4N for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2023 16:20:32 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id B85F0FF805 for ; Sun, 31 Dec 2023 21:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1704057613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=m5yn/nAMptIS0Y6fvyUyj0WM5nYA2vw3DytoIXjCYJU=; b=Up7J0ttMSHUxHK/6+dAFm01BANCvicYjkG6jQ6dGmgQbMXQXgLtvdd7fL6Drgiw0f0YXZ0 95iPBOmPt46woGIpA2+IOIZ+lv7cDHUH14QhrH2QONetOZ6eWA+rg8hlk1MPLlugJLW0mg aT28IVhOJ9L922jb7jvuU+KFXkgpc7I6KE1z4o2WTOyNiHGTwvCA9XvaQQDT+ef7zZz1eW BXW2W/Qei2u1vi7b3NJRDqEBW03VPqYcaWNy6jJv6EG+3z475+s6ZSKacj4NY4GjBFA4hW v033FBCQzYW9QGlkvuMq5ry4N0ULwiiBsa+9Pl0+syPCvUTwU0jJKMlJK6R0Bg== From: Morgan Willcock Date: Sun, 31 Dec 2023 21:20:11 +0000 Message-ID: <874jfy6pdg.fsf@ice9.digital> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: morgan@ice9.digital Received-SPF: pass client-ip=217.70.183.199; envelope-from=morgan@ice9.digital; helo=relay9-d.mail.gandi.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.6 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) --=-=-= Content-Type: text/plain Tags: patch The attached patch fixes an issue with Tempo template insertion, where the region start is assumed to be a position before the region end. If the user selects a region in a backwards direction the correct indentation will not be applied: (require 'tempo) (tempo-define-template "indent-region-test" '(r>)) (with-temp-buffer (emacs-lisp-mode) (insert " one\n two\n three") (goto-char (point-min)) (set-mark-command nil) (goto-char (point-max)) (tempo-template-indent-region-test) (buffer-string)) ;; => "one\ntwo\nthree" (with-temp-buffer (emacs-lisp-mode) (insert " one\n two\n three") (goto-char (point-max)) (set-mark-command nil) (goto-char (point-min)) (tempo-template-indent-region-test) (buffer-string)) ;; => " one\n two\nthree" The start and end positions are already identified and stored using separate variables, so the patch just uses these values instead of assuming the point and mark order. I've also removed passing nil as the third argument since the argument is optional. In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2023-07-31 built on inspiron Windowing system distributor 'The X.Org Foundation', version 11.0.12101007 System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure --with-native-compilation --with-cairo --with-json --with-xml2 --with-x-toolkit=lucid' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Ensure-indent-region-argument-order-is-correct.patch >From 4d7fdafeee5f6540d5e39549fa0a9927176171bb Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Sun, 31 Dec 2023 20:47:17 +0000 Subject: [PATCH] Ensure indent-region argument order is correct * lisp/tempo.el (tempo-insert): Call indent-region with the stored region markers to ensure that the start and end arguments are used in the correct order. --- lisp/tempo.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/tempo.el b/lisp/tempo.el index 45dc24dcc97..1b6cc4476e1 100644 --- a/lisp/tempo.el +++ b/lisp/tempo.el @@ -333,7 +333,8 @@ tempo-insert (`(r> . ,rest) (if on-region (progn (goto-char tempo-region-stop) - (indent-region (mark) (point) nil)) + (indent-region tempo-region-start + tempo-region-stop)) (tempo-insert-prompt-compat rest))) (`(s ,name) (tempo-insert-named name)) (`(l . ,rest) (dolist (elt rest) (tempo-insert elt on-region))) @@ -344,7 +345,7 @@ tempo-insert ('r> (if on-region (progn (goto-char tempo-region-stop) - (indent-region (mark) (point) nil)) + (indent-region tempo-region-start tempo-region-stop)) (tempo-insert-mark (point-marker)))) ('> (indent-according-to-mode)) ('& (if (not (or (= (current-column) 0) -- 2.39.2 --=-=-=-- From unknown Sun Jun 22 00:15:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68185: [PATCH] Ensure indent-region argument order is correct References: <874jfy6pdg.fsf@ice9.digital> In-Reply-To: <874jfy6pdg.fsf@ice9.digital> Resent-From: Morgan Willcock Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 Dec 2023 22:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68185 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 68185@debbugs.gnu.org Received: via spool by 68185-submit@debbugs.gnu.org id=B68185.17040623865692 (code B ref 68185); Sun, 31 Dec 2023 22:40:01 +0000 Received: (at 68185) by debbugs.gnu.org; 31 Dec 2023 22:39:46 +0000 Received: from localhost ([127.0.0.1]:47143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rK4TC-0001Ti-48 for submit@debbugs.gnu.org; Sun, 31 Dec 2023 17:39:46 -0500 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]:43689) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rK4T9-0001TT-Lb for 68185@debbugs.gnu.org; Sun, 31 Dec 2023 17:39:44 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 149DC40002 for <68185@debbugs.gnu.org>; Sun, 31 Dec 2023 22:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1704062374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=XdP32K+nfbuafaLuGI6IhG9t7MQUPihjhzio3nsOvpA=; b=nH9NZHnqC/qik+AQe7dmup0dkZnnPNt5mWwc/B798/n41SiExn2/UK0S5SK7bh9Oy7i2f1 IOSMXmhsSb2+SjaoX4A+Bn0bh7cQAobaTpnw1e5aB7nLpIJUSbZ8KsLDEsTSYgO6o5Jszb DuRKGPTUJW3aecw+9jMI9VgWicvO+eFu23IjU/zpcj9imtEDcBbWK8pOCAgMHHodIL4HSP wU7XiX21NFvjw7Qct74aYDgCqo6UCik4hZYWY0k7+RMG/Ux8xXhq+yeITPCGW3RDobnTUQ TmxsrY1nyhclXQE7AFn78zumNnfXGkp/pSXm/sce6r5V58ZuJDq0oIgRZB8imw== From: Morgan Willcock Date: Sun, 31 Dec 2023 22:39:33 +0000 Message-ID: <87zfxq574q.fsf@ice9.digital> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: morgan@ice9.digital X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Apologies, I think the fix is too simplistic and does not account for the region being shifted. The existing implementation does account for that for also assumes that the region was selected in a forwards direction. Is it possible to convert this into a normal bug report rather than a patch request? From unknown Sun Jun 22 00:15:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68185: [PATCH] Ensure indent-region argument order is correct Resent-From: Morgan Willcock Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Jan 2024 17:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68185 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 68185@debbugs.gnu.org Received: via spool by 68185-submit@debbugs.gnu.org id=B68185.170412868316150 (code B ref 68185); Mon, 01 Jan 2024 17:05:01 +0000 Received: (at 68185) by debbugs.gnu.org; 1 Jan 2024 17:04:43 +0000 Received: from localhost ([127.0.0.1]:48674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rKLiV-0004CP-4c for submit@debbugs.gnu.org; Mon, 01 Jan 2024 12:04:43 -0500 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:38947) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rKLiS-0004C9-3O for 68185@debbugs.gnu.org; Mon, 01 Jan 2024 12:04:41 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 7DF93C0005 for <68185@debbugs.gnu.org>; Mon, 1 Jan 2024 17:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1704128671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vKWi07LHaJkpADwwyZ21KLll5RkUHajSNBKsIVniNx4=; b=RJwXxzj2Uxcyo1ZHfsIt9YDeV33hfHKVarbpCschoEZnqhCBn1Py4mDg8ypn+C6rUSRXGV nlaW/OmFje0MCuabqz5dStdwYbjH29/Xu+GvljpTcBAdlguYiEdG/EWYbAXTu8yKW3Zz56 qXcBdx9N+vQEAh+MLleWrAimSAoJ0WtPDJYU6bPEu4miBGQHdywuqdOH4r6yUZ/EPWqXlH EY7bUq8vVbpqffB8B4lPAHIFj7SFu1fAG2yoe+QDT0TmFeD4bxF55vILZgQqrNYuILKlzM Ur2kjghIiLQW+P85m1aKpd7UgQdUyqhFfhgyG6Vftc6689ePYLa4zfKnrHp2fw== From: Morgan Willcock In-Reply-To: <87zfxq574q.fsf@ice9.digital> (Morgan Willcock's message of "Sun, 31 Dec 2023 22:39:33 +0000") References: <87zfxq574q.fsf@ice9.digital> Date: Mon, 01 Jan 2024 17:04:30 +0000 Message-ID: <87wmstnfxd.fsf@ice9.digital> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: morgan@ice9.digital X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Attached is a replacement patch which I believe fixes the issue with the region selection direction and with indentation potentially being incorrectly applied to text that is inserted by the template. Previously when text was being inserted at the region start it was actually going into region, which means that it will have been possible for template contents to have accidentally been indented along with the region that the user selected. I've changed the marker insertion type for the start boundary, which should preserve the original indentation of text which was inserted by the template, i.e. if text inserted by the template should be indented this is now back under control of the template rather than applied by accident. The changes do mean that the indentation of existing templates may change, but I think this will only be for templates which accidentally omitted the indentation directives because indentation was mistakenly applied as part of the region. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Ensure-indent-region-arguments-and-boundaries-are-co.patch >From e667cd5abbdc7788726ec0da29b95b24a44a7923 Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Sun, 31 Dec 2023 20:47:17 +0000 Subject: [PATCH] Ensure indent-region arguments and boundaries are correct * lisp/tempo.el: Set marker type for tempo-region-start to move when text is inserted at its position. This prevents the template from inserting text into the region. * lisp/tempo.el (tempo-insert): Call indent-region with the stored region markers to ensure that the start and end arguments are used in the correct order. --- lisp/tempo.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/tempo.el b/lisp/tempo.el index 45dc24dcc97..56f8a8389a2 100644 --- a/lisp/tempo.el +++ b/lisp/tempo.el @@ -197,6 +197,9 @@ tempo-named-insertions (defvar-local tempo-region-start (make-marker) "Region start when inserting around the region.") +;; Insertion by the template at the region start position should move +;; the marker to preserve the original region contents. +(set-marker-insertion-type tempo-region-start t) (defvar-local tempo-region-stop (make-marker) "Region stop when inserting around the region.") @@ -333,7 +336,8 @@ tempo-insert (`(r> . ,rest) (if on-region (progn (goto-char tempo-region-stop) - (indent-region (mark) (point) nil)) + (indent-region tempo-region-start + tempo-region-stop)) (tempo-insert-prompt-compat rest))) (`(s ,name) (tempo-insert-named name)) (`(l . ,rest) (dolist (elt rest) (tempo-insert elt on-region))) @@ -344,7 +348,7 @@ tempo-insert ('r> (if on-region (progn (goto-char tempo-region-stop) - (indent-region (mark) (point) nil)) + (indent-region tempo-region-start tempo-region-stop)) (tempo-insert-mark (point-marker)))) ('> (indent-according-to-mode)) ('& (if (not (or (= (current-column) 0) -- 2.39.2 --=-=-=-- From unknown Sun Jun 22 00:15:16 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Morgan Willcock Subject: bug#68185: closed (Re: bug#68185: [PATCH] Ensure indent-region argument order is correct) Message-ID: References: <83zfxlwdmv.fsf@gnu.org> <874jfy6pdg.fsf@ice9.digital> X-Gnu-PR-Message: they-closed 68185 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 68185@debbugs.gnu.org Date: Thu, 04 Jan 2024 11:19:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1704367142-24478-1" This is a multi-part message in MIME format... ------------=_1704367142-24478-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #68185: [PATCH] Ensure indent-region argument order is correct which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 68185@debbugs.gnu.org. --=20 68185: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D68185 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1704367142-24478-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 68185-done) by debbugs.gnu.org; 4 Jan 2024 11:18:43 +0000 Received: from localhost ([127.0.0.1]:53714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLLkI-0006MC-QI for submit@debbugs.gnu.org; Thu, 04 Jan 2024 06:18:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53232) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLLkH-0006Lw-8W for 68185-done@debbugs.gnu.org; Thu, 04 Jan 2024 06:18:41 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rLLk6-0000Ji-PM; Thu, 04 Jan 2024 06:18:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=s0+OaqW1tRnSey3BGXhQ2yg5HgHo089EepeXqq9amJw=; b=XrRjym7RnBcf viTVy1qjpkWb5UR4x3990XUV90mzw1T8Ay5dHzhmBNMMk7lCmekp8WuycRZ6rUDSbRIQ00zthrcK9 NblYIgDNuBYksptYDuM5EdUNWE8oTQ2vAN+rCxzI4EXJ0G4csN3Yx3NOvoYZCsn0c9cRixEovcsQC UNAOERhYVr85CwCl2eUn1WeClGtSOLHqppUjMh+HNOv4RQny8eTnml42Mw4grkgZ8teRHD4dH/kI0 bzRhSY+67AzRtIemih8itNrUIvtYBnVFAj9E1GygmPKG1rqq00jEABGENn+R3CT5zfakhpwIMKhC2 ce2KAqqq793r2SF25ea8Gg==; Date: Thu, 04 Jan 2024 13:18:16 +0200 Message-Id: <83zfxlwdmv.fsf@gnu.org> From: Eli Zaretskii To: Morgan Willcock In-Reply-To: <874jfy6pdg.fsf@ice9.digital> (message from Morgan Willcock on Sun, 31 Dec 2023 21:20:11 +0000) Subject: Re: bug#68185: [PATCH] Ensure indent-region argument order is correct References: <874jfy6pdg.fsf@ice9.digital> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 68185-done Cc: 68185-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Morgan Willcock > Date: Sun, 31 Dec 2023 21:20:11 +0000 > > The attached patch fixes an issue with Tempo template insertion, where > the region start is assumed to be a position before the region end. If > the user selects a region in a backwards direction the correct > indentation will not be applied: Thanks, installed on the master branch, and closing the bug. ------------=_1704367142-24478-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 31 Dec 2023 21:20:45 +0000 Received: from localhost ([127.0.0.1]:47124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rK3Ej-0003Sc-8k for submit@debbugs.gnu.org; Sun, 31 Dec 2023 16:20:45 -0500 Received: from lists.gnu.org ([2001:470:142::17]:43404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rK3Eg-0003SJ-Up for submit@debbugs.gnu.org; Sun, 31 Dec 2023 16:20:43 -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 1rK3EW-00015S-JJ for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2023 16:20:32 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rK3EK-0001PF-4N for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2023 16:20:32 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id B85F0FF805 for ; Sun, 31 Dec 2023 21:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1704057613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=m5yn/nAMptIS0Y6fvyUyj0WM5nYA2vw3DytoIXjCYJU=; b=Up7J0ttMSHUxHK/6+dAFm01BANCvicYjkG6jQ6dGmgQbMXQXgLtvdd7fL6Drgiw0f0YXZ0 95iPBOmPt46woGIpA2+IOIZ+lv7cDHUH14QhrH2QONetOZ6eWA+rg8hlk1MPLlugJLW0mg aT28IVhOJ9L922jb7jvuU+KFXkgpc7I6KE1z4o2WTOyNiHGTwvCA9XvaQQDT+ef7zZz1eW BXW2W/Qei2u1vi7b3NJRDqEBW03VPqYcaWNy6jJv6EG+3z475+s6ZSKacj4NY4GjBFA4hW v033FBCQzYW9QGlkvuMq5ry4N0ULwiiBsa+9Pl0+syPCvUTwU0jJKMlJK6R0Bg== From: Morgan Willcock To: bug-gnu-emacs@gnu.org Subject: [PATCH] Ensure indent-region argument order is correct Date: Sun, 31 Dec 2023 21:20:11 +0000 Message-ID: <874jfy6pdg.fsf@ice9.digital> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: morgan@ice9.digital Received-SPF: pass client-ip=217.70.183.199; envelope-from=morgan@ice9.digital; helo=relay9-d.mail.gandi.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) --=-=-= Content-Type: text/plain Tags: patch The attached patch fixes an issue with Tempo template insertion, where the region start is assumed to be a position before the region end. If the user selects a region in a backwards direction the correct indentation will not be applied: (require 'tempo) (tempo-define-template "indent-region-test" '(r>)) (with-temp-buffer (emacs-lisp-mode) (insert " one\n two\n three") (goto-char (point-min)) (set-mark-command nil) (goto-char (point-max)) (tempo-template-indent-region-test) (buffer-string)) ;; => "one\ntwo\nthree" (with-temp-buffer (emacs-lisp-mode) (insert " one\n two\n three") (goto-char (point-max)) (set-mark-command nil) (goto-char (point-min)) (tempo-template-indent-region-test) (buffer-string)) ;; => " one\n two\nthree" The start and end positions are already identified and stored using separate variables, so the patch just uses these values instead of assuming the point and mark order. I've also removed passing nil as the third argument since the argument is optional. In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2023-07-31 built on inspiron Windowing system distributor 'The X.Org Foundation', version 11.0.12101007 System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure --with-native-compilation --with-cairo --with-json --with-xml2 --with-x-toolkit=lucid' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Ensure-indent-region-argument-order-is-correct.patch >From 4d7fdafeee5f6540d5e39549fa0a9927176171bb Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Sun, 31 Dec 2023 20:47:17 +0000 Subject: [PATCH] Ensure indent-region argument order is correct * lisp/tempo.el (tempo-insert): Call indent-region with the stored region markers to ensure that the start and end arguments are used in the correct order. --- lisp/tempo.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/tempo.el b/lisp/tempo.el index 45dc24dcc97..1b6cc4476e1 100644 --- a/lisp/tempo.el +++ b/lisp/tempo.el @@ -333,7 +333,8 @@ tempo-insert (`(r> . ,rest) (if on-region (progn (goto-char tempo-region-stop) - (indent-region (mark) (point) nil)) + (indent-region tempo-region-start + tempo-region-stop)) (tempo-insert-prompt-compat rest))) (`(s ,name) (tempo-insert-named name)) (`(l . ,rest) (dolist (elt rest) (tempo-insert elt on-region))) @@ -344,7 +345,7 @@ tempo-insert ('r> (if on-region (progn (goto-char tempo-region-stop) - (indent-region (mark) (point) nil)) + (indent-region tempo-region-start tempo-region-stop)) (tempo-insert-mark (point-marker)))) ('> (indent-according-to-mode)) ('& (if (not (or (= (current-column) 0) -- 2.39.2 --=-=-=-- ------------=_1704367142-24478-1-- From unknown Sun Jun 22 00:15:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68185: [PATCH] Ensure indent-region argument order is correct Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jan 2024 11:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68185 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Morgan Willcock Cc: 68185@debbugs.gnu.org Received: via spool by 68185-submit@debbugs.gnu.org id=B68185.170436740725044 (code B ref 68185); Thu, 04 Jan 2024 11:24:01 +0000 Received: (at 68185) by debbugs.gnu.org; 4 Jan 2024 11:23:27 +0000 Received: from localhost ([127.0.0.1]:53721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLLos-0006Vr-H7 for submit@debbugs.gnu.org; Thu, 04 Jan 2024 06:23:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50146) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLLop-0006VY-S5 for 68185@debbugs.gnu.org; Thu, 04 Jan 2024 06:23:24 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rLLog-000147-I3; Thu, 04 Jan 2024 06:23:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ZfTXDK8G50JjA/RQobXPZSj/47zQ6UzCf+rHn9i7ons=; b=CEN76iGuZpNL kEhZ4C3Qm7gfpnutnr1jHOn5BiVsi+tRO+FYk5fJhciwX00pUEgJRgR048on4bDXVV+ScfjuyI2oc S5V+lw6uEZ0GvmwWLHE21CkTa/xgCUUJZBu0A4TnwRzhuI05bzRJt+hT+nD7d7bljcayTxKTsicc4 gzJ75q8D+oleO6fjrX5rR9qW5f+qGC0U+Z2ME6xtMgAc559T785l+7/wsNFLMfRTOilZBBBXJjf2E R2jcjeogCDwS2seJ68TsiTdxCnAv1tKOUN+f5HCY3p5FYXVUBKXF+T+rL7mkNTvJs5r8lbt6Hg+HN IGhivvXycG0489dZZZXorw==; Date: Thu, 04 Jan 2024 13:22:56 +0200 Message-Id: <83y1d5wdf3.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87wmstnfxd.fsf@ice9.digital> (message from Morgan Willcock on Mon, 01 Jan 2024 17:04:30 +0000) References: <87zfxq574q.fsf@ice9.digital> <87wmstnfxd.fsf@ice9.digital> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Morgan Willcock > Date: Mon, 01 Jan 2024 17:04:30 +0000 > > Attached is a replacement patch which I believe fixes the issue with the > region selection direction and with indentation potentially being > incorrectly applied to text that is inserted by the template. > > Previously when text was being inserted at the region start it was > actually going into region, which means that it will have been possible > for template contents to have accidentally been indented along with the > region that the user selected. I've changed the marker insertion type > for the start boundary, which should preserve the original indentation > of text which was inserted by the template, i.e. if text inserted by the > template should be indented this is now back under control of the > template rather than applied by accident. > > The changes do mean that the indentation of existing templates may > change, but I think this will only be for templates which accidentally > omitted the indentation directives because indentation was mistakenly > applied as part of the region. Thanks, installed (the additional part which wasn't in the previous patch).