From: florian@fsavigny.de (Florian v. Savigny)
To: help-gnu-emacs@gnu.org
Subject: Is there a function to sort file names by file version number, like "ls -v"?
Date: Thu, 23 May 2013 04:21:46 -0400 [thread overview]
Message-ID: <E1UfQmM-00010N-9K@eggs.gnu.org> (raw)
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
next reply other threads:[~2013-05-23 8:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 8:21 Florian v. Savigny [this message]
[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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1UfQmM-00010N-9K@eggs.gnu.org \
--to=florian@fsavigny.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.