unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Richard Copley <rcopley@gmail.com>
Cc: 41934@debbugs.gnu.org
Subject: bug#41934: reverse-region no longer works
Date: Thu, 18 Jun 2020 21:20:26 +0300	[thread overview]
Message-ID: <83imfoz15h.fsf@gnu.org> (raw)
In-Reply-To: <CAPM58oi==RcRJGdvOA34bW2R5MDz7=GHFtcYe9=8cHYRWUfBuA@mail.gmail.com> (message from Richard Copley on Thu, 18 Jun 2020 18:52:48 +0100)

> From: Richard Copley <rcopley@gmail.com>
> 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)





      parent reply	other threads:[~2020-06-18 18:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 16:41 bug#41934: reverse-region no longer works Richard Copley
2020-06-18 17:42 ` Eli Zaretskii
2020-06-18 17:52   ` Richard Copley
2020-06-18 17:59     ` Richard Copley
2020-06-18 18:28       ` Eli Zaretskii
2020-06-18 18:33         ` Richard Copley
2020-06-18 18:44           ` Eli Zaretskii
     [not found]             ` <CAPM58oijG1t__9DtYyBPjA+EPHYA7hDFizz9oXv=hqVAyFEPiw@mail.gmail.com>
2020-06-19 11:31               ` Eli Zaretskii
2020-06-20 10:03                 ` Richard Copley
2020-06-22 15:43                   ` Eli Zaretskii
2020-06-18 18:20     ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83imfoz15h.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=41934@debbugs.gnu.org \
    --cc=rcopley@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).