annotate lisp/efs/dired-oas.el @ 142:1856695b1fa9 r20-2b5

Import from CVS: tag r20-2b5
author cvs
date Mon, 13 Aug 2007 09:33:18 +0200
parents 9f59509498e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;; File: dired-oas.el
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 22
diff changeset
4 ;; Dired Version: #Revision: 7.9 $
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; RCS:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
6 ;; Description: dired odds and sods. Dired functions not usually needed.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;; This file is not a reference to the Organization of
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; American States.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12 ;;; Don't require or provide anything, as this file is just an archive.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 (defun dired-sort-on-size ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15 "Sorts a dired listing on file size.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 If your ls cannot sort on size, this is useful as `dired-after-readin-hook':
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 \(setq dired-after-readin-hook 'dired-sort-on-size\)"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18 (require 'sort)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 (goto-char (point-min))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 (dired-goto-next-file) ; skip `total' line
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 (beginning-of-line)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 (sort-subr t 'forward-line 'end-of-line 'dired-get-file-size))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 (defun dired-directories-of (files)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 ;; Return unique list of parent directories of FILES.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 (let (dirs dir file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 (while files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28 (setq file (car files)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 files (cdr files)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30 dir (file-name-directory file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 (or (member dir dirs)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 (setq dirs (cons dir dirs))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 dirs))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 (defun dired-parse-ls-show ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 (interactive)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 (let (inode s mode size uid gid nlink time name sym)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38 (if (dired-parse-ls)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 (message "%s" (list inode s mode nlink uid gid size time name sym))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 (message "Not on a file line."))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 (defun dired-files-same-directory (file-list &optional absolute)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 "If all files in LIST are in the same directory return it, otherwise nil.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 Returned name has no trailing slash. \"Same\" means file-name-directory of
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 the files are string=. File names in LIST must all be absolute or all be
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 relative. Implicitly, relative file names are in default-directory. If
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 optional ABS is non-nil, the returned name will be absolute, otherwise the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 returned name will be absolute or relative as per the files in LIST."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 (let ((dir (file-name-directory (car file-list))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 (if (memq nil (mapcar (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 (lambda (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 (string= dir (file-name-directory file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 file-list))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 (directory-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 (if (or (not absolute) (and dir (file-name-absolute-p dir)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 (or dir "")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (concat default-directory dir))))))