Subject: Re: bug#16533: 24.3.50; "s" no longer works as documented in dired

From: Eli Zaretskii <[email-masked]>
Date: Sat, 25 Jan 2014 13:22:46 +0200

> From: Glenn Morris <[email-masked]>
> Date: Fri, 24 Jan 2014 13:32:55 -0500
> Cc: [email-masked]
> 
> Please confirm what the problem actually is - just that it says "by
> date" in the mode line?

I think the problem is that is says "by date", but the actual sorting
is not changed, i.e. it stays by size in this case.

> When it does so, what are the values of
> 
> dired-ls-sorting-switches

"SXU"

> dired-sort-by-date-regexp

"\\(\\`\\| \\)-[^- ]*t[^ SXU]*\\(\\(\\`\\| +\\)\\(--[^ ]+\\|-[^- tSXU]+\\)\\)* *$"

> dired-actual-switches

"-alSt"

And the latter is the root cause of the problem, IMO: the -S switch is
not removed from dired-actual-switches.

The problem here seems to be that dired-sort-toggle blindly adds the
"-t" flag to dired-actual-switches, although in this case the sorting
is not by date at all.  I don't understand the logic here; it seems
like dired-sort-toggle assumes without testing that the directory is
sorted either by date or by name, which is of course false.

Is it a portable assumption that the last switch that determines the
sorting order overrides all the previous ones?  If so, ls-lisp.el
should be fixed to implement that requirement.  But if not, we need to
fix dired.el not to put more than one sorting option into
dired-actual-switches.  In particular, the logic in dired-sort-toggle
seems to be flawed.