[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Human-readable file sorting
From: |
Eli Zaretskii |
Subject: |
Re: Human-readable file sorting |
Date: |
Sat, 20 Feb 2016 11:28:46 +0200 |
> From: Lars Ingebrigtsen <address@hidden>
> Date: Sat, 20 Feb 2016 17:00:01 +1100
>
> So I think the easiest way to get all this consistent throughout Emacs
> isn't to allow `directory-files' to be customisable, but to instead
> introduce a new function `file-string-lessp' (or a better name if you
> have it)
logical-string-lessp, alphanumeric-string-lessp, human-string-lessp.
> (defun file-string-lessp (s1 s2)
> (pcase file-sorting-method
> (,unicode
> (string-lessp s1 s2))
> (,human
> (human-string-lessp s1 s2)))
> ..)
>
> (Hey! Did I get the pcase syntax right? Bonus points!)
Actually, pcase is not needed here, as you are comparing literal
symbols. cond should be do the job.
> (Perhaps it should be in the C layer for speed? Does it matter when
> sorting files names? That's probably not the bottleneck...)
Measure it before deciding.
Btw, MS-Windows filesystems sort files internally in the order you
want. E.g., here's what I get for a directory I set up for testing
this:
(directory-files "~/data/tsort")
=> ("." ".." "file1.png" "file10.png" "file11.png" "file2.png" "file3.png"
"file31.png" "file4.png" "file5.png" "file6.png" "file8.png" "file9.png")
Look, ma: no sorting required!
> If the proposed method sounds fine, I can start implementing...
It's certainly a good feature, thanks.
- Re: Human-readable file sorting, (continued)
- Re: Human-readable file sorting, Lars Ingebrigtsen, 2016/02/20
- Re: Human-readable file sorting, Marcin Borkowski, 2016/02/20
- Re: Human-readable file sorting, Lars Ingebrigtsen, 2016/02/20
- Re: Human-readable file sorting, Marcin Borkowski, 2016/02/20
- Re: Human-readable file sorting, Nikolaus Rath, 2016/02/22
- Re: Human-readable file sorting, Marcin Borkowski, 2016/02/22
- Re: Human-readable file sorting, Yuri Khan, 2016/02/23
- Re: Human-readable file sorting, Andreas Schwab, 2016/02/23
- Re: Human-readable file sorting, John Wiegley, 2016/02/20
- Re: Human-readable file sorting, Lars Ingebrigtsen, 2016/02/20
- Re: Human-readable file sorting,
Eli Zaretskii <=
- Re: Human-readable file sorting, martin rudalics, 2016/02/20
- Re: Human-readable file sorting, Eli Zaretskii, 2016/02/20
- Re: Human-readable file sorting, Michael Heerdegen, 2016/02/20
- RE: Human-readable file sorting, Drew Adams, 2016/02/20
- dired and ls (was: Human-readable file sorting), Lars Ingebrigtsen, 2016/02/20
- Re: dired and ls, John Wiegley, 2016/02/20
- Re: dired and ls, Lars Ingebrigtsen, 2016/02/20
- Re: dired and ls, John Wiegley, 2016/02/20
- Re: dired and ls, Thierry Volpiatto, 2016/02/23
- Re: dired and ls, John Wiegley, 2016/02/23