help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sort directories then files in Dired.


From: Thamer Mahmoud
Subject: Re: Sort directories then files in Dired.
Date: Sun, 05 Sep 2010 23:02:12 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Oleksandr Gavenko <gavenkoa@gmail.com> writes:

> ls have option --group-directories-first. But then I set
> 'dired-listing-switches' to '-al --group-directories-first'
> output seems damaged:
>
>   e:/home/devel/autorpg:
>   total used in directory 1 available 13039040
>       281474976729852  0drwxrwxrwx  1 sasha Отсутствует 0 2007-09-05  ..
>      1407374883569819  0drwxrwxrwx  1 sasha Отсутствует 0 2009-08-24  .
>      1125899906859437  0drwxrwxrwx  1 sasha Отсутствует 0 2009-08-24  .hg
>      2533274790412740  1-rw-rw-rw-  1 sasha Отсутствует 209 2009-08-24
> README
>       562949953438149  0drwxrwxrwx  1 sasha Отсутствует 0 2009-08-24
> very-dumb-game

I don't use --group-directories-first, sorry. Perhaps you should
consider reporting this as a bug.

As an alternative, I use the following code in ~/.emacs which
essentially does the same thing:

(defun mydired-sort ()
  "Sort dired listings with directories first."
  (save-excursion
    (let (buffer-read-only)
      (forward-line 2) ;; beyond dir. header 
      (sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max)))
    (set-buffer-modified-p nil)))

(defadvice dired-readin
  (after dired-after-updating-hook first () activate)
  "Sort dired listings with directories first before adding marks."
  (mydired-sort))

For more sorting options, see:
http://www.emacswiki.org/emacs/DiredSortDirectoriesFirst
http://www.emacswiki.org/emacs/DiredSortMenu

--
Thamer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]