From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Florian von Savigny Newsgroups: gmane.emacs.help Subject: customized name sorting in dired Date: Mon, 15 Nov 2004 12:06:53 +0100 Organization: 1&1 Internet AG Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1100517141 8413 80.91.229.6 (15 Nov 2004 11:12:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 15 Nov 2004 11:12:21 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 15 12:12:17 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CTemP-0000OI-00 for ; Mon, 15 Nov 2004 12:12:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CTev6-0007QF-Bw for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Nov 2004 06:21:16 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.stueberl.de!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 52 Original-NNTP-Posting-Host: pd950261d.dip0.t-ipconnect.de Original-X-Trace: online.de 1100516870 12243 217.80.38.29 (15 Nov 2004 11:07:50 GMT) Original-X-Complaints-To: abuse@einsundeins.com Original-NNTP-Posting-Date: Mon, 15 Nov 2004 11:07:50 +0000 (UTC) User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:oPvUzeU8CIUISSl04u0ppIbeZn0= Original-Xref: shelby.stanford.edu gnu.emacs.help:126601 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21996 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21996 I have been searching the archive for this, but it looks as if this particular idea has not yet been addressed: I have a directory the entries of which contain a date in DDMMYY format as the last part of their name. I would like to display these entries sorted according to this date. I figure that it is possible to sort a list of strings in that way roughly by providing the following function as the predicate to sort: (defun by-date-in-name (a b) "Returns t if the date in the first name is earlier than the second, nil otherwise." (if (string< (substring a -2 nil) (substring b -2 nil)) t (if (string< (substring a -4 -2) (substring b -4 -2)) t (if (string< (substring a -6 -4) (substring b -6 -4)) t nil)))) (Does not work perfectly yet, but I guess that simply requires some tinkering.) What puzzles me is how to get dired to sort the names by using this sort routine. I have tried to pass dired its first argument as (cons DIRNAME ), and add the listing switches "lU" but that seems to be a misapprehension of its usage (I get an error message about dired trying to open the first entry of the list and saying it has not found that directory). [Under the shell, you can say "ls -lUd `sort_by_date_in_name`" if sort_by_date_in_name is a script that returns the names in due order and separated by a space] Since actually it shouldn't be too complicated: is there any hook or similar available to tell dired how to sort the names of the entries of the directory it is operating upon? -- Florian v. Savigny If you are going to reply in private, please be patient, as I only check for mail something like once a week. - Si vous allez répondre personellement, patientez s.v.p., car je ne lis les courriels qu'environ une fois par semaine.