Mercurial > hg > xemacs-beta
comparison lisp/efs/dired.el @ 48:56c54cf7c5b6 r19-16b90
Import from CVS: tag r19-16b90
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:56:04 +0200 |
parents | 8b8b7f3559a2 |
children | ee648375d8d6 |
comparison
equal
deleted
inserted
replaced
47:11c6df210d7f | 48:56c54cf7c5b6 |
---|---|
219 ;; uses the user's value of the environment variable PATH. chown is | 219 ;; uses the user's value of the environment variable PATH. chown is |
220 ;; an exception as it is not always in the PATH. | 220 ;; an exception as it is not always in the PATH. |
221 | 221 |
222 ;;;###autoload | 222 ;;;###autoload |
223 (defvar dired-chown-program | 223 (defvar dired-chown-program |
224 (if (memq system-type '(hpux dgux usg-unix-v)) "chown" "/etc/chown") | 224 (if (memq system-type '(hpux dgux usg-unix-v linux)) "chown" "/etc/chown") |
225 "*Name of chown command (usually `chown' or `/etc/chown').") | 225 "*Name of chown command (usually `chown' or `/etc/chown').") |
226 | 226 |
227 ;;;###autoload | 227 ;;;###autoload |
228 (defvar dired-gnutar-program nil | 228 (defvar dired-gnutar-program nil |
229 "*If non-nil, name of the GNU tar executable (e.g. \"tar\" or \"gnutar\"). | 229 "*If non-nil, name of the GNU tar executable (e.g. \"tar\" or \"gnutar\"). |
374 The symbols 'rmail and 'vm are the only two allowed values.") | 374 The symbols 'rmail and 'vm are the only two allowed values.") |
375 | 375 |
376 (defvar dired-verify-modtimes t | 376 (defvar dired-verify-modtimes t |
377 "*If non-nil dired will revert dired buffers for modified subdirectories. | 377 "*If non-nil dired will revert dired buffers for modified subdirectories. |
378 See also dired-no-confirm <V>.") | 378 See also dired-no-confirm <V>.") |
379 | |
380 ;;;###autoload | |
381 (defvar dired-refresh-automatically t | |
382 "*If non-nil, refresh dired buffers automatically after file operations.") | |
379 | 383 |
380 ;;; File name regular expressions and extensions. | 384 ;;; File name regular expressions and extensions. |
381 | 385 |
382 (defvar dired-trivial-filenames "^\\.\\.?$\\|^#" | 386 (defvar dired-trivial-filenames "^\\.\\.?$\\|^#" |
383 "*Regexp of files to skip when finding first file of a directory listing. | 387 "*Regexp of files to skip when finding first file of a directory listing. |
416 | 420 |
417 (defvar dired-omit-regexps '("^#" "^\\.") | 421 (defvar dired-omit-regexps '("^#" "^\\.") |
418 "*File names matching these regexp may be omitted (buffer-local). | 422 "*File names matching these regexp may be omitted (buffer-local). |
419 This only has effect when the subdirectory is in omission mode. | 423 This only has effect when the subdirectory is in omission mode. |
420 To make omission mode the default, set `dired-omit-files' to t. | 424 To make omission mode the default, set `dired-omit-files' to t. |
421 This only has effect when `dired-omit-files-p' is t. | 425 This only has effect when `dired-omit-files' is t. |
422 See also `dired-omit-extensions'.") | 426 See also `dired-omit-extensions'.") |
423 (make-variable-buffer-local 'dired-omit-files-regexp) | 427 (make-variable-buffer-local 'dired-omit-regexps) |
424 | 428 |
425 (defvar dired-filename-re-ext "\\..+$" ; start from the first dot. last dot? | 429 (defvar dired-filename-re-ext "\\..+$" ; start from the first dot. last dot? |
426 "*Defines what is the extension of a file name. | 430 "*Defines what is the extension of a file name. |
427 \(match-beginning 0\) for this regexp in the file name without directory will | 431 \(match-beginning 0\) for this regexp in the file name without directory will |
428 be taken to be the start of the extension.") | 432 be taken to be the start of the extension.") |
1557 ;; successfully use dired functions (e.g. dired-get-filename) | 1561 ;; successfully use dired functions (e.g. dired-get-filename) |
1558 ;; as the subdir-alist has been built in dired-readin. | 1562 ;; as the subdir-alist has been built in dired-readin. |
1559 (run-hooks 'dired-after-readin-hook) | 1563 (run-hooks 'dired-after-readin-hook) |
1560 ;; I put omit-expunge after the dired-after-readin-hook | 1564 ;; I put omit-expunge after the dired-after-readin-hook |
1561 ;; in case that hook marks files. Does this make sense? Also, users | 1565 ;; in case that hook marks files. Does this make sense? Also, users |
1562 ;; might want to set dired-omit-files-p in some incredibly clever | 1566 ;; might want to set dired-omit-files in some incredibly clever |
1563 ;; way depending on the contents of the directory... I don't know... | 1567 ;; way depending on the contents of the directory... I don't know... |
1564 (if dired-omit-files | 1568 (if dired-omit-files |
1565 (dired-omit-expunge nil t)) | 1569 (dired-omit-expunge nil t)) |
1566 (goto-char (point-min)) | 1570 (goto-char (point-min)) |
1567 (dired-initial-position dirname)) | 1571 (dired-initial-position dirname)) |
1639 (message "Reading directory %s..." dirname) | 1643 (message "Reading directory %s..." dirname) |
1640 (let (buffer-read-only) | 1644 (let (buffer-read-only) |
1641 (widen) | 1645 (widen) |
1642 (erase-buffer) | 1646 (erase-buffer) |
1643 (dired-readin-insert dir-or-list wildcard) | 1647 (dired-readin-insert dir-or-list wildcard) |
1644 (dired-indent-listing (point-min) (point-max)) | 1648 (dired-indent-listing (point-min) (point-max-marker)) |
1645 ;; We need this to make the root dir have a header line as all | 1649 ;; We need this to make the root dir have a header line as all |
1646 ;; other subdirs have: | 1650 ;; other subdirs have: |
1647 (goto-char (point-min)) | 1651 (goto-char (point-min)) |
1648 (dired-insert-headerline (expand-file-name default-directory))) | 1652 (dired-insert-headerline (expand-file-name default-directory))) |
1649 (message "Reading directory %s...done" dirname) | 1653 (message "Reading directory %s...done" dirname) |
3810 | 3814 |
3811 (defun dired-unmark (arg) | 3815 (defun dired-unmark (arg) |
3812 "Unmark the current (or next ARG) files. | 3816 "Unmark the current (or next ARG) files. |
3813 If looking at a subdir, unmark all its files except `.' and `..'." | 3817 If looking at a subdir, unmark all its files except `.' and `..'." |
3814 (interactive "p") | 3818 (interactive "p") |
3815 (let (buffer-read-only) | 3819 (if (dired-get-subdir) |
3816 (dired-repeat-over-lines | 3820 (dired-mark-subdir-files ?\ ) |
3817 arg | 3821 (let (buffer-read-only) |
3818 (function | 3822 (dired-repeat-over-lines |
3819 (lambda () | 3823 arg |
3820 (let ((char (following-char))) | 3824 (function |
3821 (or (memq char '(?\ ?\n ?\r)) | 3825 (lambda () |
3822 (progn | 3826 (let ((char (following-char))) |
3823 (cond | 3827 (or (memq char '(?\ ?\n ?\r)) |
3824 ((char-equal char dired-marker-char) | 3828 (progn |
3825 (setq dired-marks-number (max (1- dired-marks-number) 0))) | 3829 (cond |
3826 ((char-equal char dired-del-marker) | 3830 ((char-equal char dired-marker-char) |
3827 (setq dired-del-flags-number | 3831 (setq dired-marks-number (max (1- dired-marks-number) 0))) |
3828 (max (1- dired-del-flags-number) 0))) | 3832 ((char-equal char dired-del-marker) |
3829 ((setq dired-other-marks-number | 3833 (setq dired-del-flags-number |
3830 (max (1- dired-other-marks-number) 0)))) | 3834 (max (1- dired-del-flags-number) 0))) |
3831 (dired-substitute-marker (point) char ?\ ))))))) | 3835 ((setq dired-other-marks-number |
3832 (dired-update-mode-line-modified))) | 3836 (max (1- dired-other-marks-number) 0)))) |
3837 (dired-substitute-marker (point) char ?\ ))))))) | |
3838 (dired-update-mode-line-modified)))) | |
3833 | 3839 |
3834 (defun dired-mark-prefix (&optional arg) | 3840 (defun dired-mark-prefix (&optional arg) |
3835 "Mark the next ARG files with the next character typed. | 3841 "Mark the next ARG files with the next character typed. |
3836 If ARG is negative, marks the previous files." | 3842 If ARG is negative, marks the previous files." |
3837 (interactive "p") | 3843 (interactive "p") |
5104 (defun dired-get-file-size () | 5110 (defun dired-get-file-size () |
5105 ;; Returns the file size in bytes of the current file, as an integer. | 5111 ;; Returns the file size in bytes of the current file, as an integer. |
5106 ;; Assumes that it is on a valid file line. It's the caller's responsibility | 5112 ;; Assumes that it is on a valid file line. It's the caller's responsibility |
5107 ;; to ensure this. Assumes that match 0 for dired-re-month-and-time is | 5113 ;; to ensure this. Assumes that match 0 for dired-re-month-and-time is |
5108 ;; at the end of the file size. | 5114 ;; at the end of the file size. |
5109 (dired-move-to-filename t) | 5115 (end-of-line) |
5110 ;; dired-move-to-filename must leave match-beginning 0 at the start of | 5116 (search-backward-regexp dired-re-month-and-time) |
5111 ;; the date. | |
5112 (goto-char (match-beginning 0)) | |
5113 (skip-chars-backward " ") | 5117 (skip-chars-backward " ") |
5114 (string-to-int (buffer-substring (point) | 5118 (string-to-int (buffer-substring (point) |
5115 (progn (skip-chars-backward "0-9") | 5119 (progn (skip-chars-backward "0-9") |
5116 (point))))) | 5120 (point))))) |
5117 | 5121 |
5267 ;; For historical reasons, we still use the term expunge, although nothing | 5271 ;; For historical reasons, we still use the term expunge, although nothing |
5268 ;; is expunged from the buffer. | 5272 ;; is expunged from the buffer. |
5269 | 5273 |
5270 (defun dired-omit-toggle (&optional arg) | 5274 (defun dired-omit-toggle (&optional arg) |
5271 "Toggle between displaying and omitting files matching | 5275 "Toggle between displaying and omitting files matching |
5272 `dired-omit-files-regexp' in the current subdirectory. | 5276 `dired-omit-regexps' in the current subdirectory. |
5273 With a positive prefix, omits files in the entire tree dired buffer. | 5277 With a positive prefix, omits files in the entire tree dired buffer. |
5274 With a negative prefix, forces all files in the tree dired buffer to be | 5278 With a negative prefix, forces all files in the tree dired buffer to be |
5275 displayed." | 5279 displayed." |
5276 (interactive "P") | 5280 (interactive "P") |
5277 (if arg | 5281 (if arg |
5311 (setq result (cons (car elt) result)))) | 5315 (setq result (cons (car elt) result)))) |
5312 result)) | 5316 result)) |
5313 | 5317 |
5314 (defun dired-omit-expunge (&optional regexp full-buffer) | 5318 (defun dired-omit-expunge (&optional regexp full-buffer) |
5315 ;; Hides all unmarked files matching REGEXP. | 5319 ;; Hides all unmarked files matching REGEXP. |
5316 ;; If REGEXP is nil or not specified, uses `dired-omit-files-regexp', | 5320 ;; If REGEXP is nil or not specified, uses `dired-omit-regexps', |
5317 ;; and also omits filenames ending in `dired-omit-extensions'. | 5321 ;; and also omits filenames ending in `dired-omit-extensions'. |
5318 ;; If REGEXP is the empty string, this function is a no-op. | 5322 ;; If REGEXP is the empty string, this function is a no-op. |
5319 (let ((omit-re (or regexp (dired-omit-regexp))) | 5323 (let ((omit-re (or regexp (dired-omit-regexp))) |
5320 (alist dired-subdir-alist) | 5324 (alist dired-subdir-alist) |
5321 elt min) | 5325 elt min) |
5717 (delq nil | 5721 (delq nil |
5718 (mapcar | 5722 (mapcar |
5719 (function | 5723 (function |
5720 (lambda (x) | 5724 (lambda (x) |
5721 (and (not (eq (current-buffer) (cdr x))) x))) | 5725 (and (not (eq (current-buffer) (cdr x))) x))) |
5722 dired-buffers)))) | 5726 dired-buffers))) |
5727 ;; If there are no more dired buffers, we are no longer needed in the | |
5728 ;; file-name-handler-alist. | |
5729 (or dired-buffers (dired-remove-from-file-name-handler-alist))) | |
5723 | 5730 |
5724 (defun dired-fun-in-all-buffers (directory fun &rest args) | 5731 (defun dired-fun-in-all-buffers (directory fun &rest args) |
5725 ;; In all buffers dired'ing DIRECTORY, run FUN with ARGS. | 5732 ;; In all buffers dired'ing DIRECTORY, run FUN with ARGS. |
5726 ;; Return list of buffers where FUN succeeded (i.e., returned non-nil). | 5733 ;; Return list of buffers where FUN succeeded (i.e., returned non-nil). |
5727 (let* ((buf-list (dired-buffers-for-dir directory)) | 5734 (let* ((buf-list (dired-buffers-for-dir directory)) |
6183 x))) | 6190 x))) |
6184 file-name-handler-alist)))) | 6191 file-name-handler-alist)))) |
6185 | 6192 |
6186 (defun dired-check-file-name-handler-alist () | 6193 (defun dired-check-file-name-handler-alist () |
6187 ;; Verify that dired is installed as the first item in the alist | 6194 ;; Verify that dired is installed as the first item in the alist |
6188 (or (eq (cdr (car file-name-handler-alist)) 'dired-handler-fn) | 6195 (and dired-refresh-automatically |
6189 (setq file-name-handler-alist | 6196 (or (eq (cdr (car file-name-handler-alist)) 'dired-handler-fn) |
6190 (cons | 6197 (setq file-name-handler-alist |
6191 '("." . dired-handler-fn) | 6198 (cons |
6192 (dired-remove-from-file-name-handler-alist))))) | 6199 '("." . dired-handler-fn) |
6200 (dired-remove-from-file-name-handler-alist)))))) | |
6193 | 6201 |
6194 (defun dired-handler-fn (op &rest args) | 6202 (defun dired-handler-fn (op &rest args) |
6195 ;; Function to update dired buffers after I/O. | 6203 ;; Function to update dired buffers after I/O. |
6196 (prog1 | 6204 (prog1 |
6197 (let ((inhibit-file-name-handlers | 6205 (let ((inhibit-file-name-handlers |