From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: florian@fsavigny.de (Florian v. Savigny) Newsgroups: gmane.emacs.help 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 Message-ID: NNTP-Posting-Host: plane.gmane.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1369297332 7444 80.91.229.3 (23 May 2013 08:22:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 May 2013 08:22:12 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 23 10:22:10 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UfQmn-0002k3-MG for geh-help-gnu-emacs@m.gmane.org; Thu, 23 May 2013 10:22:09 +0200 Original-Received: from localhost ([::1]:42639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfQmn-0007sg-8n for geh-help-gnu-emacs@m.gmane.org; Thu, 23 May 2013 04:22:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfQmR-0007ks-1F for help-gnu-emacs@gnu.org; Thu, 23 May 2013 04:21:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfQmM-00010r-Fs for help-gnu-emacs@gnu.org; Thu, 23 May 2013 04:21:46 -0400 Original-Received: from srv4.ns-domain-hosting.de ([178.63.89.203]:60142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfQmM-00010N-9K for help-gnu-emacs@gnu.org; Thu, 23 May 2013 04:21:42 -0400 X-No-Relay: not in my network Original-Received: from bertrandrussell.Speedport_W_723V_1_27_000 (p4FECD59C.dip0.t-ipconnect.de [79.236.213.156]) by srv4.ns-domain-hosting.de (Postfix) with ESMTPA id CABC115DC001 for ; Thu, 23 May 2013 10:21:40 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 178.63.89.203 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90992 Archived-At: 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