From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#41934: reverse-region no longer works Date: Thu, 18 Jun 2020 21:20:26 +0300 Message-ID: <83imfoz15h.fsf@gnu.org> References: <83lfkkz2wr.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="119358"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41934@debbugs.gnu.org To: Richard Copley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 18 20:21:21 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 1jlzA9-000Uv7-5H for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Jun 2020 20:21:21 +0200 Original-Received: from localhost ([::1]:46494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlzA8-0004tY-7Y for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Jun 2020 14:21:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlz9q-0004tD-TW for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 14:21:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlz9q-0007Rl-Kr for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 14:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jlz9q-00079O-HC for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 14:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Jun 2020 18:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41934 X-GNU-PR-Package: emacs Original-Received: via spool by 41934-submit@debbugs.gnu.org id=B41934.159250444827447 (code B ref 41934); Thu, 18 Jun 2020 18:21:02 +0000 Original-Received: (at 41934) by debbugs.gnu.org; 18 Jun 2020 18:20:48 +0000 Original-Received: from localhost ([127.0.0.1]:54385 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlz9c-00078c-MC for submit@debbugs.gnu.org; Thu, 18 Jun 2020 14:20:48 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlz9Z-00078O-VO for 41934@debbugs.gnu.org; Thu, 18 Jun 2020 14:20:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:45567) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlz9U-0007Ke-FK; Thu, 18 Jun 2020 14:20:40 -0400 Original-Received: from [176.228.60.248] (port=4387 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jlz9T-0001h7-Sh; Thu, 18 Jun 2020 14:20:40 -0400 In-Reply-To: (message from Richard Copley on Thu, 18 Jun 2020 18:52:48 +0100) 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" Xref: news.gmane.io gmane.emacs.bugs:182135 Archived-At: > From: Richard Copley > Date: Thu, 18 Jun 2020 18:52:48 +0100 > Cc: 41934@debbugs.gnu.org > > No, that fails on this example: > > [mark]abc > def > [point]abcdefghi How about this: diff --git a/lisp/sort.el b/lisp/sort.el index de0e1b9..8a4a56c 100644 --- a/lisp/sort.el +++ b/lisp/sort.el @@ -554,9 +554,18 @@ reverse-region (if (> beg end) (let (mid) (setq mid end end beg beg mid))) (save-excursion - (when (or (< (line-beginning-position) beg) - (< end (line-end-position))) - (user-error "There are no full lines in the region")) + (let ((lbeg (save-excursion + (goto-char beg) + (if (bolp) + beg + (line-beginning-position 2)))) + (lend (save-excursion + (goto-char end) + (if (bolp) + end + (line-beginning-position))))) + (when (>= lbeg lend) + (user-error "There are no full lines in the region"))) ;; 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)