From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Philip K Newsgroups: gmane.emacs.bugs Subject: bug#39376: [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> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="126186"; mail-complaints-to="usenet@ciao.gmane.io" To: 39376@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 31 22:27:11 2020 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 1ixdol-000Wmu-0f for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Jan 2020 22:27:11 +0100 Original-Received: from localhost ([::1]:59808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixdok-0008LT-30 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Jan 2020 16:27:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37466) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixdoc-0008Iy-VC for bug-gnu-emacs@gnu.org; Fri, 31 Jan 2020 16:27:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixdoc-0006oL-2i for bug-gnu-emacs@gnu.org; Fri, 31 Jan 2020 16:27:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60430) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixdob-0006oA-Vw for bug-gnu-emacs@gnu.org; Fri, 31 Jan 2020 16:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ixdob-00063L-Rm for bug-gnu-emacs@gnu.org; Fri, 31 Jan 2020 16:27:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philip K Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Jan 2020 21:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39376 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.158050599423228 (code B ref -1); Fri, 31 Jan 2020 21:27:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Jan 2020 21:26:34 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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) Original-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: Original-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) X-Mailer: git-send-email 2.20.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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" Xref: news.gmane.io gmane.emacs.bugs:175530 Archived-At: 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