unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Is there a function to sort file names by file version number, like "ls -v"?
@ 2013-05-23  8:21 Florian v. Savigny
  0 siblings, 0 replies; 6+ messages in thread
From: Florian v. Savigny @ 2013-05-23  8:21 UTC (permalink / raw)
  To: help-gnu-emacs


Hi there,

if you backup files using "cp --backup numbered", cp creates version
numbers like this:

xorg.conf.~1~
xorg.conf.~2~
...
xorg.conf.~9~
xorg.conf.~10~
xorg.conf.~11~
...
xorg.conf.~20~

etc.

As these names are not zero-padded, the normal, alphabetical sorting
will sort them like this:

xorg.conf.~10~
xorg.conf.~11~
...
xorg.conf.~1~
xorg.conf.~20~
xorg.conf.~21~
xorg.conf.~2~
...
xorg.conf.~9~

which is definitely not what is normally useful. For this reason, ls
seems to have the -v switch, which sorts them as shown in the first
listing.

I am wondering if there is somehow a comparison function (of the same
category as string-lessp) in Elisp which compares file name strings by
these version numbers, so I could sort the result of
directory-file-names in the same way as "ls -v".

Is there? (There must be! ;-))

Thank you very much in advance!

Best regards,

Florian




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-05-24 15:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.229.1369297314.22516.help-gnu-emacs@gnu.org>
2013-05-23 18:33 ` Is there a function to sort file names by file version number, like "ls -v"? Sean McAfee
2013-05-23 20:01   ` Florian v. Savigny
     [not found]   ` <mailman.283.1369339299.22516.help-gnu-emacs@gnu.org>
2013-05-23 20:18     ` Pascal J. Bourguignon
2013-05-23 20:28     ` Sean McAfee
2013-05-24 15:07       ` Florian v. Savigny
2013-05-23  8:21 Florian v. Savigny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).