* bug#41934: reverse-region no longer works
@ 2020-06-18 16:41 Richard Copley
2020-06-18 17:42 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Richard Copley @ 2020-06-18 16:41 UTC (permalink / raw)
To: 41934
Recipe:
Insert text in a buffer:
abc
def
ghi
Position the mark before the 'a' and point before the 'g'.
Do 'M-x reverse-region'.
An error is signalled, 'There are no full lines in the region'.
See #39376.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#41934: reverse-region no longer works
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
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2020-06-18 17:42 UTC (permalink / raw)
To: Richard Copley; +Cc: 41934
> From: Richard Copley <rcopley@gmail.com>
> Date: Thu, 18 Jun 2020 17:41:19 +0100
>
> Insert text in a buffer:
>
> abc
> def
> ghi
>
> Position the mark before the 'a' and point before the 'g'.
> Do 'M-x reverse-region'.
>
> An error is signalled, 'There are no full lines in the region'.
Thanks. Does the patch below look good?
diff --git a/lisp/sort.el b/lisp/sort.el
index de0e1b9..6640c8f 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -554,8 +554,8 @@ 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)))
+ (when (< (- end beg)
+ (- (line-end-position) (line-beginning-position)))
(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.
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#41934: reverse-region no longer works
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:20 ` Eli Zaretskii
0 siblings, 2 replies; 11+ messages in thread
From: Richard Copley @ 2020-06-18 17:52 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 41934
On Thu, 18 Jun 2020 at 18:42, Eli Zaretskii <eliz@gnu.org> wrote:
> diff --git a/lisp/sort.el b/lisp/sort.el
> index de0e1b9..6640c8f 100644
> --- a/lisp/sort.el
> +++ b/lisp/sort.el
> @@ -554,8 +554,8 @@ 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)))
> + (when (< (- end beg)
> + (- (line-end-position) (line-beginning-position)))
> (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.
Thanks,
No, that fails on this example:
[mark]abc
def
[point]abcdefghi
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#41934: reverse-region no longer works
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:20 ` Eli Zaretskii
1 sibling, 1 reply; 11+ messages in thread
From: Richard Copley @ 2020-06-18 17:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 41934
On Thu, 18 Jun 2020 at 18:52, Richard Copley <rcopley@gmail.com> wrote:
> On Thu, 18 Jun 2020 at 18:42, Eli Zaretskii <eliz@gnu.org> wrote:
> Thanks,
> No, that fails on this example [...]
How's this?
diff --git a/lisp/sort.el b/lisp/sort.el
index de0e1b9519..f878db24a3 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -554,9 +554,6 @@ is the one that ends before END."
(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"))
;; 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)
@@ -568,6 +565,8 @@ is the one that ends before END."
;; reversal; it isn't difficult to add it afterward.
(or (and (eolp) (not (bolp))) (progn (forward-line -1) (end-of-line)))
(setq end (point-marker))
+ (when (<= end beg)
+ (user-error "There are no full lines in the region"))
;; The real work. This thing cranks through memory on large regions.
(let (ll (do t))
(while do
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#41934: reverse-region no longer works
2020-06-18 17:59 ` Richard Copley
@ 2020-06-18 18:28 ` Eli Zaretskii
2020-06-18 18:33 ` Richard Copley
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2020-06-18 18:28 UTC (permalink / raw)
To: Richard Copley; +Cc: 41934
> From: Richard Copley <rcopley@gmail.com>
> Date: Thu, 18 Jun 2020 18:59:21 +0100
> Cc: 41934@debbugs.gnu.org
>
> On Thu, 18 Jun 2020 at 18:52, Richard Copley <rcopley@gmail.com> wrote:
> > On Thu, 18 Jun 2020 at 18:42, Eli Zaretskii <eliz@gnu.org> wrote:
> > Thanks,
> > No, that fails on this example [...]
>
> How's this?
Looks good, but what if beg and end are on the same line (at the point
where you added the test)? Does that not warrant the error message?
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#41934: reverse-region no longer works
2020-06-18 18:28 ` Eli Zaretskii
@ 2020-06-18 18:33 ` Richard Copley
2020-06-18 18:44 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Richard Copley @ 2020-06-18 18:33 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 41934
On Thu, 18 Jun 2020 at 19:28, Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Richard Copley <rcopley@gmail.com>
> > Date: Thu, 18 Jun 2020 18:59:21 +0100
> > Cc: 41934@debbugs.gnu.org
> >
> > On Thu, 18 Jun 2020 at 18:52, Richard Copley <rcopley@gmail.com> wrote:
> > > On Thu, 18 Jun 2020 at 18:42, Eli Zaretskii <eliz@gnu.org> wrote:
> > > Thanks,
> > > No, that fails on this example [...]
> >
> > How's this?
>
> Looks good, but what if beg and end are on the same line (at the point
> where you added the test)? Does that not warrant the error message?
Not that error message, no, but rather something like "There are fewer
than two lines in the region".
I don't see the point of this error at all: if there are fewer than
two lines in the region-to-be-reversed at that point, in my opinion
the command should have no effect.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#41934: reverse-region no longer works
2020-06-18 18:33 ` Richard Copley
@ 2020-06-18 18:44 ` Eli Zaretskii
[not found] ` <CAPM58oijG1t__9DtYyBPjA+EPHYA7hDFizz9oXv=hqVAyFEPiw@mail.gmail.com>
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2020-06-18 18:44 UTC (permalink / raw)
To: Richard Copley; +Cc: 41934
> From: Richard Copley <rcopley@gmail.com>
> Date: Thu, 18 Jun 2020 19:33:57 +0100
> Cc: 41934@debbugs.gnu.org
>
> > Looks good, but what if beg and end are on the same line (at the point
> > where you added the test)? Does that not warrant the error message?
>
> Not that error message, no, but rather something like "There are fewer
> than two lines in the region".
The original message says "lines", plural, so I think it kinda hints
on that. We could make it say something that will cover both cases.
> I don't see the point of this error at all: if there are fewer than
> two lines in the region-to-be-reversed at that point, in my opinion
> the command should have no effect.
Indeed, it doesn't have any effect. I'm asking whether this should be
flagged, since doing that makes no sense.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#41934: reverse-region no longer works
2020-06-18 17:52 ` Richard Copley
2020-06-18 17:59 ` Richard Copley
@ 2020-06-18 18:20 ` Eli Zaretskii
1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2020-06-18 18:20 UTC (permalink / raw)
To: Richard Copley; +Cc: 41934
> 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)
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-06-22 15:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.