1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ;; Description: dired odds and sods. Dired functions not usually needed.
7 ;; This file is not a reference to the Organization of
10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12 ;;; Don't require or provide anything, as this file is just an archive.
14 (defun dired-sort-on-size ()
15 "Sorts a dired listing on file size.
16 If your ls cannot sort on size, this is useful as `dired-after-readin-hook':
17 \(setq dired-after-readin-hook 'dired-sort-on-size\)"
19 (goto-char (point-min))
20 (dired-goto-next-file) ; skip `total' line
22 (sort-subr t 'forward-line 'end-of-line 'dired-get-file-size))
24 (defun dired-directories-of (files)
25 ;; Return unique list of parent directories of FILES.
28 (setq file (car files)
30 dir (file-name-directory file))
32 (setq dirs (cons dir dirs))))
35 (defun dired-parse-ls-show ()
37 (let (inode s mode size uid gid nlink time name sym)
39 (message "%s" (list inode s mode nlink uid gid size time name sym))
40 (message "Not on a file line."))))
42 (defun dired-files-same-directory (file-list &optional absolute)
43 "If all files in LIST are in the same directory return it, otherwise nil.
44 Returned name has no trailing slash. \"Same\" means file-name-directory of
45 the files are string=. File names in LIST must all be absolute or all be
46 relative. Implicitly, relative file names are in default-directory. If
47 optional ABS is non-nil, the returned name will be absolute, otherwise the
48 returned name will be absolute or relative as per the files in LIST."
49 (let ((dir (file-name-directory (car file-list))))
50 (if (memq nil (mapcar (function
52 (string= dir (file-name-directory file))))
56 (if (or (not absolute) (and dir (file-name-absolute-p dir)))
58 (concat default-directory dir))))))