From unknown Fri Jun 13 16:53:32 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#39376 <39376@debbugs.gnu.org> To: bug#39376 <39376@debbugs.gnu.org> Subject: Status: [PATCH] Throw error when calling reverse-region on a single line Reply-To: bug#39376 <39376@debbugs.gnu.org> Date: Fri, 13 Jun 2025 23:53:32 +0000 retitle 39376 [PATCH] Throw error when calling reverse-region on a single l= ine reassign 39376 emacs submitter 39376 Philip K severity 39376 normal tag 39376 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 31 16:26:34 2020 Received: (at submit) by debbugs.gnu.org; 31 Jan 2020 21:26:34 +0000 Received: from localhost ([127.0.0.1]:38170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ixdoA-00062a-C4 for submit@debbugs.gnu.org; Fri, 31 Jan 2020 16:26:34 -0500 Received: from lists.gnu.org ([209.51.188.17]:35315) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ixdo8-00062S-Sl for submit@debbugs.gnu.org; Fri, 31 Jan 2020 16:26:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37263) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixdo7-0008F4-NW for bug-gnu-emacs@gnu.org; Fri, 31 Jan 2020 16:26:32 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_40,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,SPOOFED_FREEMAIL,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixdo6-0006T6-O1 for bug-gnu-emacs@gnu.org; Fri, 31 Jan 2020 16:26:31 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:54623) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixdo6-0006Ri-Fp for bug-gnu-emacs@gnu.org; Fri, 31 Jan 2020 16:26:30 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id CCB1F22458 for ; Fri, 31 Jan 2020 16:26:28 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Fri, 31 Jan 2020 16:26:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=warpmail.net; h= from:to:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=u7zBrl1BIHyjGW8g67tBrB6jB+ phlkiu5ITrktSjsrw=; b=drnv2VyJiiP9doqhwWU76Qn1m5tYXpLR11ShbHvLQh 3oxZKa2UYMeR7bDGqENHTWapKfG0AmwLL6+GB3l6sJcSkvBE0y5l0Dk8H2NRho55 2sn3jY1kZCUIrpuuoz1FRMKWW9W4zMt86g7KeX4HQJ4BP/yjktKfnaTp+Y5LQqp1 8iBooG8BnuNwZ7aMj7wSTJuM0A5wx+yr6Q91Nziibb5xF3eTJNMYhELgXoKGzlpm tDLSRZ61JLLO3qtKNxtwnhrlyv7/GUvP8h9gPUN/6Crz4yOt653wMRHrG0uI5DA4 tnqlGJ5i17jsgg1eCrM5nXI3I5oePh6j9oLP3NNbkB3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=u7zBrl1BIHyjGW8g6 7tBrB6jB+phlkiu5ITrktSjsrw=; b=rX5h2hvVpwdX5y/WfNxSjJ3VwXW6jgEfW 2gyggBVG1JN8qpQEaamz6s7F8w6F4YIOI/oahXmnlbV7lDx4W0XPxlD0pL8y0m37 uV0+Unz7IyWQCnIpk6QrYRgQDy1rZ7QhzQGIFB2BNkXPlLZMh52vThB22zkPwc4x oKr0HVtCYOLExDMacbkezP0PLIADkYfFaAqgVPo5BvjbXCRhOeQJzAD8TWNKuOpk 71+nhCW2Bq8RxaXZ0MuNGAeZ8qQN9uT9JCsJybmLulQZ1eInDFqhSVIEIN1b7yqS kmFl63Lh9M485poFK9TWPoHI3Gf4mE/gpU6rzKlZSL9dPy0eML7ZA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrgedtgddugedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfhhihhlihhpucfmuceophhhihhlihhpseifrghrphhmrghilhdr nhgvtheqnecukfhppeejledrvdduledrudelhedrvdeinecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepphhhihhlihhpseifrghrphhmrghilhdr nhgvth X-ME-Proxy: Received: from localhost (p4fdbc31a.dip0.t-ipconnect.de [79.219.195.26]) by mail.messagingengine.com (Postfix) with ESMTPA id DE6EB3280060 for ; Fri, 31 Jan 2020 16:26:27 -0500 (EST) From: Philip K To: bug-gnu-emacs@gnu.org Subject: [PATCH] Throw error when calling reverse-region on a single line Date: Fri, 31 Jan 2020 22:26:24 +0100 Message-Id: <20200131212624.4658-1-philip@warpmail.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.26 X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The current implementation of reverse region will delete everything following the current line, if the region marks only a part of a line. This is because the algorithm implemented below accidentally [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: messagingengine.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (philip[at]warpmail.net) 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [209.51.188.17 listed in list.dnswl.org] 2.0 SPOOFED_FREEMAIL No description available. 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: -1.0 (-) The current implementation of reverse region will delete everything following the current line, if the region marks only a part of a line. This is because the algorithm implemented below accidentally deletes all following lines, and fails before being able to reinsert them. This patch sends an error (could be changed to an user-error) in that case, as it makes no sense for a single line to be reversed. --- lisp/sort.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/sort.el b/lisp/sort.el index 6ea1c44060..8848c5bf24 100644 --- a/lisp/sort.el +++ b/lisp/sort.el @@ -543,6 +543,8 @@ reverse-region (if (> beg end) (let (mid) (setq mid end end beg beg mid))) (save-excursion + (when (< (line-beginning-position) beg end (line-end-position)) + (error "Cannot reverse a single line")) ;; put beg at the start of a line and end and the end of one -- ;; the largest possible region which fits this criteria (goto-char beg) -- 2.20.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 15 03:51:58 2020 Received: (at 39376-done) by debbugs.gnu.org; 15 Feb 2020 08:51:58 +0000 Received: from localhost ([127.0.0.1]:35012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2tB8-0000dw-IS for submit@debbugs.gnu.org; Sat, 15 Feb 2020 03:51:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49307) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2tB5-0000di-Lm for 39376-done@debbugs.gnu.org; Sat, 15 Feb 2020 03:51:56 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j2tAz-0007sJ-2Z; Sat, 15 Feb 2020 03:51:49 -0500 Received: from [176.228.60.248] (port=2966 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1j2tAy-0001Hv-Hs; Sat, 15 Feb 2020 03:51:48 -0500 Date: Sat, 15 Feb 2020 10:51:54 +0200 Message-Id: <838sl4nsgl.fsf@gnu.org> From: Eli Zaretskii To: Philip K In-reply-to: <20200131212624.4658-1-philip@warpmail.net> (message from Philip K on Fri, 31 Jan 2020 22:26:24 +0100) Subject: Re: bug#39376: [PATCH] Throw error when calling reverse-region on a single line References: <20200131212624.4658-1-philip@warpmail.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 39376-done Cc: 39376-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: -1.7 (-) > From: Philip K > Date: Fri, 31 Jan 2020 22:26:24 +0100 > > The current implementation of reverse region will delete everything > following the current line, if the region marks only a part of a > line. This is because the algorithm implemented below accidentally > deletes all following lines, and fails before being able to reinsert > them. > > This patch sends an error (could be changed to an user-error) in that > case, as it makes no sense for a single line to be reversed. Thanks. I installed a slightly different change, because the command would still delete the following lines if only BEG or END (bit not both) was not at a line beginning/end. I also fixed the doc string and the comments there. From unknown Fri Jun 13 16:53:32 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 14 Mar 2020 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator