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: Re: customized name sorting in dired Date: Wed, 17 Nov 2004 17:54:27 +0100 Organization: 1&1 Internet AG Message-ID: References: <2vs7j6F2pbdefU1@uni-berlin.de> 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 1100710741 29285 80.91.229.6 (17 Nov 2004 16:59:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 17 Nov 2004 16:59:01 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 17 17:58:56 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 1CUT8x-000186-00 for ; Wed, 17 Nov 2004 17:58:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CUTHl-00016K-PP for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Nov 2004 12:08:01 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!npeer.de.kpn-eurorings.net!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 101 Original-NNTP-Posting-Host: pd95024ec.dip0.t-ipconnect.de Original-X-Trace: online.de 1100710523 27236 217.80.36.236 (17 Nov 2004 16:55:23 GMT) Original-X-Complaints-To: abuse@einsundeins.com Original-NNTP-Posting-Date: Wed, 17 Nov 2004 16:55:23 +0000 (UTC) User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:8SCy4qc99P1UXYLfVf4sH5/zIIM= Original-Xref: shelby.stanford.edu gnu.emacs.help:126697 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:22093 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:22093 Kevin, thanks very much. I ashamedly admit I have only now hit on the idea of renaming the entries such that they should sort properly with standard routines: beginning with YYMMDD, instead of ending with DDMMYY. Hence, my current need for custom sorting is suddenly gone. However, I will supply the answer in case anybody is interested in the problem (I am of course interested, but the urge is gone). So please, only bother with it if you find it plain interesting, anybody. Thanks for having been helpful, Kevin. Kevin Rodgers writes: > I'm not familiar with the ls -U option (a GNU extension?), but calling > dired like that works for me in Emacs 21.3 on Solaris. Perhaps you > could post your code and the resulting error message. The manpage says "-U: do not sort; list entries in directory order". The reason why I tried this was because I first tried a shell version of what I was now trying to find for Emacs. I wrote a Perl script that takes the directory entries and returns them in the sort order I want, separated by spaces. Calling ls -ld `sorting_script` (-d because the entries are directories) would then display the usual information but re-sort it - such as when you have three files a, b, and c, and say "ls b a c": ls will resort them to "a b c". Adding the -U switch has precluded this re-sorting on my system (maybe not the task it was originally intended for). So much for that. My idea how to implement this under Emacs was such: the documentation for dired says: (dired DIRNAME &optional SWITCHES) ... If DIRNAME is a cons, its first element is taken as the directory name and the rest as an explicit list of files to make directory entries for. I figured that to imitate the shell solution above, I had to supply the directory name as the car, and the sorted list of entries as the cons, which ls would dutyfully not re-sort if I supplied the -U switch: (defun dired-entries-in-my-order (dir) "Run dired on DIR; display entries in proper order." (interactive "DDirectory: ") (dired (cons dir (sort (directory-files dir nil) 'by-date-in-name)) ;; see first posting "lU")) That seems to have been a misapprehension; the message is as follows. Curiously, it is emitted no matter whether I do a (cd DIR) first or not (if that made a difference, I would have an idea what the problem is ...): Reading directory /home/uebersetzer/auftraege/... insert-directory: Reading directory: file or directory not found, hau45147ess030204 [hau45147ess030204 is the first entry of the sorted list] Maybe this also helps (control characters replaced by Gnus): Debugger entered--Lisp error: (file-error "Reading directory" "file or directory not found" "hau45147ess030204") access-file("hau45147ess030204" "Reading directory") insert-directory("hau45147ess030204" "lU" nil nil) #[(x) "Ä \n $." [x switches wildcard full-p insert-directory] 5]("hau45147ess030204") mapcar(#[(x) "Ä \n $." [x switches wildcard full-p insert-directory] 5] ("hau45147ess030204" "sta33609bie080304" "sta33609bie160304" "sel57439att300304" "med13008mar040604" "hau45147ess140404" "hau45147ess060504" "sel57439att270604" "sel57439att080704" "hau45147ess030804" "sel57439att100804" "sel57439att160904" "log41100mod180804" "5_5-35310cha230704" "sel57439att240904" "sel57439att081004" "med13008mar290604" "med13008mar160904" "log41100mod280904" "log41100mod191004" "hau45147ess200204" "log41100mod291004")) dired-insert-directory(("/home/uebersetzer/auftraege/" "hau45147ess030204" "sta33609bie080304" "sta33609bie160304" "sel57439att300304" "med13008mar040604" "hau45147ess140404" "hau45147ess060504" "sel57439att270604" "sel57439att080704" "hau45147ess030804" "sel57439att100804" "sel57439att160904" "log41100mod180804" "5_5-35310cha230704" "sel57439att240904" "sel57439att081004" "med13008mar290604" "med13008mar160904" "log41100mod280904" "log41100mod191004" "hau45147ess200204" "log41100mod291004") "lU" nil) dired-readin-insert(("/home/uebersetzer/auftraege/" "hau45147ess030204" "sta33609bie080304" "sta33609bie160304" "sel57439att300304" "med13008mar040604" "hau45147ess140404" "hau45147ess060504" "sel57439att270604" "sel57439att080704" "hau45147ess030804" "sel57439att100804" "sel57439att160904" "log41100mod180804" "5_5-35310cha230704" "sel57439att240904" "sel57439att081004" "med13008mar290604" "med13008mar160904" "log41100mod280904" "log41100mod191004" "hau45147ess200204" "log41100mod291004")) dired-readin(("/home/uebersetzer/auftraege/" "hau45147ess030204" "sta33609bie080304" "sta33609bie160304" "sel57439att300304" "med13008mar040604" "hau45147ess140404" "hau45147ess060504" "sel57439att270604" "sel57439att080704" "hau45147ess030804" "sel57439att100804" "sel57439att160904" "log41100mod180804" "5_5-35310cha230704" "sel57439att240904" "sel57439att081004" "med13008mar290604" "med13008mar160904" "log41100mod280904" "log41100mod191004" "hau45147ess200204" "log41100mod291004") #) dired-internal-noselect(("/home/uebersetzer/auftraege/" "hau45147ess030204" "sta33609bie080304" "sta33609bie160304" "sel57439att300304" "med13008mar040604" "hau45147ess140404" "hau45147ess060504" "sel57439att270604" "sel57439att080704" "hau45147ess030804" "sel57439att100804" "sel57439att160904" "log41100mod180804" "5_5-35310cha230704" "sel57439att240904" "sel57439att081004" "med13008mar290604" "med13008mar160904" "log41100mod280904" "log41100mod191004" "hau45147ess200204" "log41100mod291004") "lU") dired-noselect(("/home/uebersetzer/auftraege/" "hau45147ess030204" "sta33609bie080304" "sta33609bie160304" "sel57439att300304" "med13008mar040604" "hau45147ess140404" "hau45147ess060504" "sel57439att270604" "sel57439att080704" "hau45147ess030804" "sel57439att100804" "sel57439att160904" "log41100mod180804" "5_5-35310cha230704" "sel57439att240904" "sel57439att081004" "med13008mar290604" "med13008mar160904" "log41100mod280904" "log41100mod191004" "hau45147ess200204" "log41100mod291004") "lU") dired(("/home/uebersetzer/auftraege/" "hau45147ess030204" "sta33609bie080304" "sta33609bie160304" "sel57439att300304" "med13008mar040604" "hau45147ess140404" "hau45147ess060504" "sel57439att270604" "sel57439att080704" "hau45147ess030804" "sel57439att100804" "sel57439att160904" "log41100mod180804" "5_5-35310cha230704" "sel57439att240904" "sel57439att081004" "med13008mar290604" "med13008mar160904" "log41100mod280904" "log41100mod191004" "hau45147ess200204" "log41100mod291004") "lU") dired-entries-in-my-order("/home/uebersetzer/auftraege/") eval((dired-entries-in-my-order "/home/uebersetzer/auftraege/")) eval-last-sexp-1(t) eval-last-sexp(t) eval-print-last-sexp() call-interactively(eval-print-last-sexp) -- 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.