[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: customized name sorting in dired
From: |
Florian von Savigny |
Subject: |
Re: customized name sorting in dired |
Date: |
Wed, 17 Nov 2004 17:54:27 +0100 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
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 <ihs_4664@yahoo.com> 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") #<buffer auftraege>)
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.