On Mon, Aug 28, 2017 at 12:00 AM, Robert Weiner <rsw@gnu.org> wrote:
---------- Forwarded message ----------
From: Richard Stallman <rms@gnu.org>
Date: Wed, Jun 22, 2016 at 2:34 AM
Subject: Re: Fwd: bug#23789: Emacs 25.0.94: Patch to make sort-lines respect visible lines (fairly urgent)
To: rswgnu@gmail.com

  > > I think the old behavior was only correct for Outline mode in SOME
  > > cases.  Not in all cases.  Likewise for the new behavior.

  > Can you list the cases you think exist and how you think each should
  > be handled?

When the first line of some substructure is visible and the rest of
that substructure is hidden, it seems to make sense to sort the
substructure with the first line.

​I agree.
​​
However, if there are two substructures at the same level
​​
and they are both invisible, it does not seem right for them
​​
to stick together in sorting.

​This I'll argue against.  The point of hiding the substructure in an outline is not just a visual one but also so you can operate on a hierarchy as a single entity.  You might want to move it, delete it or sort it but you typically want to treat it as a single unit.  Its visual representation, often as a single line, reflects this.

So, I would argue, when you sort an outline with certain elements visible and others hidden, you want to sort just the visible elements and keep the hidden substructures together with their visible ancestors but not sort them.  If you want to sort substructure, you expand it and visually reflect its existence.  That would make for pretty consistent and understandable behavior.

​​
I have a feeling that sort-lines doesn't really make
​​
sense for an
​ 
​​
o
​​
u
​​
t
​​
l
​​
i
​​
n
​​
e
​​
​​
​Personally, I have often found it useful.
​​
, and other operations are needed for sortin
​​
g in outlines.
​​
​Yes, we could write other commands or we could apply something like the simple patch I provided and make this do something ​useful before Emacs 26 is released.
We all agree that the current behavior of sort-lines is not useful in outlines as it stands.

​​
But I am not sure of that.
​​
​​
​I have contributed what I can on this and I hope someone is willing to try to get this patched before Emacs 26 goes out or we'll have a whole other long-lived generation of Emacs without a basic way to sort visible lines in a file.

Bob