GNU bug report logs -
#13521
`sort-lines' on the empty region
Previous Next
Reported by: Xue Fuqiao <xfq.free <at> gmail.com>
Date: Tue, 22 Jan 2013 00:56:01 UTC
Severity: wishlist
Tags: patch, wontfix
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13521 in the body.
You can then email your comments to 13521 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Tue, 22 Jan 2013 00:56:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Xue Fuqiao <xfq.free <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 22 Jan 2013 00:56:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
The current behavior of `sort-lines' on the empty region is to do
nothing. I often find that I want to sort whole buffers at the time,
and I expect `sort-lines' to do just that, before remembering I have
to mark the whole buffer first.
Wouldn't it be convenient to change the behavior of `sort-lines' so
that it sorts the whole buffer if no region is marked? Or is this
inconsistent with how other region-operating functions works?
See:
http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00492.html
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Tue, 22 Jan 2013 03:21:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 13521 <at> debbugs.gnu.org (full text, mbox):
Please wait a week or so before reposting something from one Emacs list
on another, to allow time for people to reply.
Xue Fuqiao wrote:
> http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00492.html
See the very first reply, posted before this report.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Tue, 22 Jan 2013 03:46:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 13521 <at> debbugs.gnu.org (full text, mbox):
On Mon, 21 Jan 2013 22:19:12 -0500
Glenn Morris <rgm <at> gnu.org> wrote:
> Please wait a week or so before reposting something from one Emacs list
> on another, to allow time for people to reply.
Thanks for your advice.
> Xue Fuqiao wrote:
>
> > http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00492.html
>
> See the very first reply, posted before this report.
I've seen this reply, but I'd like to report it as a wishlist.
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Tue, 22 Jan 2013 03:46:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 13521 <at> debbugs.gnu.org (full text, mbox):
On Mon, 21 Jan 2013 22:19:12 -0500
Glenn Morris <rgm <at> gnu.org> wrote:
> Please wait a week or so before reposting something from one Emacs list
> on another, to allow time for people to reply.
Thanks for your advice.
> Xue Fuqiao wrote:
>
> > http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00492.html
>
> See the very first reply, posted before this report.
I've seen this reply, but I'd like to report it as a wishlist.
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Tue, 22 Jan 2013 15:02:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> The current behavior of `sort-lines' on the empty region is to do
> nothing.
I think that's the right thing to do.
> I often find that I want to sort whole buffers at the time,
> and I expect `sort-lines' to do just that, before remembering I have
> to mark the whole buffer first.
That seems to be considering a different case: not the case of an empty
region, but the case where there's no active region.
Currently, this case signals an error, but I think I agree it makes
sense to let it apply to the whole buffer if there is no active region.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Tue, 22 Jan 2013 18:21:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 13521 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier wrote:
> That seems to be considering a different case: not the case of an empty
> region, but the case where there's no active region.
> Currently, this case signals an error, but I think I agree it makes
> sense to let it apply to the whole buffer if there is no active region.
flush-lines, keep-lines instead operate on all lines after point.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Tue, 22 Jan 2013 19:06:03 GMT)
Full text and
rfc822 format available.
Message #23 received at 13521 <at> debbugs.gnu.org (full text, mbox):
>> That seems to be considering a different case: not the case of an empty
>> region, but the case where there's no active region.
>> Currently, this case signals an error, but I think I agree it makes
>> sense to let it apply to the whole buffer if there is no active region.
> flush-lines, keep-lines instead operate on all lines after point.
Yes, we have an inconsistency in this respect: some commands use "the
whole buffer" and others use "everything after point". Whichever choice
we make for sort-lines, it will be inconsistent with some of the
existing commands ;-)
I personally prefer the "whole buffer", but whoever makes the change
gets to make the choice.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Fri, 21 Aug 2020 01:19:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 13521 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 13521 + patch
thanks
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
>>> That seems to be considering a different case: not the case of an empty
>>> region, but the case where there's no active region.
>>> Currently, this case signals an error, but I think I agree it makes
>>> sense to let it apply to the whole buffer if there is no active region.
>> flush-lines, keep-lines instead operate on all lines after point.
>
> Yes, we have an inconsistency in this respect: some commands use "the
> whole buffer" and others use "everything after point". Whichever choice
> we make for sort-lines, it will be inconsistent with some of the
> existing commands ;-)
>
> I personally prefer the "whole buffer", but whoever makes the change
> gets to make the choice.
The attached patch makes 'sort-lines' sort the entire buffer when there
is no region.
Any comments?
Best regards,
Stefan Kangas
[0001-Make-sort-lines-sort-entire-buffer-without-active-re.patch (text/x-diff, attachment)]
Added tag(s) patch.
Request was from
Stefan Kangas <stefan <at> marxist.se>
to
control <at> debbugs.gnu.org
.
(Fri, 21 Aug 2020 01:19:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Fri, 21 Aug 2020 06:23:01 GMT)
Full text and
rfc822 format available.
Message #31 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Thu, 20 Aug 2020 18:18:34 -0700
> Cc: Xue Fuqiao <xfq.free <at> gmail.com>, Glenn Morris <rgm <at> gnu.org>,
> 13521 <at> debbugs.gnu.org
>
> > I personally prefer the "whole buffer", but whoever makes the change
> > gets to make the choice.
>
> The attached patch makes 'sort-lines' sort the entire buffer when there
> is no region.
How frequently did you see a buffer in Emacs with no region in it?
IME, it takes about 2 commands since buffer creation to have a region
in it. So I predict users to be tripped by this feature quite a lot:
they will think there's no region, invoke the command, and get some
arbitrary region sorted. Requiring them to always provide the region
avoids this pitfall, since the user is forced to make sure the region
is where he or she wants it. And marking the whole buffer is just 2
key-presses away.
So I think this change will annoy more than help.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Fri, 21 Aug 2020 07:16:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 13521 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> The attached patch makes 'sort-lines' sort the entire buffer when there
>> is no region.
>
> How frequently did you see a buffer in Emacs with no region in it?
> IME, it takes about 2 commands since buffer creation to have a region
> in it. So I predict users to be tripped by this feature quite a lot:
> they will think there's no region, invoke the command, and get some
> arbitrary region sorted. Requiring them to always provide the region
> avoids this pitfall, since the user is forced to make sure the region
> is where he or she wants it. And marking the whole buffer is just 2
> key-presses away.
>
> So I think this change will annoy more than help.
Sorry, the correct terminology I should have used is "active region".
This is as tested by `use-region-p'. Compare the test I introduce also
to the one in `flush-lines', where I lifted it from.
Best regards,
Stefan Kangas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Fri, 21 Aug 2020 07:37:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Fri, 21 Aug 2020 00:15:31 -0700
> Cc: monnier <at> iro.umontreal.ca, xfq.free <at> gmail.com, rgm <at> gnu.org,
> 13521 <at> debbugs.gnu.org
>
> > How frequently did you see a buffer in Emacs with no region in it?
> > IME, it takes about 2 commands since buffer creation to have a region
> > in it. So I predict users to be tripped by this feature quite a lot:
> > they will think there's no region, invoke the command, and get some
> > arbitrary region sorted. Requiring them to always provide the region
> > avoids this pitfall, since the user is forced to make sure the region
> > is where he or she wants it. And marking the whole buffer is just 2
> > key-presses away.
> >
> > So I think this change will annoy more than help.
>
> Sorry, the correct terminology I should have used is "active region".
> This is as tested by `use-region-p'. Compare the test I introduce also
> to the one in `flush-lines', where I lifted it from.
So if the user has transient-mark-mode disabled (which is what I do),
the command will always sort the entire buffer? Or did I
misunderstand something?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 11:14:01 GMT)
Full text and
rfc822 format available.
Message #40 received at 13521 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> So if the user has transient-mark-mode disabled (which is what I do),
> the command will always sort the entire buffer? Or did I
> misunderstand something?
I didn't consider that case, but you are correct. The behavior would be
like that documented in `flush-lines':
Interactively, in Transient Mark mode when the mark is active, operate
on the contents of the region. Otherwise, operate from point to the
end of (the accessible portion of) the buffer.
I'm not sure the `flush-lines' behavior makes sense, though. It looks
like you can't run it on a region without transient-mark-mode. So maybe
we should fix that as well.
(Note that `flush-lines' operates from point to point-max, but
`sort-lines' is proposed here to operate on the entire buffer instead as
per previous discussion in this bug.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 11:30:02 GMT)
Full text and
rfc822 format available.
Message #43 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Sat, 5 Sep 2020 11:13:17 +0000
> Cc: xfq.free <at> gmail.com, rgm <at> gnu.org, monnier <at> iro.umontreal.ca,
> 13521 <at> debbugs.gnu.org
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > So if the user has transient-mark-mode disabled (which is what I do),
> > the command will always sort the entire buffer? Or did I
> > misunderstand something?
>
> I didn't consider that case, but you are correct. The behavior would be
> like that documented in `flush-lines':
>
> Interactively, in Transient Mark mode when the mark is active, operate
> on the contents of the region. Otherwise, operate from point to the
> end of (the accessible portion of) the buffer.
>
> I'm not sure the `flush-lines' behavior makes sense, though. It looks
> like you can't run it on a region without transient-mark-mode. So maybe
> we should fix that as well.
I think we should indeed fix flush-lines as well, yes.
> (Note that `flush-lines' operates from point to point-max, but
> `sort-lines' is proposed here to operate on the entire buffer instead as
> per previous discussion in this bug.)
I guess due to historical reasons?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 14:38:01 GMT)
Full text and
rfc822 format available.
Message #46 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> > > So if the user has transient-mark-mode disabled (which is what I do),
> > > the command will always sort the entire buffer? Or did I
> > > misunderstand something?
> >
> > I didn't consider that case, but you are correct. The behavior would be
> > like that documented in `flush-lines':
> >
> > Interactively, in Transient Mark mode when the mark is active, operate
> > on the contents of the region. Otherwise, operate from point to the
> > end of (the accessible portion of) the buffer.
> >
> > I'm not sure the `flush-lines' behavior makes sense, though. It looks
> > like you can't run it on a region without transient-mark-mode. So maybe
> > we should fix that as well.
>
> I think we should indeed fix flush-lines as well, yes.
>
> > (Note that `flush-lines' operates from point to point-max, but
> > `sort-lines' is proposed here to operate on the entire buffer instead as
> > per previous discussion in this bug.)
>
> I guess due to historical reasons?
Apologies for not following this thread and perhaps
misunderstanding at this point.
If `transient-mark-mode' is off then there is no notion
of an "active region". There is just the region.
I doubt that someone who has `transient-mark-mode' off
would ever want commands such as `flush-lines' and
`sort-lines' to act on the region. And if they did, I
expect they'd just narrow to it.
Anything that works on "the active region" is something
that makes sense only when `transient-mark-mode' is on
(IMHO).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 14:52:02 GMT)
Full text and
rfc822 format available.
Message #49 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> Date: Sat, 5 Sep 2020 07:36:55 -0700 (PDT)
> From: Drew Adams <drew.adams <at> oracle.com>
> Cc: xfq.free <at> gmail.com, rgm <at> gnu.org, monnier <at> iro.umontreal.ca,
> 13521 <at> debbugs.gnu.org
>
> I doubt that someone who has `transient-mark-mode' off
> would ever want commands such as `flush-lines' and
> `sort-lines' to act on the region. And if they did, I
> expect they'd just narrow to it.
Please don't doubt, and please don't impose unnecessary commands on
users who have transient-mark-mode off.
> Anything that works on "the active region" is something
> that makes sense only when `transient-mark-mode' is on
> (IMHO).
The important point here is that sort-lines worked on the region, even
if inactive, before the proposed changes, so restricting it now only
to active regions would be a backward-incompatible change of behavior.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 15:26:02 GMT)
Full text and
rfc822 format available.
Message #52 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> > I doubt that someone who has `transient-mark-mode' off
> > would ever want commands such as `flush-lines' and
> > `sort-lines' to act on the region. And if they did, I
> > expect they'd just narrow to it.
>
> Please don't doubt, and please don't impose unnecessary commands on
> users who have transient-mark-mode off.
Please don't claim that I imposed any commands on anyone.
The region is nearly always present and usually nonempty.
A user with `transient-mark-mode' off would typically
(IMHO) be bothered if `flush-lines' started always acting
on the region (it would be almost always: whenever there's
a mark in the buffer and the region is nonempty).
Do you disagree?
> > Anything that works on "the active region" is something
> > that makes sense only when `transient-mark-mode' is on
> > (IMHO).
>
> The important point here is that sort-lines worked on the region, even
> if inactive, before the proposed changes, so restricting it now only
> to active regions would be a backward-incompatible change of behavior.
Yes, sorry; I agree about `sort-lines'. That is not
the case for `flush-lines' and `keep-lines'.
And I think "the important point here" is that a command
that behaves differently when the region is active should
NOT act on the region when `transient-mark-mode' is off.
Why? Because the notion of "active region" applies only
when `transient-mark-mode' is on. Any special behavior
provided only when the region is active is, well, only
for when the region is active. And that's never the case
when `transient-mark-mode' is on.
This was not the case for `sort-lines', as you point out.
It did NOT, and does not, behave differently when the
region is active from when it is inactive.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 15:35:02 GMT)
Full text and
rfc822 format available.
Message #55 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> The important point here is that sort-lines worked on the region, even
> if inactive, before the proposed changes, so restricting it now only
> to active regions would be a backward-incompatible change of behavior.
Indeed, so the patch should check something like
(if (or (null transient-mark-mode) (use-region-p))
(list (region-beginning) (region-end))
(list (point-min) (point-max)))
`use-region-p` checks `transient-mark-mode` the other way, because it's
used mostly for commands which previously did *not* operate on the
region, unlike `sort-lines`.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 15:38:02 GMT)
Full text and
rfc822 format available.
Message #58 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> Date: Sat, 5 Sep 2020 08:22:58 -0700 (PDT)
> From: Drew Adams <drew.adams <at> oracle.com>
> Cc: stefan <at> marxist.se, xfq.free <at> gmail.com, rgm <at> gnu.org,
> monnier <at> iro.umontreal.ca, 13521 <at> debbugs.gnu.org
>
> > > I doubt that someone who has `transient-mark-mode' off
> > > would ever want commands such as `flush-lines' and
> > > `sort-lines' to act on the region. And if they did, I
> > > expect they'd just narrow to it.
> >
> > Please don't doubt, and please don't impose unnecessary commands on
> > users who have transient-mark-mode off.
>
> Please don't claim that I imposed any commands on anyone.
You expected them to narrow the buffer. That takes additional
commands.
> The region is nearly always present and usually nonempty.
> A user with `transient-mark-mode' off would typically
> (IMHO) be bothered if `flush-lines' started always acting
> on the region (it would be almost always: whenever there's
> a mark in the buffer and the region is nonempty).
So maybe flush-lines needs a separate solution, or none at all. This
bug is about sort-lines, so flush-lines is a tangent.
> And I think "the important point here" is that a command
> that behaves differently when the region is active should
> NOT act on the region when `transient-mark-mode' is off.
That's not really relevant here. We are talking about commands which
by virtue of their 'interactive' spec work on the region. Such
commands shouldn't depend on the region being active.
> This was not the case for `sort-lines', as you point out.
> It did NOT, and does not, behave differently when the
> region is active from when it is inactive.
The proposed change would have made it behave differently, which is
why I've pointed that out.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Sat, 05 Sep 2020 15:47:01 GMT)
Full text and
rfc822 format available.
Message #61 received at 13521 <at> debbugs.gnu.org (full text, mbox):
> > > > I doubt that someone who has `transient-mark-mode' off
> > > > would ever want commands such as `flush-lines' and
> > > > `sort-lines' to act on the region. And if they did, I
> > > > expect they'd just narrow to it.
> > >
> > > Please don't doubt, and please don't impose unnecessary commands on
> > > users who have transient-mark-mode off.
> >
> > Please don't claim that I imposed any commands on anyone.
>
> You expected them to narrow the buffer. That takes additional
> commands.
I do expect that, for `flush-lines', which is what I
was thinking of. You correctly pointed out that
`sort-lines' is different.
> > The region is nearly always present and usually nonempty.
> > A user with `transient-mark-mode' off would typically
> > (IMHO) be bothered if `flush-lines' started always acting
> > on the region (it would be almost always: whenever there's
> > a mark in the buffer and the region is nonempty).
>
> So maybe flush-lines needs a separate solution, or none at all. This
> bug is about sort-lines, so flush-lines is a tangent.
I didn't introduce `flush-lines' into the thread.
But yes, the subject line says `sort-lines', and
`flush-lines' is a very different case.
> > And I think "the important point here" is that a command
> > that behaves differently when the region is active should
> > NOT act on the region when `transient-mark-mode' is off.
>
> That's not really relevant here. We are talking about commands which
> by virtue of their 'interactive' spec work on the region. Such
> commands shouldn't depend on the region being active.
Yes, if this is only about commands like `sort-lines'.
Introducing `flush-lines' here was apparently a mistake,
which muddied the waters.
> > This was not the case for `sort-lines', as you point out.
> > It did NOT, and does not, behave differently when the
> > region is active from when it is inactive.
>
> The proposed change would have made it behave differently, which is
> why I've pointed that out.
Good. Agreed.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13521
; Package
emacs
.
(Mon, 10 May 2021 11:26:02 GMT)
Full text and
rfc822 format available.
Message #64 received at 13521 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> So I think this change will annoy more than help.
I agree -- I don't think we should change how `sort-lines' works here.
The current behaviour makes sense to me (and changing it sounds like it
might lead to people messing up their buffers), even if there are other
commands that do a DWIM-ish thing in this use case.
So I'm closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) wontfix.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 10 May 2021 11:26:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
13521 <at> debbugs.gnu.org and Xue Fuqiao <xfq.free <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 10 May 2021 11:26:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 08 Jun 2021 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 317 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.