GNU bug report logs -
#19896
23.1; reverse-region is slow compared to sort-columns
Previous Next
Reported by: asparagus <at> comcast.net
Date: Wed, 18 Feb 2015 17:59:02 UTC
Severity: minor
Found in version 23.1
Fixed in version 25.1
Done: Glenn Morris <rgm <at> gnu.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 19896 in the body.
You can then email your comments to 19896 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#19896
; Package
emacs
.
(Wed, 18 Feb 2015 17:59:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
asparagus <at> comcast.net
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 18 Feb 2015 17:59:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
The emacs manual recommends 'M-x reverse-region' as a companion to 'M-x sort-columns' to achieve a descending-order column sort. However, for large regions (>100k lines), 'M-x reverse-region' is noticeably slower than 'M-x sort-columns', making descending sort much slower than ascending sort.
A workaround on linux: use 'C-u M-x shell-command-on-region' with tac (the opposite of cat) instead of using 'M-x reverse-region'.
FROM THE MANUAL:
https://www.gnu.org/software/emacs/manual/html_node/emacs/Sorting.html
M-x reverse-region
Reverse the order of the lines in the region. This is useful for sorting into descending order by fields or columns, since those sort commands do not have a feature for doing that.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19896
; Package
emacs
.
(Wed, 18 Feb 2015 18:30:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 19896 <at> debbugs.gnu.org (full text, mbox):
>>>>> asparagus <asparagus <at> comcast.net> writes:
> The emacs manual recommends 'M-x reverse-region' as a companion to
> 'M-x sort-columns' to achieve a descending-order column sort.
This could be a bug in the manual, as sort-columns has an
optional (prefix) ‘reverse’ argument since at least 1990
(d32200ac.)
> However, for large regions (> 100k lines), 'M-x reverse-region' is
> noticeably slower than 'M-x sort-columns', making descending sort
> much slower than ascending sort.
I don’t seem to see this on the current master; at a glance,
M-x reverse-region takes less time to complete than
M-x sort-columns.
The current stable version of Emacs is 24.4, with the pretest
for 24.5 being available since 17th [1]. Could you please check
if this issue also manifests with either of these versions?
TIA.
[1] news:87mw4c6gjn.fsf <at> petton.fr
http://permalink.gmane.org/gmane.emacs.devel/183187
> A workaround on linux: use 'C-u M-x shell-command-on-region' with tac
> (the opposite of cat) instead of using 'M-x reverse-region'.
On a GNU system (as well as on any other system featuring
GNU Coreutils), it should be possible to just use sort(1) for
the purpose. For instance, the “reverse” option is ‘-r’.
[…]
--
FSF associate member #7257 http://boycottsystemd.org/ … 3013 B6A0 230E 334A
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19896
; Package
emacs
.
(Wed, 18 Feb 2015 19:02:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 19896 <at> debbugs.gnu.org (full text, mbox):
> From: Ivan Shmakov <ivan <at> siamics.net>
> Date: Wed, 18 Feb 2015 18:29:08 +0000
>
> > A workaround on linux: use 'C-u M-x shell-command-on-region' with tac
> > (the opposite of cat) instead of using 'M-x reverse-region'.
>
> On a GNU system (as well as on any other system featuring
> GNU Coreutils), it should be possible to just use sort(1) for
> the purpose. For instance, the “reverse” option is ‘-r’.
But sort(1)'s sort order is locale-specific, whereas that of Emacs
isn't.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19896
; Package
emacs
.
(Wed, 18 Feb 2015 19:14:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 19896 <at> debbugs.gnu.org (full text, mbox):
>>>>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>>>> From: Ivan Shmakov Date: Wed, 18 Feb 2015 18:29:08 +0000
[…]
>> On a GNU system (as well as on any other system featuring GNU
>> Coreutils), it should be possible to just use sort(1) for the
>> purpose. For instance, the “reverse” option is ‘-r’.
> But sort(1)'s sort order is locale-specific, whereas that of Emacs
> isn't.
How is that a disadvantage? The user can easily force any
locale of those available on the system with an explicit
LC_ALL=, like:
$ LC_ALL=de_DE.UTF-8 sort < list.de
$ LC_ALL=ru_RU.UTF-8 sort < list.ru
$ LC_ALL=C sort < list.ascii
For one thing, M-x sort-lines seems to put ё after я, while in
Russian it comes between е and ж. And similarly for ß (and the
accented letters) in German, etc.
--
FSF associate member #7257 np. Bombtrack — clawz/bomb … 3013 B6A0 230E 334A
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19896
; Package
emacs
.
(Wed, 18 Feb 2015 19:20:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 19896 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks for identifying the bug in the manual.
I do not have access to the latest versions of emacs, but thank you for verifying that reverse-region has an efficient implementation in the latest version.
Given that reverse-region is efficiently implemented in the latest versions, correcting the manual entries for sort-columns and reverse-region would provide resolution to this issue.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19896
; Package
emacs
.
(Wed, 18 Feb 2015 19:30:03 GMT)
Full text and
rfc822 format available.
Message #20 received at 19896 <at> debbugs.gnu.org (full text, mbox):
> From: Ivan Shmakov <ivan <at> siamics.net>
> Date: Wed, 18 Feb 2015 19:13:00 +0000
>
> >>>>> Eli Zaretskii <eliz <at> gnu.org> writes:
> >>>>> From: Ivan Shmakov Date: Wed, 18 Feb 2015 18:29:08 +0000
>
> […]
>
> >> On a GNU system (as well as on any other system featuring GNU
> >> Coreutils), it should be possible to just use sort(1) for the
> >> purpose. For instance, the “reverse” option is ‘-r’.
>
> > But sort(1)'s sort order is locale-specific, whereas that of Emacs
> > isn't.
>
> How is that a disadvantage?
I didn't say it was a disadvantage, only that the results might be
different, and will almost certainly be different in different
locales.
> The user can easily force any locale of those available on the
> system with an explicit LC_ALL=, like:
>
> $ LC_ALL=de_DE.UTF-8 sort < list.de
>
> $ LC_ALL=ru_RU.UTF-8 sort < list.ru
>
> $ LC_ALL=C sort < list.ascii
Yes, but Emacs's sort order is not in any locale, more or less. So
it's not easy to find a locale that will produce the same order as
Emacs, unless you know a lot about Emacs internals. And even if you
do, such a locale might not be installed on the end-user's machine.
> For one thing, M-x sort-lines seems to put ё after я, while in
> Russian it comes between е and ж. And similarly for ß (and the
> accented letters) in German, etc.
Precisely! That was my point.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19896
; Package
emacs
.
(Thu, 26 Feb 2015 17:54:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 19896 <at> debbugs.gnu.org (full text, mbox):
To close this bug, please modify
https://www.gnu.org/software/emacs/manual/html_node/emacs/Sorting.html
as follows:
Add the following to the description of M-x sort-columns:
"A numeric argument means sort into descending order."
Remove "or columns" from the description of M-x reverse-region.
Thanks.
Reply sent
to
Glenn Morris <rgm <at> gnu.org>
:
You have taken responsibility.
(Sun, 19 Apr 2015 00:50:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
asparagus <at> comcast.net
:
bug acknowledged by developer.
(Sun, 19 Apr 2015 00:50:03 GMT)
Full text and
rfc822 format available.
Message #28 received at 19896-done <at> debbugs.gnu.org (full text, mbox):
Version: 25.1
asparagus <at> comcast.net wrote:
> Add the following to the description of M-x sort-columns:
> "A numeric argument means sort into descending order."
>
> Remove "or columns" from the description of M-x reverse-region.
Thanks; done in the source. (The versions on www.gnu.org will probably
not be updated until the next Emacs release.)
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 17 May 2015 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 38 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.