all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: customized name sorting in dired
Date: Wed, 17 Nov 2004 11:51:54 -0700	[thread overview]
Message-ID: <301kudF2q4km0U1@uni-berlin.de> (raw)
In-Reply-To: <m3k6sktnzw.fsf@yahoo.de>

Florian von Savigny wrote:
 > 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).

That's what I wanted to suggest, but I figured the files were named that
way for a reason.  I prefer CCYY-MM-DD myself.

 > So please, only bother with it if you find it plain interesting,
 > anybody. Thanks for having been helpful, Kevin.

You're welcome!

 > 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.

Right.

 > 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"))

You need to pass SWITCHES as "-lU", because it is used as the value of
dired-listing-switches.

-- 
Kevin Rodgers

  reply	other threads:[~2004-11-17 18:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-15 11:06 customized name sorting in dired Florian von Savigny
2004-11-15 17:33 ` Kevin Rodgers
2004-11-17 16:54   ` Florian von Savigny
2004-11-17 18:51     ` Kevin Rodgers [this message]
2004-11-15 19:40 ` Drew Adams

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=301kudF2q4km0U1@uni-berlin.de \
    --to=ihs_4664@yahoo.com \
    /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.