1 |
;;; dired.el --- directory-browsing commands |
;;; dired.el --- directory-browsing commands |
2 |
|
|
3 |
;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 1997, 2000, 2001 |
;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 1997, 2000, 2001, 2003 |
4 |
;; Free Software Foundation, Inc. |
;; Free Software Foundation, Inc. |
5 |
|
|
6 |
;; Author: Sebastian Kremer <sk@thp.uni-koeln.de> |
;; Author: Sebastian Kremer <sk@thp.uni-koeln.de> |
39 |
|
|
40 |
(defgroup dired nil |
(defgroup dired nil |
41 |
"Directory editing." |
"Directory editing." |
42 |
:group 'environment) |
:group 'files) |
43 |
|
|
44 |
(defgroup dired-mark nil |
(defgroup dired-mark nil |
45 |
"Handling marks in Dired." |
"Handling marks in Dired." |
59 |
:type 'string |
:type 'string |
60 |
:group 'dired) |
:group 'dired) |
61 |
|
|
62 |
; Don't use absolute paths as /bin should be in any PATH and people |
; Don't use absolute file names as /bin should be in any PATH and people |
63 |
; may prefer /usr/local/gnu/bin or whatever. However, chown is |
; may prefer /usr/local/gnu/bin or whatever. However, chown is |
64 |
; usually not in PATH. |
; usually not in PATH. |
65 |
|
|
66 |
;;;###autoload |
;;;###autoload |
67 |
(defvar dired-chown-program |
(defvar dired-chown-program |
68 |
(if (memq system-type '(hpux dgux usg-unix-v irix linux gnu/linux)) |
(if (memq system-type '(hpux dgux usg-unix-v irix linux gnu/linux cygwin)) |
69 |
"chown" |
"chown" |
70 |
(if (file-exists-p "/usr/sbin/chown") |
(if (file-exists-p "/usr/sbin/chown") |
71 |
"/usr/sbin/chown" |
"/usr/sbin/chown" |
72 |
"/etc/chown")) |
"/etc/chown")) |
73 |
"Name of chown command (usually `chown' or `/etc/chown').") |
"Name of chown command (usually `chown' or `/etc/chown').") |
74 |
|
|
75 |
|
(defvar dired-use-ls-dired (not (not (string-match "gnu" system-configuration))) |
76 |
|
"Non-nil means Dired should use `ls --dired'.") |
77 |
|
|
78 |
(defvar dired-chmod-program "chmod" |
(defvar dired-chmod-program "chmod" |
79 |
"Name of chmod command (usually `chmod').") |
"Name of chmod command (usually `chmod').") |
80 |
|
|
192 |
;; Note this can't simply be run inside function `dired-ls' as the hook |
;; Note this can't simply be run inside function `dired-ls' as the hook |
193 |
;; functions probably depend on the dired-subdir-alist to be OK. |
;; functions probably depend on the dired-subdir-alist to be OK. |
194 |
|
|
195 |
;;; Internal variables |
;; Internal variables |
196 |
|
|
197 |
(defvar dired-marker-char ?* ; the answer is 42 |
(defvar dired-marker-char ?* ; the answer is 42 |
198 |
;; so that you can write things like |
;; so that you can write things like |
219 |
|
|
220 |
(defvar dired-file-version-alist) |
(defvar dired-file-version-alist) |
221 |
|
|
222 |
|
;;;###autoload |
223 |
(defvar dired-directory nil |
(defvar dired-directory nil |
224 |
"The directory name or shell wildcard that was used as argument to `ls'. |
"The directory name or wildcard spec that this Dired directory lists. |
225 |
Local to each dired buffer. May be a list, in which case the car is the |
Local to each dired buffer. May be a list, in which case the car is the |
226 |
directory name and the cdr is the actual files to list.") |
directory name and the cdr is the list of files to mention. |
227 |
|
The directory name must be absolute, but need not be fully expanded.") |
228 |
|
|
229 |
(defvar dired-actual-switches nil |
(defvar dired-actual-switches nil |
230 |
"The value of `dired-listing-switches' used to make this buffer's text.") |
"The value of `dired-listing-switches' used to make this buffer's text.") |
300 |
'(".+" (dired-move-to-filename) nil (0 font-lock-function-name-face))) |
'(".+" (dired-move-to-filename) nil (0 font-lock-function-name-face))) |
301 |
;; |
;; |
302 |
;; Symbolic links. |
;; Symbolic links. |
303 |
(list dired-re-sym |
(list dired-re-sym |
304 |
'(".+" (dired-move-to-filename) nil (0 font-lock-keyword-face))) |
'(".+" (dired-move-to-filename) nil (0 font-lock-keyword-face))) |
305 |
;; |
;; |
306 |
;; Files suffixed with `completion-ignored-extensions'. |
;; Files suffixed with `completion-ignored-extensions'. |
307 |
'(eval . |
'(eval . |
308 |
(let ((extensions (mapcar 'regexp-quote completion-ignored-extensions))) |
;; It is quicker to first find just an extension, then go back to the |
309 |
;; It is quicker to first find just an extension, then go back to the |
;; start of that file name. So we do this complex MATCH-ANCHORED form. |
310 |
;; start of that file name. So we do this complex MATCH-ANCHORED form. |
(list (concat "\\(" (regexp-opt completion-ignored-extensions) "\\|#\\)$") |
311 |
(list (concat "\\(" (mapconcat 'identity extensions "\\|") "\\|#\\)$") |
'(".+" (dired-move-to-filename) nil (0 font-lock-string-face))))) |
|
'(".+" (dired-move-to-filename) nil (0 font-lock-string-face)))))) |
|
312 |
"Additional expressions to highlight in Dired mode.") |
"Additional expressions to highlight in Dired mode.") |
313 |
|
|
314 |
;;; Macros must be defined before they are used, for the byte compiler. |
;;; Macros must be defined before they are used, for the byte compiler. |
424 |
(push file result))) |
(push file result))) |
425 |
result))) |
result))) |
426 |
|
|
|
;; Function dired-ls is redefinable for VMS, ange-ftp, Prospero or |
|
|
;; other special applications. |
|
|
|
|
427 |
;; The dired command |
;; The dired command |
428 |
|
|
429 |
(defun dired-read-dir-and-switches (str) |
(defun dired-read-dir-and-switches (str) |
512 |
;; like find-file does. |
;; like find-file does. |
513 |
;; Optional argument MODE is passed to dired-find-buffer-nocreate, |
;; Optional argument MODE is passed to dired-find-buffer-nocreate, |
514 |
;; see there. |
;; see there. |
515 |
(let* ((dirname (if (consp dir-or-list) (car dir-or-list) dir-or-list)) |
(let* (dirname |
516 |
;; The following line used to use dir-or-list. |
buffer |
|
;; That never found an existing buffer, in the case |
|
|
;; where it is a list. |
|
|
(buffer (dired-find-buffer-nocreate dirname mode)) |
|
517 |
;; note that buffer already is in dired-mode, if found |
;; note that buffer already is in dired-mode, if found |
518 |
(new-buffer-p (not buffer)) |
new-buffer-p |
519 |
(old-buf (current-buffer))) |
(old-buf (current-buffer))) |
520 |
|
(if (consp dir-or-list) |
521 |
|
(setq dirname (car dir-or-list)) |
522 |
|
(setq dirname dir-or-list)) |
523 |
|
;; Look for an existing buffer. |
524 |
|
(setq buffer (dired-find-buffer-nocreate dirname mode) |
525 |
|
new-buffer-p (null buffer)) |
526 |
(or buffer |
(or buffer |
527 |
(let ((default-major-mode 'fundamental-mode)) |
(let ((default-major-mode 'fundamental-mode)) |
528 |
;; We don't want default-major-mode to run hooks and set auto-fill |
;; We don't want default-major-mode to run hooks and set auto-fill |
531 |
(setq buffer (create-file-buffer (directory-file-name dirname))))) |
(setq buffer (create-file-buffer (directory-file-name dirname))))) |
532 |
(set-buffer buffer) |
(set-buffer buffer) |
533 |
(if (not new-buffer-p) ; existing buffer ... |
(if (not new-buffer-p) ; existing buffer ... |
534 |
(cond (switches ; ... but new switches |
(cond (switches ; ... but new switches |
535 |
;; file list may have changed |
;; file list may have changed |
536 |
(if (consp dir-or-list) |
(setq dired-directory dir-or-list) |
|
(setq dired-directory dir-or-list)) |
|
537 |
;; this calls dired-revert |
;; this calls dired-revert |
538 |
(dired-sort-other switches)) |
(dired-sort-other switches)) |
539 |
;; If directory has changed on disk, offer to revert. |
;; If directory has changed on disk, offer to revert. |
540 |
((if (let ((attributes (file-attributes dirname)) |
((if (let ((attributes (file-attributes dirname)) |
541 |
(modtime (visited-file-modtime))) |
(modtime (visited-file-modtime))) |
556 |
(file-name-directory dirname)) |
(file-name-directory dirname)) |
557 |
(or switches (setq switches dired-listing-switches)) |
(or switches (setq switches dired-listing-switches)) |
558 |
(if mode (funcall mode) |
(if mode (funcall mode) |
559 |
(dired-mode dirname switches)) |
(dired-mode dir-or-list switches)) |
560 |
;; default-directory and dired-actual-switches are set now |
;; default-directory and dired-actual-switches are set now |
561 |
;; (buffer-local), so we can call dired-readin: |
;; (buffer-local), so we can call dired-readin: |
562 |
(let ((failed t)) |
(let ((failed t)) |
563 |
(unwind-protect |
(unwind-protect |
564 |
(progn (dired-readin dir-or-list buffer) |
(progn (dired-readin) |
565 |
(setq failed nil)) |
(setq failed nil)) |
566 |
;; dired-readin can fail if parent directories are inaccessible. |
;; dired-readin can fail if parent directories are inaccessible. |
567 |
;; Don't leave an empty buffer around in that case. |
;; Don't leave an empty buffer around in that case. |
568 |
(if failed (kill-buffer buffer)))) |
(if failed (kill-buffer buffer)))) |
|
;; No need to narrow since the whole buffer contains just |
|
|
;; dired-readin's output, nothing else. The hook can |
|
|
;; successfully use dired functions (e.g. dired-get-filename) |
|
|
;; as the subdir-alist has been built in dired-readin. |
|
|
(run-hooks 'dired-after-readin-hook) |
|
569 |
(goto-char (point-min)) |
(goto-char (point-min)) |
570 |
(dired-initial-position dirname)) |
(dired-initial-position dirname)) |
571 |
(set-buffer old-buf) |
(set-buffer old-buf) |
581 |
;; This differs from dired-buffers-for-dir in that it does not consider |
;; This differs from dired-buffers-for-dir in that it does not consider |
582 |
;; subdirs of default-directory and searches for the first match only. |
;; subdirs of default-directory and searches for the first match only. |
583 |
;; Also, the major mode must be MODE. |
;; Also, the major mode must be MODE. |
584 |
|
(setq dirname (expand-file-name dirname)) |
585 |
(let (found (blist dired-buffers)) ; was (buffer-list) |
(let (found (blist dired-buffers)) ; was (buffer-list) |
586 |
(or mode (setq mode 'dired-mode)) |
(or mode (setq mode 'dired-mode)) |
587 |
(while blist |
(while blist |
590 |
(save-excursion |
(save-excursion |
591 |
(set-buffer (cdr (car blist))) |
(set-buffer (cdr (car blist))) |
592 |
(if (and (eq major-mode mode) |
(if (and (eq major-mode mode) |
593 |
(if (consp dired-directory) |
dired-directory ;; nil during find-alternate-file |
594 |
(equal (car dired-directory) dirname) |
(equal dirname |
595 |
(equal dired-directory dirname))) |
(expand-file-name |
596 |
|
(if (consp dired-directory) |
597 |
|
(car dired-directory) |
598 |
|
dired-directory)))) |
599 |
(setq found (cdr (car blist)) |
(setq found (cdr (car blist)) |
600 |
blist nil) |
blist nil) |
601 |
(setq blist (cdr blist)))))) |
(setq blist (cdr blist)))))) |
607 |
;; dired-readin differs from dired-insert-subdir in that it accepts |
;; dired-readin differs from dired-insert-subdir in that it accepts |
608 |
;; wildcards, erases the buffer, and builds the subdir-alist anew |
;; wildcards, erases the buffer, and builds the subdir-alist anew |
609 |
;; (including making it buffer-local and clearing it first). |
;; (including making it buffer-local and clearing it first). |
610 |
(defun dired-readin (dir-or-list buffer) |
(defun dired-readin () |
611 |
;; default-directory and dired-actual-switches must be buffer-local |
;; default-directory and dired-actual-switches must be buffer-local |
612 |
;; and initialized by now. |
;; and initialized by now. |
613 |
;; Thus we can test (equal default-directory dirname) instead of |
(let (dirname) |
614 |
;; (file-directory-p dirname) and save a filesystem transaction. |
(if (consp dired-directory) |
615 |
;; Also, we can run this hook which may want to modify the switches |
(setq dirname (car dired-directory)) |
616 |
;; based on default-directory, e.g. with ange-ftp to a SysV host |
(setq dirname dired-directory)) |
|
;; where ls won't understand -Al switches. |
|
|
(let (dirname |
|
|
(indent-tabs-mode nil)) |
|
|
(if (consp dir-or-list) |
|
|
(setq dirname (car dir-or-list)) |
|
|
(setq dirname dir-or-list)) |
|
617 |
(setq dirname (expand-file-name dirname)) |
(setq dirname (expand-file-name dirname)) |
|
(if (consp dir-or-list) |
|
|
(setq dir-or-list (cons dirname (cdr dir-or-list)))) |
|
|
(run-hooks 'dired-before-readin-hook) |
|
618 |
(save-excursion |
(save-excursion |
619 |
|
;; This hook which may want to modify dired-actual-switches |
620 |
|
;; based on dired-directory, e.g. with ange-ftp to a SysV host |
621 |
|
;; where ls won't understand -Al switches. |
622 |
|
(run-hooks 'dired-before-readin-hook) |
623 |
(message "Reading directory %s..." dirname) |
(message "Reading directory %s..." dirname) |
624 |
(set-buffer buffer) |
(if (consp buffer-undo-list) |
625 |
(let (buffer-read-only (failed t)) |
(setq buffer-undo-list nil)) |
626 |
|
(let (buffer-read-only |
627 |
|
;; Don't make undo entries for readin. |
628 |
|
(buffer-undo-list t)) |
629 |
(widen) |
(widen) |
630 |
(erase-buffer) |
(erase-buffer) |
631 |
(dired-readin-insert dir-or-list) |
(dired-readin-insert)) |
|
(indent-rigidly (point-min) (point-max) 2) |
|
|
;; We need this to make the root dir have a header line as all |
|
|
;; other subdirs have: |
|
|
(goto-char (point-min)) |
|
|
(if (not (looking-at "^ /.*:$")) |
|
|
(dired-insert-headerline default-directory)) |
|
|
;; can't run dired-after-readin-hook here, it may depend on the subdir |
|
|
;; alist to be OK. |
|
|
) |
|
632 |
(message "Reading directory %s...done" dirname) |
(message "Reading directory %s...done" dirname) |
633 |
|
(goto-char (point-min)) |
634 |
;; Must first make alist buffer local and set it to nil because |
;; Must first make alist buffer local and set it to nil because |
635 |
;; dired-build-subdir-alist will call dired-clear-alist first |
;; dired-build-subdir-alist will call dired-clear-alist first |
636 |
(set (make-local-variable 'dired-subdir-alist) nil) |
(set (make-local-variable 'dired-subdir-alist) nil) |
638 |
(let ((attributes (file-attributes dirname))) |
(let ((attributes (file-attributes dirname))) |
639 |
(if (eq (car attributes) t) |
(if (eq (car attributes) t) |
640 |
(set-visited-file-modtime (nth 5 attributes)))) |
(set-visited-file-modtime (nth 5 attributes)))) |
641 |
(if (consp buffer-undo-list) |
(set-buffer-modified-p nil) |
642 |
(setq buffer-undo-list nil)) |
;; No need to narrow since the whole buffer contains just |
643 |
(set-buffer-modified-p nil)))) |
;; dired-readin's output, nothing else. The hook can |
644 |
|
;; successfully use dired functions (e.g. dired-get-filename) |
645 |
|
;; as the subdir-alist has been built in dired-readin. |
646 |
|
(run-hooks 'dired-after-readin-hook)))) |
647 |
|
|
648 |
;; Subroutines of dired-readin |
;; Subroutines of dired-readin |
649 |
|
|
650 |
(defun dired-readin-insert (dir-or-list) |
(defun dired-readin-insert () |
651 |
;; Just insert listing for the passed-in directory or |
;; Insert listing for the specified dir (and maybe file list) |
652 |
;; directory-and-file list, assuming a clean buffer. |
;; already in dired-directory, assuming a clean buffer. |
653 |
(let (dirname) |
(let (dir file-list) |
654 |
(if (consp dir-or-list) |
(if (consp dired-directory) |
655 |
(setq dirname (car dir-or-list)) |
(setq dir (car dired-directory) |
656 |
(setq dirname dir-or-list)) |
file-list (cdr dired-directory)) |
657 |
;; Expand before comparing in case one or both have been abbreviated. |
(setq dir dired-directory |
658 |
(if (and (equal (expand-file-name default-directory) |
file-list nil)) |
659 |
(expand-file-name dirname)) |
(setq dir (expand-file-name dir)) |
660 |
(not (consp dir-or-list))) |
(if (and (equal "" (file-name-nondirectory dir)) |
661 |
|
(not file-list)) |
662 |
;; If we are reading a whole single directory... |
;; If we are reading a whole single directory... |
663 |
(dired-insert-directory dir-or-list dired-actual-switches nil t) |
(dired-insert-directory dir dired-actual-switches nil nil t) |
664 |
(if (not (file-readable-p |
(if (not (file-readable-p |
665 |
(directory-file-name (file-name-directory dirname)))) |
(directory-file-name (file-name-directory dir)))) |
666 |
(error "Directory %s inaccessible or nonexistent" dirname) |
(error "Directory %s inaccessible or nonexistent" dir) |
667 |
;; Else assume it contains wildcards, |
;; Else treat it as a wildcard spec |
668 |
;; unless it is an explicit list of files. |
;; unless we have an explicit list of files. |
669 |
(dired-insert-directory dir-or-list dired-actual-switches |
(dired-insert-directory dir dired-actual-switches |
670 |
(not (listp dir-or-list))) |
file-list (not file-list) t))))) |
671 |
(or (consp dir-or-list) |
|
672 |
(save-excursion ;; insert wildcard instead of total line: |
(defun dired-insert-directory (dir switches &optional file-list wildcard hdr) |
673 |
(goto-char (point-min)) |
"Insert a directory listing of DIR, Dired style. |
674 |
(insert "wildcard " (file-name-nondirectory dirname) "\n"))))))) |
Use SWITCHES to make the listings. |
675 |
|
If FILE-LIST is non-nil, list only those files. |
676 |
(defun dired-insert-directory (dir-or-list switches &optional wildcard full-p) |
Otherwise, if WILDCARD is non-nil, expand wildcards; |
677 |
;; Do the right thing whether dir-or-list is atomic or not. If it is, |
in that case, DIR should be a file name that uses wildcards. |
678 |
;; inset all files listed in the cdr (the car is the passed-in directory |
In other cases, DIR should be a directory name or a directory filename. |
679 |
;; list). |
If HDR is non-nil, insert a header line with the directory name." |
680 |
(let ((opoint (point)) |
(let ((opoint (point)) |
681 |
(process-environment (copy-sequence process-environment)) |
(process-environment (copy-sequence process-environment)) |
682 |
end) |
end) |
683 |
|
(if (or dired-use-ls-dired (file-remote-p dir)) |
684 |
|
(setq switches (concat "--dired " switches))) |
685 |
;; We used to specify the C locale here, to force English month names; |
;; We used to specify the C locale here, to force English month names; |
686 |
;; but this should not be necessary any more, |
;; but this should not be necessary any more, |
687 |
;; with the new value of dired-move-to-filename-regexp. |
;; with the new value of dired-move-to-filename-regexp. |
688 |
(if (consp dir-or-list) |
(if file-list |
689 |
;; In this case, use the file names in the cdr |
(dolist (f file-list) |
690 |
;; exactly as originally given to dired-noselect. |
(insert-directory f switches nil nil)) |
691 |
(mapcar |
(insert-directory dir switches wildcard (not wildcard))) |
|
(function (lambda (x) (insert-directory x switches wildcard full-p))) |
|
|
(cdr dir-or-list)) |
|
|
;; Expand the file name here because it may have been abbreviated |
|
|
;; in dired-noselect. |
|
|
(insert-directory (expand-file-name dir-or-list) switches wildcard full-p)) |
|
692 |
;; Quote certain characters, unless ls quoted them for us. |
;; Quote certain characters, unless ls quoted them for us. |
693 |
(if (not (string-match "b" dired-actual-switches)) |
(if (not (string-match "b" dired-actual-switches)) |
694 |
(save-excursion |
(save-excursion |
695 |
(setq end (point-marker)) |
(setq end (point-marker)) |
696 |
(goto-char opoint) |
(goto-char opoint) |
697 |
(while (search-forward "\\" end t) |
(while (search-forward "\\" end t) |
698 |
(replace-match "\\\\" nil t)) |
(replace-match (apply #'propertize |
699 |
|
"\\\\" |
700 |
|
(text-properties-at (match-beginning 0))) |
701 |
|
nil t)) |
702 |
(goto-char opoint) |
(goto-char opoint) |
703 |
(while (search-forward "\^m" end t) |
(while (search-forward "\^m" end t) |
704 |
(replace-match "\\015" nil t)) |
(replace-match (apply #'propertize |
705 |
|
"\\015" |
706 |
|
(text-properties-at (match-beginning 0))) |
707 |
|
nil t)) |
708 |
(set-marker end nil))) |
(set-marker end nil))) |
709 |
(dired-insert-set-properties opoint (point))) |
(dired-insert-set-properties opoint (point)) |
710 |
(setq dired-directory dir-or-list)) |
;; If we used --dired and it worked, the lines are already indented. |
711 |
|
;; Otherwise, indent them. |
712 |
|
(unless (save-excursion |
713 |
|
(goto-char opoint) |
714 |
|
(looking-at " ")) |
715 |
|
(let ((indent-tabs-mode nil)) |
716 |
|
(indent-rigidly opoint (point) 2))) |
717 |
|
;; Insert text at the beginning to standardize things. |
718 |
|
(save-excursion |
719 |
|
(goto-char opoint) |
720 |
|
(if (and (or hdr wildcard) (not (looking-at "^ /.*:$"))) |
721 |
|
;; Note that dired-build-subdir-alist will replace the name |
722 |
|
;; by its expansion, so it does not matter whether what we insert |
723 |
|
;; here is fully expanded, but it should be absolute. |
724 |
|
(insert " " (directory-file-name (file-name-directory dir)) ":\n")) |
725 |
|
(when wildcard |
726 |
|
;; Insert "wildcard" line where "total" line would be for a full dir. |
727 |
|
(insert " wildcard " (file-name-nondirectory dir) "\n"))))) |
728 |
|
|
729 |
;; Make the file names highlight when the mouse is on them. |
;; Make the file names highlight when the mouse is on them. |
730 |
(defun dired-insert-set-properties (beg end) |
(defun dired-insert-set-properties (beg end) |
742 |
help-echo "mouse-2: visit this file in other window"))) |
help-echo "mouse-2: visit this file in other window"))) |
743 |
(error nil)) |
(error nil)) |
744 |
(forward-line 1)))) |
(forward-line 1)))) |
|
|
|
|
(defun dired-insert-headerline (dir);; also used by dired-insert-subdir |
|
|
;; Insert DIR's headerline with no trailing slash, exactly like ls |
|
|
;; would, and put cursor where dired-build-subdir-alist puts subdir |
|
|
;; boundaries. |
|
|
(save-excursion (insert " " (directory-file-name dir) ":\n"))) |
|
|
|
|
745 |
|
|
746 |
;; Reverting a dired buffer |
;; Reverting a dired buffer |
747 |
|
|
764 |
;; treat top level dir extra (it may contain wildcards) |
;; treat top level dir extra (it may contain wildcards) |
765 |
(dired-uncache |
(dired-uncache |
766 |
(if (consp dired-directory) (car dired-directory) dired-directory)) |
(if (consp dired-directory) (car dired-directory) dired-directory)) |
767 |
(dired-readin dired-directory (current-buffer)) |
(dired-readin) |
768 |
(let ((dired-after-readin-hook nil)) |
(let ((dired-after-readin-hook nil)) |
769 |
;; don't run that hook for each subdir... |
;; don't run that hook for each subdir... |
770 |
(dired-insert-old-subdirs old-subdir-alist)) |
(dired-insert-old-subdirs old-subdir-alist)) |
1369 |
(interactive) |
(interactive) |
1370 |
(set-buffer-modified-p nil) |
(set-buffer-modified-p nil) |
1371 |
(find-alternate-file (dired-get-file-for-visit))) |
(find-alternate-file (dired-get-file-for-visit))) |
1372 |
|
;; Don't override the setting from .emacs. |
1373 |
|
;;;###autoload (put 'dired-find-alternate-file 'disabled t) |
1374 |
|
|
1375 |
(defun dired-mouse-find-file-other-window (event) |
(defun dired-mouse-find-file-other-window (event) |
1376 |
"In Dired, visit the file or directory name you click on." |
"In Dired, visit the file or directory name you click on." |
1417 |
(if (string-match (car elt) file) |
(if (string-match (car elt) file) |
1418 |
(setq cmd (cdr elt)))) |
(setq cmd (cdr elt)))) |
1419 |
(if cmd |
(if cmd |
1420 |
(dired-run-shell-command (concat cmd " " file)) |
(dired-run-shell-command (concat cmd " " |
1421 |
|
(shell-quote-argument file))) |
1422 |
(view-file file)))))) |
(view-file file)))))) |
1423 |
|
|
1424 |
(defun dired-find-file-other-window () |
(defun dired-find-file-other-window () |
1457 |
(setq file |
(setq file |
1458 |
(read |
(read |
1459 |
(concat "\"" |
(concat "\"" |
1460 |
;; some ls -b don't escape quotes, argh! |
;; Some ls -b don't escape quotes, argh! |
1461 |
;; This is not needed for GNU ls, though. |
;; This is not needed for GNU ls, though. |
1462 |
(or (dired-string-replace-match |
(or (dired-string-replace-match |
1463 |
"\\([^\\]\\|\\`\\)\"" file "\\1\\\\\"" nil t) |
"\\([^\\]\\|\\`\\)\"" file "\\1\\\\\"" nil t) |
1464 |
file) |
file) |
1465 |
"\""))))) |
"\""))) |
1466 |
|
;; The above `read' will return a unibyte string if FILE |
1467 |
|
;; contains eight-bit-control/graphic characters. |
1468 |
|
(if (and enable-multibyte-characters |
1469 |
|
(not (multibyte-string-p file))) |
1470 |
|
(setq file (string-to-multibyte file))))) |
1471 |
(and file (file-name-absolute-p file) |
(and file (file-name-absolute-p file) |
1472 |
;; A relative file name can start with ~. |
;; A relative file name can start with ~. |
1473 |
;; Don't treat it as absolute in this context. |
;; Don't treat it as absolute in this context. |
1474 |
(not (eq (aref file 0) ?~)) |
(not (eq (aref file 0) ?~)) |
1475 |
(setq already-absolute t)) |
(setq already-absolute t)) |
|
(and file buffer-file-coding-system |
|
|
(not file-name-coding-system) |
|
|
(not default-file-name-coding-system) |
|
|
(setq file (encode-coding-string file buffer-file-coding-system))) |
|
1476 |
(cond |
(cond |
1477 |
((null file) |
((null file) |
1478 |
nil) |
nil) |
1481 |
((and (eq localp 'no-dir) already-absolute) |
((and (eq localp 'no-dir) already-absolute) |
1482 |
(file-name-nondirectory file)) |
(file-name-nondirectory file)) |
1483 |
(already-absolute |
(already-absolute |
1484 |
(if (find-file-name-handler file nil) |
(let ((handler (find-file-name-handler file nil))) |
1485 |
(concat "/:" file) |
;; check for safe-magic property so that we won't |
1486 |
file)) |
;; put /: for names that don't really need them. |
1487 |
|
;; For instance, .gz files when auto-compression-mode is on. |
1488 |
|
(if (and handler (not (get handler 'safe-magic))) |
1489 |
|
(concat "/:" file) |
1490 |
|
file))) |
1491 |
((eq localp 'no-dir) |
((eq localp 'no-dir) |
1492 |
file) |
file) |
1493 |
((equal (dired-current-directory) "/") |
((equal (dired-current-directory) "/") |
1494 |
(setq file (concat (dired-current-directory localp) file)) |
(setq file (concat (dired-current-directory localp) file)) |
1495 |
(if (find-file-name-handler file nil) |
(let ((handler (find-file-name-handler file nil))) |
1496 |
(concat "/:" file) |
;; check for safe-magic property so that we won't |
1497 |
file)) |
;; put /: for names that don't really need them. |
1498 |
|
;; For instance, .gz files when auto-compression-mode is on. |
1499 |
|
(if (and handler (not (get handler 'safe-magic))) |
1500 |
|
(concat "/:" file) |
1501 |
|
file))) |
1502 |
(t |
(t |
1503 |
(concat (dired-current-directory localp) file))))) |
(concat (dired-current-directory localp) file))))) |
1504 |
|
|
1520 |
(replace-match newtext t literal string)))) |
(replace-match newtext t literal string)))) |
1521 |
|
|
1522 |
(defun dired-make-absolute (file &optional dir) |
(defun dired-make-absolute (file &optional dir) |
1523 |
;;"Convert FILE (a pathname relative to DIR) to an absolute pathname." |
;;"Convert FILE (a file name relative to DIR) to an absolute file name." |
1524 |
;; We can't always use expand-file-name as this would get rid of `.' |
;; We can't always use expand-file-name as this would get rid of `.' |
1525 |
;; or expand in / instead default-directory if DIR=="". |
;; or expand in / instead default-directory if DIR=="". |
1526 |
;; This should be good enough for ange-ftp, but might easily be |
;; This should be good enough for ange-ftp, but might easily be |
1574 |
;; The "[0-9]" below requires the previous column to end in a digit. |
;; The "[0-9]" below requires the previous column to end in a digit. |
1575 |
;; This avoids recognizing `1 may 1997' as a date in the line: |
;; This avoids recognizing `1 may 1997' as a date in the line: |
1576 |
;; -r--r--r-- 1 may 1997 1168 Oct 19 16:49 README |
;; -r--r--r-- 1 may 1997 1168 Oct 19 16:49 README |
1577 |
;; The "[kMGTPEZY]?" below supports "ls -alh" output. |
;; The "[kKMGTPEZY]?" below supports "ls -alh" output. |
1578 |
;; The ".*" below finds the last match if there are multiple matches. |
;; The ".*" below finds the last match if there are multiple matches. |
1579 |
;; This avoids recognizing `jservice 10 1024' as a date in the line: |
;; This avoids recognizing `jservice 10 1024' as a date in the line: |
1580 |
;; drwxr-xr-x 3 jservice 10 1024 Jul 2 1997 esg-host |
;; drwxr-xr-x 3 jservice 10 1024 Jul 2 1997 esg-host |
1581 |
(concat ".*[0-9][kMGTPEZY]?" s |
(concat ".*[0-9][kKMGTPEZY]?" s |
1582 |
"\\(" western "\\|" western-comma "\\|" japanese "\\|" iso "\\)" |
"\\(" western "\\|" western-comma "\\|" japanese "\\|" iso "\\)" |
1583 |
s "+")) |
s "+")) |
1584 |
"Regular expression to match up to the file name in a directory listing. |
"Regular expression to match up to the file name in a directory listing. |
1593 |
;; Returns position (point) or nil if no filename on this line." |
;; Returns position (point) or nil if no filename on this line." |
1594 |
(defun dired-move-to-filename (&optional raise-error eol) |
(defun dired-move-to-filename (&optional raise-error eol) |
1595 |
;; This is the UNIX version. |
;; This is the UNIX version. |
1596 |
(or eol (setq eol (progn (end-of-line) (point)))) |
(or eol (setq eol (line-end-position))) |
1597 |
(beginning-of-line) |
(beginning-of-line) |
1598 |
(if (re-search-forward dired-move-to-filename-regexp eol t) |
;; First try assuming `ls --dired' was used. |
1599 |
(goto-char (match-end 0)) |
(let ((change (next-single-property-change (point) 'dired-filename nil eol))) |
1600 |
(if raise-error |
(cond |
1601 |
(error "No file on this line")))) |
((and change (< change eol)) |
1602 |
|
(goto-char change)) |
1603 |
|
((re-search-forward dired-move-to-filename-regexp eol t) |
1604 |
|
(goto-char (match-end 0))) |
1605 |
|
((re-search-forward dired-permission-flags-regexp eol t) |
1606 |
|
;; Ha! There *is* a file. Our regexp-from-hell just failed to find it. |
1607 |
|
(funcall (if raise-error 'error 'message) |
1608 |
|
"Unrecognized line! Check dired-move-to-filename-regexp")) |
1609 |
|
(raise-error |
1610 |
|
(error "No file on this line"))))) |
1611 |
|
|
1612 |
(defun dired-move-to-end-of-filename (&optional no-error) |
(defun dired-move-to-end-of-filename (&optional no-error) |
1613 |
;; Assumes point is at beginning of filename, |
;; Assumes point is at beginning of filename, |
1616 |
;; (dired-move-to-filename t). |
;; (dired-move-to-filename t). |
1617 |
;; On failure, signals an error (with non-nil NO-ERROR just returns nil). |
;; On failure, signals an error (with non-nil NO-ERROR just returns nil). |
1618 |
;; This is the UNIX version. |
;; This is the UNIX version. |
1619 |
(let (opoint file-type executable symlink hidden case-fold-search used-F eol) |
(if (get-text-property (point) 'dired-filename) |
1620 |
;; case-fold-search is nil now, so we can test for capital F: |
(goto-char (next-single-property-change (point) 'dired-filename)) |
1621 |
(setq used-F (string-match "F" dired-actual-switches) |
(let (opoint file-type executable symlink hidden case-fold-search used-F eol) |
1622 |
opoint (point) |
;; case-fold-search is nil now, so we can test for capital F: |
1623 |
eol (save-excursion (end-of-line) (point)) |
(setq used-F (string-match "F" dired-actual-switches) |
1624 |
hidden (and selective-display |
opoint (point) |
1625 |
(save-excursion (search-forward "\r" eol t)))) |
eol (save-excursion (end-of-line) (point)) |
1626 |
(if hidden |
hidden (and selective-display |
1627 |
nil |
(save-excursion (search-forward "\r" eol t)))) |
1628 |
(save-excursion;; Find out what kind of file this is: |
(if hidden |
1629 |
;; Restrict perm bits to be non-blank, |
nil |
1630 |
;; otherwise this matches one char to early (looking backward): |
(save-excursion ;; Find out what kind of file this is: |
1631 |
;; "l---------" (some systems make symlinks that way) |
;; Restrict perm bits to be non-blank, |
1632 |
;; "----------" (plain file with zero perms) |
;; otherwise this matches one char to early (looking backward): |
1633 |
(if (re-search-backward |
;; "l---------" (some systems make symlinks that way) |
1634 |
dired-permission-flags-regexp nil t) |
;; "----------" (plain file with zero perms) |
1635 |
(setq file-type (char-after (match-beginning 1)) |
(if (re-search-backward |
1636 |
symlink (eq file-type ?l) |
dired-permission-flags-regexp nil t) |
1637 |
;; Only with -F we need to know whether it's an executable |
(setq file-type (char-after (match-beginning 1)) |
1638 |
executable (and |
symlink (eq file-type ?l) |
1639 |
used-F |
;; Only with -F we need to know whether it's an executable |
1640 |
(string-match |
executable (and |
1641 |
"[xst]";; execute bit set anywhere? |
used-F |
1642 |
(concat |
(string-match |
1643 |
(buffer-substring (match-beginning 2) |
"[xst]" ;; execute bit set anywhere? |
1644 |
(match-end 2)) |
(concat |
1645 |
(buffer-substring (match-beginning 3) |
(buffer-substring (match-beginning 2) |
1646 |
(match-end 3)) |
(match-end 2)) |
1647 |
(buffer-substring (match-beginning 4) |
(buffer-substring (match-beginning 3) |
1648 |
(match-end 4)))))) |
(match-end 3)) |
1649 |
(or no-error (error "No file on this line")))) |
(buffer-substring (match-beginning 4) |
1650 |
;; Move point to end of name: |
(match-end 4)))))) |
1651 |
(if symlink |
(or no-error (error "No file on this line")))) |
1652 |
(if (search-forward " ->" eol t) |
;; Move point to end of name: |
1653 |
(progn |
(if symlink |
1654 |
(forward-char -3) |
(if (search-forward " ->" eol t) |
1655 |
(and used-F |
(progn |
1656 |
dired-ls-F-marks-symlinks |
(forward-char -3) |
1657 |
(eq (preceding-char) ?@);; did ls really mark the link? |
(and used-F |
1658 |
(forward-char -1)))) |
dired-ls-F-marks-symlinks |
1659 |
(goto-char eol);; else not a symbolic link |
(eq (preceding-char) ?@) ;; did ls really mark the link? |
1660 |
;; ls -lF marks dirs, sockets and executables with exactly one |
(forward-char -1)))) |
1661 |
;; trailing character. (Executable bits on symlinks ain't mean |
(goto-char eol) ;; else not a symbolic link |
1662 |
;; a thing, even to ls, but we know it's not a symlink.) |
;; ls -lF marks dirs, sockets and executables with exactly one |
1663 |
(and used-F |
;; trailing character. (Executable bits on symlinks ain't mean |
1664 |
(or (memq file-type '(?d ?s)) |
;; a thing, even to ls, but we know it's not a symlink.) |
1665 |
executable) |
(and used-F |
1666 |
(forward-char -1)))) |
(or (memq file-type '(?d ?s)) |
1667 |
(or no-error |
executable) |
1668 |
(not (eq opoint (point))) |
(forward-char -1)))) |
1669 |
(error (if hidden |
(or no-error |
1670 |
(substitute-command-keys |
(not (eq opoint (point))) |
1671 |
"File line is hidden, type \\[dired-hide-subdir] to unhide") |
(error (if hidden |
1672 |
"No file on this line"))) |
(substitute-command-keys |
1673 |
(if (eq opoint (point)) |
"File line is hidden, type \\[dired-hide-subdir] to unhide") |
1674 |
nil |
"No file on this line"))) |
1675 |
(point)))) |
(if (eq opoint (point)) |
1676 |
|
nil |
1677 |
|
(point))))) |
1678 |
|
|
1679 |
|
|
1680 |
;;; COPY NAMES OF MARKED FILES INTO KILL-RING. |
;;; COPY NAMES OF MARKED FILES INTO KILL-RING. |
1682 |
(defun dired-copy-filename-as-kill (&optional arg) |
(defun dired-copy-filename-as-kill (&optional arg) |
1683 |
"Copy names of marked (or next ARG) files into the kill ring. |
"Copy names of marked (or next ARG) files into the kill ring. |
1684 |
The names are separated by a space. |
The names are separated by a space. |
1685 |
With a zero prefix arg, use the complete pathname of each marked file. |
With a zero prefix arg, use the absolute file name of each marked file. |
1686 |
With \\[universal-argument], use the relative pathname of each marked file. |
With \\[universal-argument], use the file name sans directory of each marked file. |
1687 |
|
|
1688 |
If on a subdir headerline, use subdirname instead; prefix arg is ignored |
If on a subdir headerline, use subdirname instead; prefix arg is ignored |
1689 |
in this case. |
in this case. |
1772 |
(substring pattern matched-in-pattern)) |
(substring pattern matched-in-pattern)) |
1773 |
"\\'"))) |
"\\'"))) |
1774 |
|
|
1775 |
|
|
1776 |
|
|
1777 |
(defun dired-advertise () |
(defun dired-advertise () |
1778 |
;;"Advertise in variable `dired-buffers' that we dired `default-directory'." |
;;"Advertise in variable `dired-buffers' that we dired `default-directory'." |
1802 |
(string-match (concat "^" (regexp-quote dir)) file))) |
(string-match (concat "^" (regexp-quote dir)) file))) |
1803 |
|
|
1804 |
(defun dired-normalize-subdir (dir) |
(defun dired-normalize-subdir (dir) |
1805 |
;; Prepend default-directory to DIR if relative path name. |
;; Prepend default-directory to DIR if relative file name. |
1806 |
;; dired-get-filename must be able to make a valid filename from a |
;; dired-get-filename must be able to make a valid file name from a |
1807 |
;; file and its directory DIR. |
;; file and its directory DIR. |
1808 |
(file-name-as-directory |
(file-name-as-directory |
1809 |
(if (file-name-absolute-p dir) |
(if (file-name-absolute-p dir) |
1947 |
(defun dired-goto-file (file) |
(defun dired-goto-file (file) |
1948 |
"Go to file line of FILE in this dired buffer." |
"Go to file line of FILE in this dired buffer." |
1949 |
;; Return value of point on success, else nil. |
;; Return value of point on success, else nil. |
1950 |
;; FILE must be an absolute pathname. |
;; FILE must be an absolute file name. |
1951 |
;; Loses if FILE contains control chars like "\007" for which ls |
;; Loses if FILE contains control chars like "\007" for which ls |
1952 |
;; either inserts "?" or "\\007" into the buffer, so we won't find |
;; either inserts "?" or "\\007" into the buffer, so we won't find |
1953 |
;; it in the buffer. |
;; it in the buffer. |
1960 |
(setq file (directory-file-name file)) ; does no harm if no directory |
(setq file (directory-file-name file)) ; does no harm if no directory |
1961 |
(let (found case-fold-search dir) |
(let (found case-fold-search dir) |
1962 |
(setq dir (or (file-name-directory file) |
(setq dir (or (file-name-directory file) |
1963 |
(error "Need absolute pathname for %s" file))) |
(error "File name `%s' is not absolute" file))) |
1964 |
(save-excursion |
(save-excursion |
1965 |
;; The hair here is to get the result of dired-goto-subdir |
;; The hair here is to get the result of dired-goto-subdir |
1966 |
;; without really calling it if we don't have any subdirs. |
;; without really calling it if we don't have any subdirs. |
1969 |
(and (cdr dired-subdir-alist) |
(and (cdr dired-subdir-alist) |
1970 |
(dired-goto-subdir dir))) |
(dired-goto-subdir dir))) |
1971 |
(let ((base (file-name-nondirectory file)) |
(let ((base (file-name-nondirectory file)) |
1972 |
|
search-string |
1973 |
(boundary (dired-subdir-max))) |
(boundary (dired-subdir-max))) |
1974 |
|
(setq search-string |
1975 |
|
(replace-regexp-in-string "\^m" "\\^m" base nil t)) |
1976 |
|
(setq search-string |
1977 |
|
(replace-regexp-in-string "\\\\" "\\\\" search-string nil t)) |
1978 |
(while (and (not found) |
(while (and (not found) |
1979 |
;; filenames are preceded by SPC, this makes |
;; filenames are preceded by SPC, this makes |
1980 |
;; the search faster (e.g. for the filename "-"!). |
;; the search faster (e.g. for the filename "-"!). |
1981 |
(search-forward (concat " " base) boundary 'move)) |
(search-forward (concat " " search-string) |
1982 |
|
boundary 'move)) |
1983 |
;; Match could have BASE just as initial substring or |
;; Match could have BASE just as initial substring or |
1984 |
;; or in permission bits or date or |
;; or in permission bits or date or |
1985 |
;; not be a proper filename at all: |
;; not be a proper filename at all: |
2049 |
`top' means ask for each directory at top level, but delete its subdirectories |
`top' means ask for each directory at top level, but delete its subdirectories |
2050 |
without asking. |
without asking. |
2051 |
Anything else means ask for each directory." |
Anything else means ask for each directory." |
2052 |
:type '(choice :tag "Delete not empty directory" |
:type '(choice :tag "Delete non-empty directories" |
2053 |
(const :tag "No. Only empty directories" nil) |
(const :tag "Yes" always) |
2054 |
(const :tag "Ask for each directory" t) |
(const :tag "No--only delete empty directories" nil) |
2055 |
(const :tag "Ask for each top directory only" top)) |
(const :tag "Confirm for each directory" t) |
2056 |
|
(const :tag "Confirm for each top directory only" top)) |
2057 |
:group 'dired) |
:group 'dired) |
2058 |
|
|
2059 |
;; Match anything but `.' and `..'. |
;; Match anything but `.' and `..'. |
2060 |
(defvar dired-re-no-dot "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*") |
(defvar dired-re-no-dot "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*") |
2061 |
|
|
2062 |
;; Delete file, possibly delete a directory and all its files. |
;; Delete file, possibly delete a directory and all its files. |
2177 |
(setq success-list (cons (buffer-name buf) success-list))))) |
(setq success-list (cons (buffer-name buf) success-list))))) |
2178 |
success-list)) |
success-list)) |
2179 |
|
|
2180 |
;; Delete the entry for FILE from |
;; Delete the entry for FILE from |
2181 |
(defun dired-delete-entry (file) |
(defun dired-delete-entry (file) |
2182 |
(save-excursion |
(save-excursion |
2183 |
(and (dired-goto-file file) |
(and (dired-goto-file file) |
2264 |
`uncompress'.") |
`uncompress'.") |
2265 |
|
|
2266 |
(defun dired-mark-pop-up (bufname op-symbol files function &rest args) |
(defun dired-mark-pop-up (bufname op-symbol files function &rest args) |
2267 |
"Args BUFNAME OP-SYMBOL FILES FUNCTION &rest ARGS. |
"Return FUNCTION's result on ARGS after showing which files are marked. |
2268 |
Return FUNCTION's result on ARGS after popping up a window (in a buffer |
Displays the file names in a buffer named BUFNAME; |
2269 |
named BUFNAME, nil gives \" *Marked Files*\") showing the marked |
nil gives \" *Marked Files*\". |
2270 |
files. Uses function `dired-pop-to-buffer' to do that. |
This uses function `dired-pop-to-buffer' to do that. |
2271 |
FUNCTION should not manipulate files. |
|
2272 |
It should only read input (an argument or confirmation). |
FUNCTION should not manipulate files, just read input |
2273 |
|
(an argument or confirmation). |
2274 |
The window is not shown if there is just one file or |
The window is not shown if there is just one file or |
2275 |
OP-SYMBOL is a member of the list in `dired-no-confirm'. |
OP-SYMBOL is a member of the list in `dired-no-confirm'. |
2276 |
FILES is the list of marked files." |
FILES is the list of marked files." |
2573 |
"auto save file"))) |
"auto save file"))) |
2574 |
|
|
2575 |
(defvar dired-garbage-files-regexp |
(defvar dired-garbage-files-regexp |
2576 |
"\\.log$\\|\\.toc$\\|\\.dvi$\\|\\.bak$\\|\\.orig$\\|\\.rej$" |
(concat (regexp-opt |
2577 |
|
'(".log" ".toc" ".dvi" ".bak" ".orig" ".rej" ".aux")) |
2578 |
|
"\\'") |
2579 |
"*Regular expression to match \"garbage\" files for `dired-flag-garbage-files'.") |
"*Regular expression to match \"garbage\" files for `dired-flag-garbage-files'.") |
2580 |
|
|
2581 |
(defun dired-flag-garbage-files () |
(defun dired-flag-garbage-files () |
2635 |
|
|
2636 |
(defun dired-unmark-all-files (mark &optional arg) |
(defun dired-unmark-all-files (mark &optional arg) |
2637 |
"Remove a specific mark (or any mark) from every file. |
"Remove a specific mark (or any mark) from every file. |
2638 |
After this command, type the mark character to remove, |
After this command, type the mark character to remove, |
2639 |
or type RET to remove all marks. |
or type RET to remove all marks. |
2640 |
With prefix arg, query for each marked file. |
With prefix arg, query for each marked file. |
2641 |
Type \\[help-command] at that time for help." |
Type \\[help-command] at that time for help." |
2677 |
(progn |
(progn |
2678 |
(select-window window) |
(select-window window) |
2679 |
(goto-char (point-max)) |
(goto-char (point-max)) |
2680 |
(recenter -1)) |
(forward-line -1) |
2681 |
|
(backward-page 1) |
2682 |
|
(recenter 0)) |
2683 |
(select-window owindow))))) |
(select-window owindow))))) |
2684 |
|
|
2685 |
(defun dired-log (log &rest args) |
(defun dired-log (log &rest args) |
2686 |
;; Log a message or the contents of a buffer. |
;; Log a message or the contents of a buffer. |
2687 |
;; If LOG is a string and there are more args, it is formatted with |
;; If LOG is a string and there are more args, it is formatted with |
2688 |
;; those ARGS. Usually the LOG string ends with a \n. |
;; those ARGS. Usually the LOG string ends with a \n. |
2689 |
;; End each bunch of errors with (dired-log t): this inserts |
;; End each bunch of errors with (dired-log t): |
2690 |
;; current time and buffer, and a \f (formfeed). |
;; this inserts the current time and buffer at the start of the page, |
2691 |
|
;; and \f (formfeed) at the end. |
2692 |
(let ((obuf (current-buffer))) |
(let ((obuf (current-buffer))) |
2693 |
(unwind-protect ; want to move point |
(with-current-buffer (get-buffer-create dired-log-buffer) |
2694 |
(progn |
(goto-char (point-max)) |
2695 |
(set-buffer (get-buffer-create dired-log-buffer)) |
(let ((inhibit-read-only t)) |
2696 |
(goto-char (point-max)) |
(cond ((stringp log) |
2697 |
(let (buffer-read-only) |
(insert (if args |
2698 |
(cond ((stringp log) |
(apply (function format) log args) |
2699 |
(insert (if args |
log))) |
2700 |
(apply (function format) log args) |
((bufferp log) |
2701 |
log))) |
(insert-buffer log)) |
2702 |
((bufferp log) |
((eq t log) |
2703 |
(insert-buffer log)) |
(backward-page 1) |
2704 |
((eq t log) |
(unless (bolp) |
2705 |
(insert "\n\t" (current-time-string) |
(insert "\n")) |
2706 |
"\tBuffer `" (buffer-name obuf) "'\n\f\n"))))) |
(insert (current-time-string) |
2707 |
(set-buffer obuf)))) |
"\tBuffer `" (buffer-name obuf) "'\n") |
2708 |
|
(goto-char (point-max)) |
2709 |
|
(insert "\f\n"))))))) |
2710 |
|
|
2711 |
(defun dired-log-summary (string failures) |
(defun dired-log-summary (string failures) |
2712 |
(message (if failures "%s--type ? for details (%s)" |
(if (= (length failures) 1) |
2713 |
"%s--type ? for details") |
(message "%s" |
2714 |
string failures) |
(with-current-buffer dired-log-buffer |
2715 |
|
(goto-char (point-max)) |
2716 |
|
(backward-page 1) |
2717 |
|
(if (eolp) (forward-line 1)) |
2718 |
|
(buffer-substring (point) (point-max)))) |
2719 |
|
(message (if failures "%s--type ? for details (%s)" |
2720 |
|
"%s--type ? for details") |
2721 |
|
string failures)) |
2722 |
;; Log a summary describing a bunch of errors. |
;; Log a summary describing a bunch of errors. |
2723 |
(dired-log (concat "\n" string)) |
(dired-log (concat "\n" string "\n")) |
2724 |
(dired-log t)) |
(dired-log t)) |
2725 |
|
|
2726 |
;;; Sorting |
;;; Sorting |
2741 |
(concat "^-[^t" dired-ls-sorting-switches "]+$") |
(concat "^-[^t" dired-ls-sorting-switches "]+$") |
2742 |
"Regexp recognized by dired to set `by name' mode.") |
"Regexp recognized by dired to set `by name' mode.") |
2743 |
|
|
2744 |
|
(defvar dired-sort-inhibit nil |
2745 |
|
"Non-nil means the Dired sort command is disabled. |
2746 |
|
The idea is to set this buffer-locally in special Dired buffers.") |
2747 |
|
|
2748 |
(defun dired-sort-set-modeline () |
(defun dired-sort-set-modeline () |
2749 |
;; Set modeline display according to dired-actual-switches. |
;; Set modeline display according to dired-actual-switches. |
2750 |
;; Modeline display of "by name" or "by date" guarantees the user a |
;; Modeline display of "by name" or "by date" guarantees the user a |
2764 |
"Toggle between sort by date/name and refresh the dired buffer. |
"Toggle between sort by date/name and refresh the dired buffer. |
2765 |
With a prefix argument you can edit the current listing switches instead." |
With a prefix argument you can edit the current listing switches instead." |
2766 |
(interactive "P") |
(interactive "P") |
2767 |
|
(when dired-sort-inhibit |
2768 |
|
(error "Cannot sort this Dired buffer")) |
2769 |
(if arg |
(if arg |
2770 |
(dired-sort-other |
(dired-sort-other |
2771 |
(read-string "ls switches (must contain -l): " dired-actual-switches)) |
(read-string "ls switches (must contain -l): " dired-actual-switches)) |
2778 |
(if (string-match " " dired-actual-switches) |
(if (string-match " " dired-actual-switches) |
2779 |
;; New toggle scheme: add/remove a trailing " -t" |
;; New toggle scheme: add/remove a trailing " -t" |
2780 |
(if (string-match " -t\\'" dired-actual-switches) |
(if (string-match " -t\\'" dired-actual-switches) |
2781 |
(dired-replace-in-string " -t\\'" "" dired-actual-switches) |
(substring dired-actual-switches 0 (match-beginning 0)) |
2782 |
(concat dired-actual-switches " -t")) |
(concat dired-actual-switches " -t")) |
2783 |
;; old toggle scheme: look for some 't' switch and add/remove it |
;; old toggle scheme: look for some 't' switch and add/remove it |
2784 |
(concat |
(concat |
2995 |
what to do with it. For directions, type \\[help-command] at that time. |
what to do with it. For directions, type \\[help-command] at that time. |
2996 |
NEWNAME may contain \\=\\<n> or \\& as in `query-replace-regexp'. |
NEWNAME may contain \\=\\<n> or \\& as in `query-replace-regexp'. |
2997 |
REGEXP defaults to the last regexp used. |
REGEXP defaults to the last regexp used. |
2998 |
With a zero prefix arg, renaming by regexp affects the complete |
With a zero prefix arg, renaming by regexp affects the full file name; |
2999 |
pathname - usually only the non-directory part of file names is used |
usually only the non-directory part of file names is used and changed." |
|
and changed." |
|
3000 |
t) |
t) |
3001 |
|
|
3002 |
(autoload 'dired-do-copy-regexp "dired-aux" |
(autoload 'dired-do-copy-regexp "dired-aux" |
3079 |
(autoload 'dired-show-file-type "dired-aux" |
(autoload 'dired-show-file-type "dired-aux" |
3080 |
"Print the type of FILE, according to the `file' command. |
"Print the type of FILE, according to the `file' command. |
3081 |
If FILE is a symbolic link and the optional argument DEREF-SYMLINKS is |
If FILE is a symbolic link and the optional argument DEREF-SYMLINKS is |
3082 |
true then the type of the file linked to by FILE is printed instead." |
true then the type of the file linked to by FILE is printed instead." |
3083 |
t) |
t) |
3084 |
|
|
3085 |
(autoload 'dired-run-shell-command "dired-aux") |
(autoload 'dired-run-shell-command "dired-aux") |