From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Morgan Willcock Newsgroups: gmane.emacs.bugs Subject: bug#68185: [PATCH] Ensure indent-region argument order is correct Date: Mon, 01 Jan 2024 17:04:30 +0000 Message-ID: <87wmstnfxd.fsf@ice9.digital> References: <87zfxq574q.fsf@ice9.digital> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8763"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 68185@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 01 18:05:24 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rKLjA-000226-0W for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Jan 2024 18:05:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKLip-0003Al-HH; Mon, 01 Jan 2024 12:05:03 -0500 Original-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 1rKLim-00039f-Nq for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2024 12:05:01 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKLim-0007oY-Cy for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2024 12:05:00 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rKLin-0004D0-Ve for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2024 12:05:01 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 68185-submit@debbugs.gnu.org id=B68185.170412868316150 (code B ref 68185); Mon, 01 Jan 2024 17:05:01 +0000 Original-Received: (at 68185) by debbugs.gnu.org; 1 Jan 2024 17:04:43 +0000 Original-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 Original-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 Original-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== In-Reply-To: <87zfxq574q.fsf@ice9.digital> (Morgan Willcock's message of "Sun, 31 Dec 2023 22:39:33 +0000") X-GND-Sasl: morgan@ice9.digital X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277182 Archived-At: --=-=-= 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 --=-=-=--