[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dired, dired-x: how to get dir sorted by *size* (of files)?
From: |
Mike Ballard |
Subject: |
Re: dired, dired-x: how to get dir sorted by *size* (of files)? |
Date: |
Thu, 17 Jul 2003 02:13:58 GMT |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 |
On Wed Jul 16, David Combs disturbed my nap when he said:
> Just wondering -- is it possible (easily possible) to get
> dired-buf showing the dir's files, by SIZE (biggest
> at top)?
>
If you need to do this often (or other kinds of dired sorts) this will add
a "sort" menu under "Immediate." (Originally it was stand-alone but I
wanted it in one of my two customization files loaded by ~/.emacs - I hope
I haven't forgotten to include something):
;;; dired-sort
;;-------------------
;;; Author: Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk>
;(eval-when-compile
(require 'dired)
(require 'easymenu)
(easy-menu-add-item ; (map path item &optional before)
dired-mode-map '("menu-bar" "immediate")
(easy-menu-create-menu ; (menu-name menu-items)
"Sort By"
'(["Name" (dired-sort-menu-set "") :style radio
:selected (not (dired-sort-menu-switches "[tSXUuc]")) :active t]
["Modification Time" (dired-sort-menu-set "t") :style radio
:selected (dired-sort-menu-switches "t") :active t]
"--"
;; and for GNU `ls' only (but no easy way to test this) ...
["Size" (dired-sort-menu-set "S") :style radio
:selected (dired-sort-menu-switches "S") :active t]
["Extension" (dired-sort-menu-set "X") :style radio
:selected (dired-sort-menu-switches "X") :active t]
["Unsorted" (dired-sort-menu-set "U") :style radio
:selected (dired-sort-menu-switches "U") :active t]
"--"
["Access Time" (dired-sort-menu-set "u") :style radio
:selected (dired-sort-menu-switches "u") :active t]
["Change Time" (dired-sort-menu-set "c") :style radio
:selected (dired-sort-menu-switches "c") :active t]
"--"
["Reverse" (dired-sort-menu-toggle "r") :style toggle
:selected (dired-sort-menu-switches "r") :active t]
))
'revert-buffer)
(defun dired-sort-menu-switches (switch-regexp)
;; Test for dired switches.
(let (case-fold-search)
(string-match switch-regexp dired-actual-switches)))
(defun dired-sort-menu-set (switch)
;; Set optional `ls' switch and update buffer (cf. `dired-sort-other').
; (setq dired-actual-switches (concat "-al" switch))
(setq dired-actual-switches (concat "-alo" switch))
(dired-sort-set-modeline)
(revert-buffer))
(defun dired-sort-menu-toggle (switch)
;; Toggle optional `ls' switch and update buffer (cf. `dired-sort-other').
(setq dired-actual-switches
(if (string-match switch dired-actual-switches)
(replace-match "" t t dired-actual-switches)
(concat dired-actual-switches switch)))
(dired-sort-set-modeline)
(revert-buffer))
;;(provide 'dired-sort)
;;(add-hook 'dired-load-hook '(lambda () (require 'dired-sort-menu)))
Mike
--
mike.ballard--at--earthlink.net
"Roses are red, violets are blue,
I'm schizophrenic and so am I"