annotate lisp/efs/efs-dired.el @ 116:9f59509498e1 r20-1b10

Import from CVS: tag r20-1b10
author cvs
date Mon, 13 Aug 2007 09:23:06 +0200
parents 4be1180a9e89
children 7d55a9ba150c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
3 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
4 ;; File: efs-dired.el
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
5 ;; Release: $efs release: 1.15 $
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 100
diff changeset
6 ;; Version: #Revision: 1.31 $
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
7 ;; RCS:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
8 ;; Description: Extends much of Dired to work under efs.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
9 ;; Authors: Sebastian Kremer <sk@thp.uni-koeln.de>,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
10 ;; Andy Norman <ange@hplb.hpl.hp.com>,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
11 ;; Sandy Rutherford <sandy@ibm550.sissa.it>
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
12 ;; Created: Throughout the ages.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
13 ;; Modified: Sun Nov 27 12:19:46 1994 by sandy on gandalf
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
14 ;; Language: Emacs-Lisp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
15 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
17
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
18 ;;; Provisions and requirements
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
19
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
20 (provide 'efs-dired)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
21 (require 'efs)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
22 (require 'dired)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
23 (autoload 'dired-shell-call-process "dired-shell")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
24
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
25 (defconst efs-dired-version
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
26 (concat (substring "$efs release: 1.15 $" 14 -2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
27 "/"
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 100
diff changeset
28 (substring "#Revision: 1.31 $" 11 -2)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
29
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
30 ;;;; ----------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
31 ;;;; User Configuration Variables
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
32 ;;;; ----------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
33
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
34 (defvar efs-dired-verify-modtime-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
35 "Regular expression determining on which hosts dired modtimes are checked.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
36
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
37 (defvar efs-dired-verify-anonymous-modtime nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
38 "If non-nil, dired modtimes are checked for anonymous logins.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
39
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
40 (defvar efs-remote-shell-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
41 (if (memq system-type '(hpux usg-unix-v)) ; hope that's right
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
42 "remsh"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
43 "rsh")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
44 "Remote shell used by efs.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
45
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
46 (defvar efs-remote-shell-takes-user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
47 (null (null (memq system-type '(aix-v3 hpux silicon-graphics-unix
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
48 berkeley-unix))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
49 ;; Complete? Doubt it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
50 "Set to non-nil if your remote shell command takes \"-l USER\".")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
51
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
52 ;;; Internal Variables
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
53
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
54 (make-variable-buffer-local 'dired-ls-F-marks-symlinks)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
55
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
56 ;;;; -----------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
57 ;;;; Inserting Directories into Buffers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
58 ;;;; -----------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
59
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
60 ;; The main command for inserting a directory listing in a buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
61 ;; In Emacs 19 this is in files.el, and not specifically connected to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
62 ;; dired. Since our version of it uses some dired functions, it is
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
63 ;; included here, but there is an autoload for it in efs.el.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
64
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
65 (defun efs-insert-directory (file switches &optional wildcard full-directory-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
66 nowait marker-char)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
67 ;; Inserts a remote directory. Can do this asynch.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
68 (let* ((parsed (efs-ftp-path file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
69 (mk (point-marker))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
70 (host (car parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
71 (user (nth 1 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
72 (path (nth 2 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
73 (host-type (efs-host-type host))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
74 (dumb (memq host-type efs-dumb-host-types))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
75 (subdir (and (null (or full-directory-p wildcard))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
76 (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
77 (dired-current-directory)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
78 (error nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
79 (case-fold-search nil) ; for testing switches
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
80 (parse (and full-directory-p (not wildcard)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
81 (or dumb (efs-parsable-switches-p switches))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
82 ;; In case dired-omit-silent isn't defined.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
83 (dired-omit-silent (and (boundp 'dired-omit-silent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
84 dired-omit-silent)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
85
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
86 ;; Insert the listing. If it's not a wild-card, and not a full-dir,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
87 ;; then we are updating a dired-line. Do this asynch.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
88 ;; This way of doing the listing makes sure that the dired
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
89 ;; buffer is still around after the listing is obtained.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
90
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
91 (efs-ls
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
92 file switches t (if parse 'parse t) nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
93 ;; asynch, if we're inserting in a subdir. Do it nowait = 0, so
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
94 ;; updating the file line gets a high priority??
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
95 ;; Insert subdir listings NOWAIT = 0 also so 1-line
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
96 ;; updates don't toggle the mode line.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
97 (if (and subdir nowait) 0 nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
98 (efs-cont (listing) (host user file path wildcard
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
99 nowait marker-char
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
100 mk subdir parse switches dired-omit-silent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
101 ;; We pass the value of dired-omit-silent from the caller to the cont.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
102 (let ((host-type (efs-host-type host))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
103 (listing-type (efs-listing-type host user)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
104 (if (marker-buffer mk)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
105 (efs-save-buffer-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
106 (set-buffer (marker-buffer mk))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
107 ;; parsing a listing, sometimes updates info
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
108 (if (and parse (eq major-mode 'dired-mode))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
109 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
110 (setq efs-dired-host-type host-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
111 efs-dired-listing-type listing-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
112 efs-dired-listing-type-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
113 (and efs-show-host-type-in-dired
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
114 (concat " "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
115 (symbol-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
116 efs-dired-listing-type))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
117 (if (memq host-type '(bsd-unix next-unix))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
118 (setq dired-ls-F-marks-symlinks nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
119 (if (memq host-type '(sysV-unix apollo-unix))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
120 (setq dired-ls-F-marks-symlinks t)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
121 (if subdir
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
122 ;; a 1-line re-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
123 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
124 (efs-update-file-info
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
125 host-type file efs-data-buffer-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
126 (goto-char mk)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
127 (let ((new-subdir (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
128 (dired-current-directory)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
129 (error nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
130 buffer-read-only)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
131 (if (and new-subdir
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
132 (string-equal subdir new-subdir))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
133 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
134 ;; Is there an existing entry?
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
135 (if (dired-goto-file file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
136 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
137 (delete-region
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
138 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
139 (skip-chars-backward "^\n\r")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
140 (1- (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
141 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
142 (skip-chars-forward "^\n\r")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
143 (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
144 (goto-char mk)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
145 (insert listing)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
146 (save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
147 (narrow-to-region mk (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
148 (efs-dired-fixup-listing
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
149 listing-type file path switches wildcard)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
150 (efs-dired-ls-trim
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
151 listing-type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
152 ;; save-excursion loses if fixup had to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
153 ;; remove and re-add the region. Say for
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
154 ;; sorting.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
155 (goto-char (point-max)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
156 (if (and nowait (eq major-mode 'dired-mode))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
157 (dired-after-add-entry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
158 (marker-position mk)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
159 marker-char))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
160 (goto-char mk)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
161 (let (buffer-read-only)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
162 (insert listing)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
163 (save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
164 (narrow-to-region mk (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
165 (efs-dired-fixup-listing
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
166 listing-type file path switches wildcard)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
167 (goto-char (point-max))))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
168 ;; Return 0 if synch, nil if asynch
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
169 (if nowait nil 0)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
170
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
171 ;;; Functions for cleaning listings.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
172
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
173 (efs-defun efs-dired-ls-trim nil ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
174 ;; Trims dir listings, so that the listing of a single file is one line.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
175 nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
176
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
177 (efs-defun efs-dired-fixup-listing nil (file path &optional switches wildcard)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
178 ;; FILE is in efs syntax.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
179 ;; PATH is just the remote path.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
180 ;; Some ftpd's put the whole directory name in front of each filename.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
181 ;; Seems to depend in a strange way on server-client interaction.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
182 ;; Walk down the listing generated and remove this stuff.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
183 ;; SWITCHES is a string.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
184 (if (memq efs-key efs-unix-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
185 (let ((continue t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
186 spot bol)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
187 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
188 (while (and (not (eobp)) continue)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
189 (and (setq bol (point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
190 spot (dired-manual-move-to-filename nil bol))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
191 (setq continue (= (following-char) ?/))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
192 (dired-manual-move-to-end-of-filename t bol)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
193 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
194 (skip-chars-backward "^/")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
195 (delete-region spot (point))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
196 (forward-line 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
197 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
198 (if (and switches (string-match "R" switches)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
199 (not (string-match "d" switches)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
200 (let ((subdir-regexp "^\\(/[^ \n\r]+\\):[\n\r]")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
201 name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
202 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
203 (while (re-search-forward subdir-regexp nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
204 (goto-char (match-beginning 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
205 ;; There may be /./ type nonsense.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
206 ;; expand-file-name will handle it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
207 (setq name (expand-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
208 (buffer-substring (point) (match-end 0))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
209 (delete-region (point) (match-end 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
210 (insert (efs-replace-path-component file name)))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
211
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
212
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
213 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
214 ;;;; Tree Dired support
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
215 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
216
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
217 ;;; efs-dired keymap
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
218
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
219 (defvar efs-dired-map nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
220 "Keymap for efs commands in dired buffers.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
221
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
222 (if efs-dired-map
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
223 ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
224 (setq efs-dired-map (make-sparse-keymap))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
225 (define-key efs-dired-map "c" 'efs-dired-close-ftp-process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
226 (define-key efs-dired-map "k" 'efs-dired-kill-ftp-process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
227 (define-key efs-dired-map "o" 'efs-dired-display-ftp-process-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
228 (define-key efs-dired-map "p" 'efs-dired-ping-connection))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
229
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
230 (fset 'efs-dired-prefix efs-dired-map)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
231
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
232 ;;; Functions for dealing with the FTP process
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
233
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
234 (defun efs-dired-close-ftp-process ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
235 "Close the FTP process for the current dired buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
236 Closing causes the connection to be dropped, but efs will retain its
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
237 cached data for the connection. This will make it more efficient to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
238 reopen the connection."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
239 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
240 (or efs-dired-host-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
241 (error "Dired buffer is not for a remote directory."))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
242 (efs-close-ftp-process (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
243 (let ((parsed (efs-ftp-path default-directory)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
244 (message "Closed FTP connection for %s@%s." (nth 1 parsed) (car parsed))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
245
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
246 (defun efs-dired-kill-ftp-process ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
247 "Kills the FTP process for the current dired buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
248 Killing causes the connection to be closed, the process buffer to be killed,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
249 and most of efs's cached data to be wiped."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
250 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
251 (or efs-dired-host-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
252 (error "Dired buffer is not for a remote directory."))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
253 (efs-kill-ftp-process (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
254 (let ((parsed (efs-ftp-path default-directory)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
255 (message "Killed FTP connection for %s@%s." (nth 1 parsed) (car parsed))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
256
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
257 (defun efs-dired-display-ftp-process-buffer ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
258 "Displays in another window the FTP process buffer for a dired buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
259 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
260 (or efs-dired-host-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
261 (error "Dired buffer is not for a remote directory."))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
262 (efs-display-ftp-process-buffer (current-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
263
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
264 (defun efs-dired-ping-connection ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
265 "Pings FTP connection associated with current dired buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
266 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
267 (or efs-dired-host-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
268 (error "Dired buffer is not for a remote directory."))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
269 (efs-ping-ftp-connection (current-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
270
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
271
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
272 ;;; Reading in dired buffers.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
273
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
274 (defun efs-dired-revert (&optional arg noconfirm)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
275 (let ((efs-ls-uncache t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
276 (dired-revert arg noconfirm)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
277
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
278 (defun efs-dired-default-dir-function ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
279 (let* ((cd (dired-current-directory))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
280 (parsed (efs-ftp-path cd)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
281 (if parsed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
282 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
283 (let ((tail directory-abbrev-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
284 (while tail
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
285 (if (string-match (car (car tail)) cd)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
286 (setq cd (concat (cdr (car tail))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
287 (substring cd (match-end 0)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
288 parsed nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
289 (setq tail (cdr tail)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
290 (apply 'efs-unexpand-parsed-filename
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
291 (or parsed (efs-ftp-path cd)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
292 cd)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
293
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
294 (defun efs-dired-before-readin ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
295 ;; Put in the dired-before-readin-hook.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
296 (let ((parsed (efs-ftp-path default-directory)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
297 (if parsed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
298 (let ((host (car parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
299 (user (nth 1 parsed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
300 (setq efs-dired-listing-type (efs-listing-type host user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
301 efs-dired-host-type (efs-host-type host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
302 efs-dired-listing-type-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
303 (and efs-show-host-type-in-dired
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
304 (concat " " (symbol-name efs-dired-listing-type))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
305 (set (make-local-variable 'revert-buffer-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
306 (function efs-dired-revert))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
307 (set (make-local-variable 'default-directory-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
308 (function efs-dired-default-dir-function))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
309 (set (make-local-variable 'dired-verify-modtimes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
310 (null (null (and
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
311 efs-dired-verify-modtime-host-regexp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
312 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
313 (let ((case-fold-search t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
314 (string-match
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
315 efs-dired-verify-modtime-host-regexp host))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
316 (or efs-dired-verify-anonymous-modtime
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
317 (not (efs-anonymous-p user))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
318 ;; The hellsoft ftp server mixes up cases.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
319 ;; However, we may not be able to catch this until
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
320 ;; after the first directory is listed.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
321 (if (and
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
322 (eq efs-dired-host-type 'hell)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
323 (not (string-equal default-directory
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
324 (setq default-directory
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
325 (downcase default-directory)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
326 (or (string-equal (buffer-name) (downcase (buffer-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
327 (rename-buffer (generate-new-buffer-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
328 (directory-file-name default-directory)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
329 ;; Setup the executable and directory regexps
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
330 (let ((eentry (assq efs-dired-listing-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
331 efs-dired-re-exe-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
332 (dentry (assq efs-dired-listing-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
333 efs-dired-re-dir-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
334 (if eentry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
335 (set (make-local-variable 'dired-re-exe) (cdr eentry)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
336 (if dentry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
337 (set (make-local-variable 'dired-re-dir) (cdr dentry))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
338 ;; No switches are sent to dumb hosts, so don't confuse dired.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
339 ;; I hope that dired doesn't get excited if it doesn't see the l
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
340 ;; switch. If it does, then maybe fake things by setting this to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
341 ;; "-Al".
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
342 (if (eq efs-dired-listing-type 'vms)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
343 (setq dired-internal-switches
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
344 (delq ?F dired-internal-switches))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
345 (if (memq efs-dired-host-type efs-dumb-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
346 (setq dired-internal-switches '(?l ?A)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
347 ;; Don't lie on the mode line
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
348 dired-sort-mode "")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
349 ;; If the remote file system is version-based, don't set
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
350 ;; dired-kept-versions to 0. It will flag the most recent
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
351 ;; copy of the file for deletion -- this isn't really a backup.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
352 (if (memq efs-dired-host-type efs-version-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
353 (set (make-local-variable 'dired-kept-versions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
354 (max 1 dired-kept-versions)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
355
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
356 (efs-defun efs-dired-insert-headerline (&use efs-dired-listing-type) (dir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
357 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
358 (efs-real-dired-insert-headerline dir))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
359
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
360 (defun efs-dired-uncache (file dir-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
361 ;; Remove FILE from cache.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
362 (if dir-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
363 (efs-del-from-ls-cache file nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
364 (efs-del-from-ls-cache file t nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
365
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
366 ;;; Checking modtimes of directories.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
367 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
368 ;; This only runs if efs-dired-verify-anonymous-modtime and
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
369 ;; efs-verify-modtime-host-regexp turn it on. Few (any?) FTP servers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
370 ;; support getting MDTM for directories. As usual, we cache whether
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
371 ;; this works, and don't keep senselessly trying it if it doesn't.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
372
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
373 (defun efs-dired-file-modtime (file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
374 ;; Returns the modtime.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
375 (let* ((parsed (efs-ftp-path file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
376 (host (car parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
377 (user (nth 1 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
378 (rpath (nth 2 parsed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
379 (and (null (efs-get-host-property host 'dir-mdtm-failed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
380 (let ((result (efs-send-cmd host user (list 'quote 'mdtm rpath)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
381 (and (eq efs-verbose t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
382 "Getting modtime")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
383 mp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
384 (if (and (null (car result))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
385 (setq mp (efs-parse-mdtime (nth 1 result))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
386 (let ((ent (efs-get-file-entry file)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
387 (if ent
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
388 (setcdr ent (list (nth 1 ent) (nth 2 ent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
389 (nth 3 ent) (nth 4 ent) mp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
390 parsed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
391 (efs-set-host-property host 'dir-mdtm-failed t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
392 nil)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
393
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
394 (defun efs-dired-set-file-modtime (file alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
395 ;; This works asynch.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
396 (let* ((parsed (efs-ftp-path file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
397 (host (car parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
398 (user (nth 1 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
399 (path (nth 2 parsed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
400 (if (efs-get-host-property host 'dir-mdtm-failed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
401 (let ((elt (assoc file alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
402 (if elt (setcar (nthcdr 4 elt) nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
403 (efs-send-cmd
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
404 host user (list 'quote 'mdtm path) nil nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
405 (efs-cont (result line cont-lines) (file alist host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
406 (let ((elt (assoc file alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
407 modtime)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
408 (if (and (null result) (setq modtime (efs-parse-mdtime line)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
409 (if elt (setcar (nthcdr 4 elt) modtime))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
410 (if elt (setcar (nthcdr 4 elt) nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
411 (efs-set-host-property host 'dir-mdtm-failed t))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
412 0) ; Always do this NOWAIT = 0
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
413 nil))) ; return NIL
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
414
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
415 ;;; Asynch insertion of subdirs. Used when renaming subdirs.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
416
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
417 (defun efs-dired-insert-subdir (dirname &optional noerror nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
418 (let ((buff (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
419 (switches (delq ?R (copy-sequence dired-internal-switches))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
420 (efs-ls
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
421 dirname (dired-make-switches-string switches)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
422 t nil noerror nowait
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
423 (efs-cont (listing) (dirname buff switches)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
424 (if (and listing (get-buffer buff))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
425 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
426 (set-buffer buff)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
427 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
428 (let ((elt (assoc dirname dired-subdir-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
429 mark-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
430 (if elt
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
431 (setq mark-list (dired-insert-subdir-del elt))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
432 (dired-insert-subdir-newpos dirname))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
433 (dired-insert-subdir-doupdate
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
434 dirname
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
435 (efs-dired-insert-subdir-do-insert dirname listing)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
436 switches elt mark-list)))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
437
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
438 (defun efs-dired-insert-subdir-do-insert (dirname listing)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
439 (let ((begin (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
440 indent-tabs-mode end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
441 (insert listing)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
442 (setq end (point-marker))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
443 (indent-rigidly begin end 2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
444 (goto-char begin)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
445 (dired-insert-headerline dirname)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
446 ;; If the listing has null lines `quote' them so that "\n\n" delimits
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
447 ;; subdirs. This is OK, because we aren't inserting -R listings.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
448 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
449 (while (search-forward "\n\n" end t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
450 (forward-char -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
451 (insert " ")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
452 ;; point is now like in dired-build-subdir-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
453 (prog1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
454 (list begin (marker-position end))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
455 (set-marker end nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
456
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
457 ;;; Moving around in dired buffers.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
458
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
459 (efs-defun efs-dired-manual-move-to-filename (&use efs-dired-listing-type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
460 (&optional raise-error bol eol)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
461 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
462 (efs-real-dired-manual-move-to-filename raise-error bol eol))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
463
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
464 (efs-defun efs-dired-manual-move-to-end-of-filename
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
465 (&use efs-dired-listing-type) (&optional no-error bol eol)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
466 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
467 (efs-real-dired-manual-move-to-end-of-filename no-error bol eol))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
468
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
469 (efs-defun efs-dired-make-filename-string (&use efs-dired-listing-type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
470 (filename &optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
471 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
472 ;; This translates file names from the way that they are displayed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
473 ;; in listings to the way that the user gives them in the minibuffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
474 ;; For example, in CMS this should take "FOO BAR" to "FOO.BAR".
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
475 filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
476
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
477 (defun efs-dired-find-file ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
478 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
479 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
480 (find-file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
481 (if (memq efs-dired-host-type efs-version-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
482 (efs-internal-file-name-sans-versions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
483 efs-dired-host-type (dired-get-filename) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
484 (dired-get-filename))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
485
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
486 (defun efs-dired-find-file-other-window (&optional display)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
487 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
488 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
489 (if display
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
490 (dired-display-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
491 (let ((file (dired-get-filename)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
492 (if (memq efs-dired-host-type efs-version-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
493 (setq file (efs-internal-file-name-sans-versions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
494 efs-dired-host-type file t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
495 (find-file-other-window file))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
496
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
497 (defun efs-dired-display-file ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
498 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
499 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
500 (let ((file (dired-get-filename)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
501 (if (memq efs-dired-host-type efs-version-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
502 (setq file (efs-internal-file-name-sans-versions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
503 efs-dired-host-type file t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
504 (display-buffer (find-file-noselect file))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
505
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
506 (defun efs-dired-find-file-other-frame ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
507 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
508 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
509 (find-file-other-frame
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
510 (if (memq efs-dired-host-type efs-version-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
511 (efs-internal-file-name-sans-versions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
512 efs-dired-host-type (dired-get-filename) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
513 (dired-get-filename))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
514
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
515 ;;; Creating and deleting new directories.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
516
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
517 (defun efs-dired-recursive-delete-directory (fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
518 ;; Does recursive deletion of remote directories for dired.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
519 (or (file-exists-p fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
520 (signal 'file-error
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
521 (list "Removing old file name" "no such directory" fn)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
522 (efs-dired-internal-recursive-delete-directory fn))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
523
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
524 (defun efs-dired-internal-recursive-delete-directory (fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
525 (if (eq (car (file-attributes fn)) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
526 (let ((files (efs-directory-files fn)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
527 (if files
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
528 (mapcar (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
529 (lambda (ent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
530 (or (string-equal "." ent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
531 (string-equal ".." ent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
532 (efs-dired-internal-recursive-delete-directory
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
533 (expand-file-name ent fn)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
534 files))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
535 (efs-delete-directory fn))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
536 (condition-case err
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
537 (efs-delete-file fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
538 (ftp-error (if (and (nth 2 err) (stringp (nth 2 err))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
539 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
540 (string-match "^FTP Error: \"550 " (nth 2 err))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
541 (message "File %s already deleted." fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
542 (signal (car err) (cdr err)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
543
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
544 ;;; File backups and versions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
545
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
546 (efs-defun efs-dired-flag-backup-files
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
547 (&use efs-dired-host-type) (&optional unflag-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
548 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
549 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
550 (efs-real-dired-flag-backup-files unflag-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
551
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
552 (efs-defun efs-dired-collect-file-versions (&use efs-dired-host-type) ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
553 ;; If it looks like a file has versions, return a list of the versions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
554 ;; The return value is ((FILENAME . (VERSION1 VERSION2 ...)) ...)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
555 (efs-real-dired-collect-file-versions))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
556
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
557 ;;; Sorting dired buffers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
558
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
559 (defun efs-dired-file-name-lessp (name1 name2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
560 (if (and efs-dired-host-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
561 (memq efs-dired-host-type efs-case-insensitive-host-types))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
562 (string< (downcase name1) (downcase name2))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
563 (string< name1 name2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
564
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
565 ;;; Support for async file creators.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
566
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
567 (defun efs-dired-copy-file (from to ok-flag &optional cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
568 ;; Version of dired-copy-file for remote files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
569 ;; Assumes that filenames are already expanded.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
570 (dired-handle-overwrite to)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
571 (efs-copy-file-internal from (efs-ftp-path from) to (efs-ftp-path to)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
572 ok-flag dired-copy-preserve-time 0 cont nowait))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
573
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
574 (defun efs-dired-rename-file (from to ok-flag &optional cont nowait
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
575 insert-subdir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
576 ;; Version of dired-rename-file for remote files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
577 (dired-handle-overwrite to)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
578 (efs-rename-file-internal
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
579 from to ok-flag nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
580 (efs-cont (result line cont-lines) (from to cont insert-subdir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
581 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
582 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
583 (efs-call-cont cont result line cont-lines)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
584 (signal 'ftp-error
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
585 (list "Dired Renaming"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
586 (format "FTP Error: \"%s\"" line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
587 from to)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
588 (dired-remove-file from)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
589 ;; Silently rename the visited file of any buffer visiting this file.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
590 ;; We do not maintain inserted subdirs for remote
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
591 (efs-dired-rename-update-buffers from to insert-subdir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
592 (if cont (efs-call-cont cont result line cont-lines))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
593 nowait))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
594
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
595 (defun efs-dired-rename-update-buffers (from to &optional insert-subdir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
596 (if (get-file-buffer from)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
597 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
598 (set-buffer (get-file-buffer from))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
599 (let ((modflag (buffer-modified-p)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
600 (set-visited-file-name to) ; kills write-file-hooks
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
601 (set-buffer-modified-p modflag)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
602 ;; It's a directory. More work to do.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
603 (let ((blist (buffer-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
604 (from-dir (file-name-as-directory from))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
605 (to-dir (file-name-as-directory to)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
606 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
607 (while blist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
608 (set-buffer (car blist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
609 (setq blist (cdr blist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
610 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
611 (buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
612 (if (dired-in-this-tree buffer-file-name from-dir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
613 (let ((modflag (buffer-modified-p)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
614 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
615 (set-visited-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
616 (concat to-dir (substring buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
617 (length from-dir))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
618 (set-buffer-modified-p modflag)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
619 (dired-directory
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
620 (if (string-equal from-dir (expand-file-name default-directory))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
621 ;; If top level directory was renamed, lots of things
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
622 ;; have to be updated.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
623 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
624 (dired-unadvertise from-dir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
625 (setq default-directory to-dir
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
626 dired-directory
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
627 ;; Need to beware of wildcards.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
628 (expand-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
629 (file-name-nondirectory dired-directory)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
630 to-dir))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
631 (let ((new-name (file-name-nondirectory
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
632 (directory-file-name dired-directory))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
633 ;; Try to rename buffer, but just leave old name if new
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
634 ;; name would already exist (don't try appending "<%d>")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
635 ;; Why? --sandy 19-8-94
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
636 (or (get-buffer new-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
637 (rename-buffer new-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
638 (dired-advertise))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
639 (and insert-subdir
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
640 (assoc (file-name-directory (directory-file-name to))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
641 dired-subdir-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
642 (if (efs-ftp-path to)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
643 (efs-dired-insert-subdir to t 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
644 (dired-insert-subdir to)))))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
645
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
646 (defun efs-dired-make-relative-symlink (from to ok-flag &optional cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
647 ;; efs version of dired-make-relative-symlink
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
648 ;; Called as a file-name-handler when dired-make-relative-symlink is
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
649 ;; called interactively.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
650 ;; efs-dired-create-files calls it directly to supply CONT
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
651 ;; and NOWAIT args.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
652 (setq from (directory-file-name from)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
653 to (directory-file-name to))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
654 (efs-make-symbolic-link-internal
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
655 (dired-make-relative from (file-name-directory to) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
656 to ok-flag cont nowait))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
657
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
658 (defun efs-dired-create-files (file-creator operation fn-list name-constructor
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
659 &optional marker-char query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
660 implicit-to)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
661 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
662 (if (catch 'found
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
663 (let ((list fn-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
664 val)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
665 (while list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
666 (if (setq val (efs-ftp-path (car list)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
667 (throw 'found val)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
668 (if (setq val (funcall name-constructor (car list)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
669 (throw 'found (efs-ftp-path val))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
670 (setq list (cdr list)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
671 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
672 (cond ((eq file-creator 'dired-copy-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
673 (setq file-creator 'efs-dired-copy-file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
674 ((eq file-creator 'dired-rename-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
675 (setq file-creator 'efs-dired-rename-file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
676 ((eq file-creator 'make-symbolic-link)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
677 (setq file-creator 'efs-make-symbolic-link-internal))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
678 ((eq file-creator 'add-name-to-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
679 (setq file-creator 'efs-add-name-to-file-internal))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
680 ((eq file-creator 'dired-make-relative-symlink)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
681 (setq file-creator 'efs-dired-make-relative-symlink))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
682 ((eq file-creator 'dired-compress-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
683 (setq file-creator 'efs-dired-compress-file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
684 ((error "Unable to perform operation %s on remote hosts."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
685 file-creator)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
686 ;; use the process-filter driven routine rather than the iterative one.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
687 (efs-dcf-1 file-creator operation fn-list name-constructor
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
688 (if (eq marker-char t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
689 (mapcar 'dired-file-marker fn-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
690 marker-char)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
691 query (buffer-name (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
692 nil ;overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
693 nil ;dired-overwrite-backup-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
694 nil ;dired-file-creator-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
695 nil ;failures
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
696 nil ;skipped
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
697 0 ;success-count
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
698 (length fn-list) ;total
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
699 implicit-to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
700 (and (eq file-creator 'efs-dired-rename-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
701 (delq nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
702 (mapcar
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
703 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
704 (lambda (x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
705 (and (assoc (file-name-as-directory x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
706 dired-subdir-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
707 x)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
708 fn-list)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
709 ;; normal case... use the interative routine... much cheaper.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
710 (efs-real-dired-create-files file-creator operation fn-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
711 name-constructor marker-char query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
712 implicit-to)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
713
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
714 (defun efs-dcf-1 (file-creator operation fn-list name-constructor
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
715 markers query buffer-name overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
716 overwrite-backup-query file-creator-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
717 failures skipped success-count total
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
718 implicit-to insertions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
719 (if (null fn-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
720 (efs-dcf-3 failures operation total skipped
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
721 success-count buffer-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
722 (let* ((from (car fn-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
723 ;; For dired-handle-overwrite and the file-creator-query,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
724 ;; need to set these 2 fluid vars according to the cont data.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
725 (dired-overwrite-backup-query overwrite-backup-query)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
726 (dired-file-creator-query file-creator-query)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
727 (to (funcall name-constructor from))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
728 (marker-char (if (consp markers)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
729 (prog1 (car markers)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
730 (setq markers (cdr markers)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
731 markers))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
732 (fn-list (cdr fn-list)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
733 (if to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
734 (if (equal to from)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
735 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
736 (dired-log buffer-name "Cannot %s to same file: %s\n"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
737 (downcase operation) from)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
738 (efs-dcf-1 file-creator operation fn-list name-constructor
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
739 markers query buffer-name overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
740 dired-overwrite-backup-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
741 dired-file-creator-query failures
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
742 (cons (dired-make-relative from nil t) skipped)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
743 success-count total implicit-to insertions))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
744 (if (or (null query)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
745 (funcall query from to))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
746 (let* ((overwrite (let (jka-compr-enabled)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
747 ;; Don't let jka-compr fool us.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
748 (file-exists-p to)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
749 (overwrite-confirmed ; for dired-handle-overwrite
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
750 (and overwrite
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
751 (let ((help-form '(format "\
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
752 Type SPC or `y' to overwrite file `%s',
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
753 DEL or `n' to skip to next,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
754 ESC or `q' to not overwrite any of the remaining files,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
755 `!' to overwrite all remaining files with no more questions." to)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
756 (dired-query 'overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
757 "Overwrite `%s'?" to)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
758 (condition-case err
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
759 (let ((dired-unhandle-add-files
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
760 (cons to dired-unhandle-add-files)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
761 (if implicit-to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
762 (funcall file-creator from overwrite-confirmed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
763 (list (function efs-dcf-2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
764 file-creator operation fn-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
765 name-constructor markers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
766 query marker-char
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
767 buffer-name to from overwrite
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
768 overwrite-confirmed overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
769 dired-overwrite-backup-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
770 dired-file-creator-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
771 failures skipped success-count
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
772 total implicit-to insertions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
773 t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
774 (apply file-creator from to overwrite-confirmed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
775 (list (function efs-dcf-2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
776 file-creator operation fn-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
777 name-constructor markers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
778 query marker-char
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
779 buffer-name to from overwrite
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
780 overwrite-confirmed overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
781 dired-overwrite-backup-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
782 dired-file-creator-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
783 failures skipped success-count total
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
784 implicit-to insertions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
785 (if insertions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
786 (list t insertions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
787 '(t)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
788 (error ; FILE-CREATOR aborted
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
789 (efs-dcf-2 'failed ;result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
790 (format "%s" err) ;line
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
791 "" file-creator operation fn-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
792 name-constructor markers query marker-char
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
793 buffer-name to from overwrite
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
794 overwrite-confirmed overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
795 dired-overwrite-backup-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
796 dired-file-creator-query failures skipped
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
797 success-count total implicit-to insertions))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
798 (efs-dcf-1 file-creator operation fn-list name-constructor
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
799 markers query buffer-name overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
800 dired-overwrite-backup-query dired-file-creator-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
801 failures
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
802 (cons (dired-make-relative from nil t) skipped)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
803 success-count total implicit-to insertions)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
804 (efs-dcf-1 file-creator operation fn-list name-constructor
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
805 markers query buffer-name overwrite-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
806 dired-overwrite-backup-query dired-file-creator-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
807 failures (cons (dired-make-relative from nil t) skipped)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
808 success-count total implicit-to insertions)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
809
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
810 (defun efs-dcf-2 (result line cont-lines file-creator operation fn-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
811 name-constructor markers query marker-char
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
812 buffer-name to from overwrite overwrite-confirmed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
813 overwrite-query overwrite-backup-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
814 file-creator-query failures skipped success-count
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
815 total implicit-to insertions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
816 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
817 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
818 (setq failures (cons (dired-make-relative from nil t) failures))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
819 (dired-log buffer-name "%s `%s' to `%s' failed:\n%s\n"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
820 operation from to line))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
821 (setq success-count (1+ success-count))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
822 (message "%s: %d of %d" operation success-count total)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
823 (let ((efs-ls-uncache t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
824 (dired-add-file to marker-char)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
825 ;; iterate again
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
826 (efs-dcf-1 file-creator operation fn-list name-constructor
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
827 markers query buffer-name overwrite-query overwrite-backup-query
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
828 file-creator-query failures skipped success-count total
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
829 implicit-to insertions))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
830
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
831 (defun efs-dcf-3 (failures operation total skipped success-count buffer-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
832 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
833 (failures
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
834 (dired-log-summary buffer-name (format "%s failed for %d of %d file%s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
835 operation (length failures) total
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
836 (dired-plural-s total)) failures))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
837 (skipped
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
838 (dired-log-summary buffer-name (format "%s: %d of %d file%s skipped"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
839 operation (length skipped) total
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
840 (dired-plural-s total)) skipped))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
841 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
842 (message "%s: %s file%s."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
843 operation success-count
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
844 (dired-plural-s success-count)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
845
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
846 ;;; Running remote shell commands
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
847
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
848 ;;; This support isn't very good. efs is really about a virtual file system,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
849 ;;; and not remote processes. What is really required is low-level
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
850 ;;; support for start-process & call-process on remote hosts. This shouldn't
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
851 ;;; be part of efs, although.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
852
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
853 (defun efs-dired-shell-unhandle-file-name (filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
854 ;; Puts remote file names into a form where they can be passed to remsh.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
855 (nth 2 (efs-ftp-path filename)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
856
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
857 (defun efs-dired-shell-call-process (command dir &optional in-background)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
858 ;; Runs shell process on remote hosts.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
859 (let* ((parsed (efs-ftp-path dir))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
860 (host (car parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
861 (user (nth 1 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
862 (rdir (nth 2 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
863 (file-name-handler-alist nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
864 (or (string-equal (efs-internal-directory-file-name dir)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
865 (efs-expand-tilde "~" (efs-host-type host) host user))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
866 (string-match "^cd " command)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
867 (setq command (concat "cd " rdir "; " command)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
868 (setq command
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
869 (format "%s %s%s \"%s\"" ; remsh -l USER does not work well
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
870 ; on a hp-ux machine I tried
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
871 efs-remote-shell-file-name host
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
872 (if efs-remote-shell-takes-user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
873 (concat " -l " user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
874 "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
875 command))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
876 (message "Doing shell command on %s..." host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
877 (dired-shell-call-process
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
878 command (file-name-directory efs-tmp-name-template) in-background)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
879
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
880 ;;; Dired commands for running local processes on remote files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
881 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
882 ;; Lots of things in this section need to be re-thunk.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
883
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
884 (defun efs-dired-call-process (program discard &rest arguments)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
885 "Documented as original."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
886 ;; PROGRAM is always one of those below in the cond in dired.el.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
887 ;; The ARGUMENTS are (nearly) always files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
888 (if (efs-ftp-path default-directory)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
889 ;; Can't use efs-dired-host-type here because the current
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
890 ;; buffer is *dired-check-process output*
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
891 (condition-case oops
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
892 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
893 ((string-equal "efs-call-compress" program)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
894 (apply 'efs-call-compress arguments))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
895 ((string-equal "chmod" program)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
896 (efs-call-chmod arguments))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
897 (t (error "Unknown remote command: %s" program)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
898 (ftp-error (dired-log (buffer-name (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
899 (format "%s: %s, %s\n"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
900 (nth 1 oops)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
901 (nth 2 oops)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
902 (nth 3 oops))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
903 (error (dired-log (buffer-name (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
904 (format "%s\n" (nth 1 oops)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
905 (apply 'call-process program nil (not discard) nil arguments)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
906
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
907 (defun efs-dired-make-compressed-filename (name &optional method)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
908 ;; Version of dired-make-compressed-filename for efs.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
909 ;; If NAME is in the syntax of a compressed file (according to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
910 ;; dired-compression-method-alist), return the data (a list) from this
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
911 ;; alist on how to uncompress it. Otherwise, return a string, the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
912 ;; uncompressed form of this file name. This is computed using the optional
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
913 ;; argument METHOD (a symbol). If METHOD is nil, the ambient value of
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
914 ;; dired-compression-method is used.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
915 (let* ((host-type (efs-host-type (car (efs-ftp-path name))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
916 (ef-alist (if (memq host-type efs-single-extension-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
917 (mapcar
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
918 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
919 (lambda (elt)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
920 (list (car elt)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
921 (mapconcat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
922 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
923 (lambda (char)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
924 (if (= char ?.)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
925 "-"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
926 (char-to-string char))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
927 (nth 1 elt) "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
928 (nth 2 elt)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
929 (nth 3 elt))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
930 dired-compression-method-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
931 dired-compression-method-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
932 (alist ef-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
933 (len (length name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
934 ext ext-len result)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
935 (if (memq host-type efs-version-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
936 (setq name (efs-internal-file-name-sans-versions host-type name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
937 (if (memq host-type efs-case-insensitive-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
938 (let ((name (downcase name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
939 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
940 (if (and (> len
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
941 (setq ext-len (length (setq ext (nth 1 (car alist))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
942 (string-equal (downcase ext)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
943 (substring name (- ext-len))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
944 (setq result (car alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
945 alist nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
946 (setq alist (cdr alist)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
947 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
948 (if (and (> len
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
949 (setq ext-len (length (setq ext (nth 1 (car alist))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
950 (string-equal ext (substring name (- ext-len))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
951 (setq result (car alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
952 alist nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
953 (setq alist (cdr alist)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
954 (or result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
955 (concat name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
956 (nth 1 (or (assq (or method dired-compression-method)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
957 ef-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
958 (error "Unknown compression method: %s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
959 (or method dired-compression-method))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
960
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
961 (defun efs-dired-compress-file (file ok-flag &optional cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
962 ;; Version of dired-compress-file for remote files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
963 (let* ((compressed-fn (efs-dired-make-compressed-filename file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
964 (host (car (efs-ftp-path file)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
965 (host-type (efs-host-type host)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
966 (cond ((file-symlink-p file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
967 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
968 (efs-call-cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
969 cont 'failed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
970 (format "Cannot compress %s, a symbolic link." file) "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
971 (signal 'file-error (list "Compress error:" file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
972 "a symbolic link"))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
973 ((listp compressed-fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
974 (let ((newname (substring (if (memq host-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
975 efs-version-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
976 (efs-internal-file-name-sans-versions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
977 host-type file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
978 file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
979 0 (- (length (nth 1 compressed-fn)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
980 (program (nth 3 compressed-fn)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
981 (if (and (memq host-type efs-unix-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
982 (null (efs-get-host-property host 'exec-failed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
983 (null (eq (efs-get-host-property
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
984 host
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
985 (intern
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
986 (concat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
987 "exec-"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
988 (efs-compress-progname (car program)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
989 'failed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
990 (efs-call-remote-compress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
991 program file newname t ok-flag
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
992 (efs-cont (result line cont-lines) (program file newname
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
993 cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
994 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
995 (if (eq result 'unsupported)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
996 (efs-call-compress program file newname
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
997 t t cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
998 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
999 (efs-call-cont cont result line cont-lines)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1000 (signal 'ftp-error
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1001 (list "Uncompressing file"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1002 (format "FTP Error: \"%s\" " line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1003 file))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1004 (if cont (efs-call-cont cont result line cont-lines))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1005 nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1006 (efs-call-compress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1007 program file newname t ok-flag cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1008 newname)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1009 ((stringp compressed-fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1010 (let ((program (nth 2 (assq dired-compression-method
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1011 dired-compression-method-alist))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1012 (if (and (memq host-type efs-unix-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1013 (null (efs-get-host-property host 'exec-failed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1014 (null (eq (efs-get-host-property
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1015 host
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1016 (intern
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1017 (concat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1018 "exec-"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1019 (efs-compress-progname (car program)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1020 'failed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1021 (efs-call-remote-compress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1022 program file compressed-fn nil ok-flag
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1023 (efs-cont (result line cont-lines) (program file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1024 compressed-fn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1025 cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1026 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1027 (if (eq result 'unsupported)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1028 (efs-call-compress program file compressed-fn nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1029 t cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1030 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1031 (efs-call-cont cont result line cont-lines)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1032 (signal 'ftp-error
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1033 (list "Compressing file"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1034 (format "FTP Error: \"%s\" " line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1035 file))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1036 (if cont (efs-call-cont cont result line cont-lines))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1037 nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1038 (efs-call-compress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1039 program file compressed-fn nil ok-flag cont nowait)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1040 compressed-fn)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1041 (t (error "Strange error in efs-dired-compress-file.")))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1042
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1043 (defun efs-dired-print-file (command file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1044 ;; Version of dired-print-file for remote files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1045 (let ((command (dired-trans-command command (list file) "")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1046 ;; Only replace the first occurence of the file name?
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1047 (if (string-match (concat "[ ><|]\\(" (regexp-quote
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1048 (dired-shell-quote file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1049 "\\)\\($\\|[ |><&]\\)")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1050 command)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1051 (setq command (concat (substring command 0 (match-beginning 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1052 "%s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1053 (substring command (match-end 1))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1054 (error "efs-print-command: strange error"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1055 (efs-call-lpr file command)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1056
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1057 ;;;;----------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1058 ;;;; Support for `processes' run on remote files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1059 ;;;; Usually (but not necessarily) these are only called from dired.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1060 ;;;;----------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1061
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1062 (defun efs-compress-progname (program)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1063 ;; Returns a canonicalized i.e. without the "un", version of a compress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1064 ;; program name.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1065 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1066 (if (string-equal program "gunzip")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1067 "gzip"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1068 (if (string-match "^un" program)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1069 (substring program (match-end 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1070 program))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1071
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1072 (defun efs-call-remote-compress (program filename newname &optional uncompress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1073 ok-if-already-exists cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1074 ;; Run a remote compress process using SITE EXEC.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1075 (if (or (not ok-if-already-exists)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1076 (numberp ok-if-already-exists))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1077 (efs-barf-or-query-if-file-exists
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1078 newname
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1079 (if uncompress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1080 "uncompress to it"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1081 "compress to it")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1082 (numberp ok-if-already-exists)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1083 (let* ((filename (expand-file-name filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1084 (parsed (efs-ftp-path filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1085 (host (car parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1086 (user (nth 1 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1087 (rpath (nth 2 parsed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1088 (if (efs-get-host-property host 'exec-failed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1089 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1090 (efs-call-cont cont 'unsupported "SITE EXEC not supported" "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1091 (signal 'ftp-error (list "Unable to SITE EXEC" host)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1092 (let* ((progname (efs-compress-progname (car program)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1093 (propsym (intern (concat "exec-" progname)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1094 (prop (efs-get-host-property host propsym)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1095 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1096 ((eq prop 'failed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1097 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1098 (efs-call-cont cont 'unsupported
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1099 (concat progname " not in FTP exec path") "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1100 (signal 'ftp-error
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1101 (list (concat progname " not in FTP exec path") host))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1102 ((eq prop 'worked)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1103 (efs-send-cmd
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1104 host user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1105 (list 'quote 'site 'exec
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1106 (concat (mapconcat 'identity program " ") " " rpath))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1107 (concat (if uncompress "Uncompressing " "Compressing ") filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1108 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1109 (efs-cont (result line cont-lines) (host user filename cont)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1110 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1111 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1112 (efs-set-host-property host 'exec-failed t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1113 (efs-error host user (concat "FTP exec Error: " line)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1114 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1115 (if (string-match "\n200-\\([^\n]*\\)" cont-lines)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1116 (let ((err (substring cont-lines (match-beginning 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1117 (match-end 1))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1118 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1119 (efs-call-cont cont 'failed err cont-lines)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1120 (efs-error host user (concat "FTP Error: " err))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1121 ;; This function only gets called for unix hosts, so
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1122 ;; we'll use the default version of efs-delete-file-entry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1123 ;; and save a host-type lookup.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1124 (efs-delete-file-entry nil filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1125 (dired-remove-file filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1126 (if cont (efs-call-cont cont nil line cont-lines))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1127 nowait))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1128 (t ; (null prop)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1129 (efs-send-cmd
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1130 host user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1131 (list 'quote 'site 'exec (concat progname " " "-V"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1132 (format "Checking for %s executable" progname)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1133 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1134 (efs-cont (result line cont-lines) (propsym host program filename
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1135 newname uncompress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1136 cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1137 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1138 (if (string-match "\n200-" cont-lines)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1139 (efs-set-host-property host propsym 'worked)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1140 (efs-set-host-property host propsym 'failed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1141 (efs-call-remote-compress program filename newname uncompress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1142 t ; already tested for overwrite
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1143 cont nowait))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1144 nowait)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1145
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1146 (defun efs-call-compress (program filename newname &optional uncompress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1147 ok-if-already-exists cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1148 "Perform a compress command on a remote file.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1149 PROGRAM is a list of the compression program and args. Works by taking a
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1150 copy of the file, compressing it and copying the file back. Returns 0 on
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1151 success, 1 or 2 on failure. If UNCOMPRESS is non-nil, does this instead."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1152 (let* ((filename (expand-file-name filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1153 (newname (expand-file-name newname))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1154 (parsed (efs-ftp-path filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1155 (tmp1 (car (efs-make-tmp-name nil (car parsed))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1156 (tmp2 (car (efs-make-tmp-name nil (car parsed))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1157 (program (mapconcat 'identity program " ")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1158 (efs-copy-file-internal
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1159 filename parsed tmp1 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1160 t nil 2
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1161 (efs-cont (result line cont-lines) (filename newname tmp1 tmp2 program
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1162 uncompress ok-if-already-exists
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1163 cont nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1164 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1165 (signal 'ftp-error
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1166 (list "Opening input file"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1167 (format "FTP Error: \"%s\" " line) filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1168 (let ((err-buff (let ((default-major-mode 'fundamental-mode))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1169 (get-buffer-create
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1170 (generate-new-buffer-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1171 (format
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1172 " efs-call-compress %s" filename))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1173 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1174 (set-buffer err-buff)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1175 (set (make-local-variable 'efs-call-compress-filename) filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1176 (set (make-local-variable 'efs-call-compress-newname) newname)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1177 (set (make-local-variable 'efs-call-compress-tmp1) tmp1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1178 (set (make-local-variable 'efs-call-compress-tmp2) tmp2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1179 (set (make-local-variable 'efs-call-compress-cont) cont)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1180 (set (make-local-variable 'efs-call-compress-nowait) nowait)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1181 (set (make-local-variable 'efs-call-compress-ok)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1182 ok-if-already-exists)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1183 (set (make-local-variable 'efs-call-compress-uncompress)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1184 uncompress)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1185 (set (make-local-variable 'efs-call-compress-abbr)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1186 (efs-relativize-filename filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1187 (if efs-verbose
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1188 (efs-message
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1189 (format "%s %s..."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1190 (if uncompress "Uncompressing" "Compressing")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1191 (symbol-value (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1192 'efs-call-compress-abbr)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1193 (set-process-sentinel
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1194 (start-process (format "efs-call-compress %s" filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1195 err-buff shell-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1196 "-c" (format "%s %s < %s > %s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1197 program
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1198 ;; Hope -c makes the compress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1199 ;; program write to std out.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1200 "-c"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1201 tmp1 tmp2))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1202 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1203 (lambda (proc str)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1204 (let ((buff (get-buffer (process-buffer proc))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1205 (if buff
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1206 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1207 (set-buffer buff)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1208 (if (/= (buffer-size) 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1209 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1210 (efs-call-cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1211 (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1212 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1213 'efs-call-compress-cont))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1214 'failed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1215 (concat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1216 "failed to compress "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1217 (symbol-value (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1218 'efs-call-compress-filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1219 ", "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1220 (buffer-substring
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1221 (point-min)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1222 (progn (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1223 (end-of-line) (point))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1224 (efs-del-tmp-name (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1225 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1226 'efs-call-compress-tmp1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1227 (let ((tmp2 (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1228 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1229 'efs-call-compress-tmp2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1230 (newname (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1231 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1232 'efs-call-compress-newname)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1233 (filename (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1234 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1235 'efs-call-compress-filename)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1236 (cont (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1237 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1238 'efs-call-compress-cont)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1239 (nowait (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1240 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1241 'efs-call-compress-nowait)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1242 (ok (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1243 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1244 'efs-call-compress-ok)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1245 (uncompress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1246 (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1247 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1248 'efs-call-compress-uncompress))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1249 (if efs-verbose
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1250 (efs-message
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1251 (format "%s %s...done"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1252 (if uncompress
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1253 "Uncompressing"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1254 "Compressing")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1255 (symbol-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1256 (make-local-variable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1257 'efs-call-compress-abbr)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1258 (kill-buffer (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1259 (efs-copy-file-internal
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1260 tmp2 nil newname (efs-ftp-path newname)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1261 ok nil 1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1262 (efs-cont (result line cont-lines) (cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1263 tmp2
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1264 filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1265 (efs-del-tmp-name tmp2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1266 (or result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1267 (let (efs-verbose)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1268 (efs-delete-file filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1269 (dired-remove-file filename)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1270 (if cont
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1271 (efs-call-cont cont result line
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1272 cont-lines)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1273 nowait (if uncompress nil 'image)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1274 (error "Strange error: %s" proc))))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1275 nowait (if uncompress 'image nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1276
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1277 (defun efs-update-mode-string (perms modes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1278 ;; For PERMS of the form `u+w', and MODES a unix 9-character mode string,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1279 ;; computes the new mode string.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1280 ;; Doesn't call efs-save-match-data. The calling function should.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1281 (or (string-match "^[augo]+\\([+-]\\)[rwxst]+$" perms)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1282 (error "efs-update-mode-string: invalid perms %s" perms))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1283 (let* ((who (substring perms 0 (match-beginning 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1284 (add (= (aref perms (match-beginning 1)) ?+))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1285 (what (substring perms (match-end 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1286 (newmodes (copy-sequence modes))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1287 (read (string-match "r" what))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1288 (write (string-match "w" what))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1289 (execute (string-match "x" what))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1290 (sticky (string-match "t" what))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1291 (suid (string-match "s" what)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1292 (if (string-match "a" who)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1293 (if add
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1294 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1295 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1296 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1297 (aset newmodes 0 ?r)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1298 (aset newmodes 3 ?r)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1299 (aset newmodes 6 ?r)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1300 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1301 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1302 (aset newmodes 1 ?w)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1303 (aset newmodes 4 ?w)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1304 (aset newmodes 7 ?w)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1305 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1306 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1307 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1308 (aset newmodes 2 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1309 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1310 (aset newmodes 2 ?s)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1311 (setq curr (aref newmodes 5))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1312 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1313 (aset newmodes 5 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1314 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1315 (aset newmodes 5 ?s)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1316 (setq curr (aref newmodes 8))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1317 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1318 (aset newmodes 8 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1319 (if (= curr ?T)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1320 (aset newmodes 8 ?t)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1321 (if suid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1322 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1323 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1324 (aset newmodes 2 ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1325 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1326 (aset newmodes 2 ?s)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1327 (setq curr (aref newmodes 5))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1328 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1329 (aset newmodes 5 ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1330 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1331 (aset newmodes 5 ?s)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1332 (if sticky
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1333 (let ((curr (aref newmodes 8)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1334 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1335 (aset newmodes 8 ?T)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1336 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1337 (aset newmodes 8 ?t))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1338 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1339 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1340 (aset newmodes 0 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1341 (aset newmodes 3 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1342 (aset newmodes 6 ?-)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1343 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1344 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1345 (aset newmodes 1 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1346 (aset newmodes 4 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1347 (aset newmodes 7 ?-)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1348 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1349 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1350 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1351 (aset newmodes 2 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1352 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1353 (aset newmodes 2 ?S)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1354 (setq curr (aref newmodes 5))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1355 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1356 (aset newmodes 5 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1357 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1358 (aset newmodes 5 ?S)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1359 (setq curr (aref newmodes 8))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1360 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1361 (aset newmodes 8 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1362 (if (= curr ?t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1363 (aset newmodes 8 ?T)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1364 (if suid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1365 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1366 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1367 (aset newmodes 2 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1368 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1369 (aset newmodes 2 ?-)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1370 (setq curr (aref newmodes 5))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1371 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1372 (aset newmodes 5 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1373 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1374 (aset newmodes 5 ?-)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1375 (if sticky
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1376 (let ((curr (aref newmodes 8)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1377 (if (= curr ?t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1378 (aset newmodes 8 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1379 (if (= curr ?T)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1380 (aset newmodes 8 ?-))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1381 (if (string-match "u" who)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1382 (if add
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1383 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1384 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1385 (aset newmodes 0 ?r))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1386 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1387 (aset newmodes 1 ?w))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1388 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1389 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1390 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1391 (aset newmodes 2 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1392 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1393 (aset newmodes 2 ?s)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1394 (if suid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1395 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1396 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1397 (aset newmodes 2 ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1398 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1399 (aset newmodes 2 ?s))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1400 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1401 (aset newmodes 0 ?-))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1402 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1403 (aset newmodes 1 ?-))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1404 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1405 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1406 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1407 (aset newmodes 2 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1408 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1409 (aset newmodes 2 ?S)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1410 (if suid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1411 (let ((curr (aref newmodes 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1412 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1413 (aset newmodes 2 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1414 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1415 (aset newmodes 2 ?-)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1416 (if (string-match "g" who)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1417 (if add
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1418 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1419 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1420 (aset newmodes 3 ?r))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1421 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1422 (aset newmodes 4 ?w))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1423 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1424 (let ((curr (aref newmodes 5)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1425 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1426 (aset newmodes 5 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1427 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1428 (aset newmodes 5 ?s)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1429 (if suid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1430 (let ((curr (aref newmodes 5)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1431 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1432 (aset newmodes 5 ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1433 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1434 (aset newmodes 5 ?s))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1435 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1436 (aset newmodes 3 ?-))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1437 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1438 (aset newmodes 4 ?-))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1439 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1440 (let ((curr (aref newmodes 5)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1441 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1442 (aset newmodes 5 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1443 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1444 (aset newmodes 5 ?S)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1445 (if suid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1446 (let ((curr (aref newmodes 5)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1447 (if (= curr ?s)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1448 (aset newmodes 5 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1449 (if (= curr ?S)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1450 (aset newmodes 5 ?-)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1451 (if (string-match "o" who)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1452 (if add
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1453 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1454 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1455 (aset newmodes 6 ?r))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1456 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1457 (aset newmodes 7 ?w))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1458 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1459 (let ((curr (aref newmodes 8)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1460 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1461 (aset newmodes 8 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1462 (if (= curr ?T)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1463 (aset newmodes 8 ?t)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1464 (if sticky
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1465 (let ((curr (aref newmodes 8)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1466 (if (= curr ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1467 (aset newmodes 8 ?T)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1468 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1469 (aset newmodes 5 ?t))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1470 (if read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1471 (aset newmodes 6 ?-))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1472 (if write
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1473 (aset newmodes 7 ?-))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1474 (if execute
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1475 (let ((curr (aref newmodes 8)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1476 (if (= curr ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1477 (aset newmodes 8 ?-)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1478 (if (= curr ?t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1479 (aset newmodes 8 ?T)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1480 (if suid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1481 (let ((curr (aref newmodes 8)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1482 (if (= curr ?t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1483 (aset newmodes 8 ?x)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1484 (if (= curr ?T)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1485 (aset newmodes 8 ?-))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1486 newmodes))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1487
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1488 (defun efs-compute-chmod-arg (perms file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1489 ;; Computes the octal number, represented as a string, required to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1490 ;; modify the permissions PERMS of FILE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1491 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1492 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1493 ((string-match "^[0-7][0-7]?[0-7]?[0-7]?$" perms)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1494 perms)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1495 ((string-match "^[augo]+[-+][rwxst]+$" perms)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1496 (let ((curr-mode (nth 3 (efs-get-file-entry file))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1497 (or (and curr-mode
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1498 (stringp curr-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1499 (= (length curr-mode) 10))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1500 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1501 ;; Current buffer is process error buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1502 (insert "Require an octal integer to modify modes for "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1503 file ".\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1504 (error "Require an octal integer to modify modes for %s." file)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1505 (format "%o"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1506 (efs-parse-mode-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1507 (efs-update-mode-string perms
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1508 (substring curr-mode 1))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1509 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1510 (insert "Don't know how to set modes " perms " for " file ".\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1511 (error "Don't know how to set modes %s" perms)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1512
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1513 (defun efs-call-chmod (args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1514 ;; Sends an FTP CHMOD command.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1515 (if (< (length args) 2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1516 (error "efs-call-chmod: missing mode and/or filename: %s" args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1517 (let ((mode (car args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1518 bombed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1519 (mapcar
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1520 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1521 (lambda (file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1522 (setq file (expand-file-name file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1523 (let ((parsed (efs-ftp-path file)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1524 (if parsed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1525 (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1526 (let* ((mode (efs-compute-chmod-arg mode file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1527 (host (nth 0 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1528 (user (nth 1 parsed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1529 (path (efs-quote-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1530 (efs-host-type host user) (nth 2 parsed)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1531 (abbr (efs-relativize-filename file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1532 (result (efs-send-cmd host user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1533 (list 'quote 'site 'chmod
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1534 mode path)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1535 (format "doing chmod %s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1536 abbr))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1537 (efs-del-from-ls-cache file t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1538 (if (car result)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1539 (efs-error host user (format "chmod: %s: \"%s\"" file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1540 (nth 1 result)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1541 (error (setq bombed t)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1542 (cdr args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1543 (if bombed 1 0))) ; return code
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1544
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1545 (defun efs-call-lpr (file command-format)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1546 "Print remote file FILE. SWITCHES are passed to the print program."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1547 ;; Works asynch.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1548 (let* ((file (expand-file-name file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1549 (parsed (efs-ftp-path file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1550 (abbr (efs-relativize-filename file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1551 (temp (car (efs-make-tmp-name nil (car parsed)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1552 (efs-copy-file-internal
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1553 file parsed temp nil t nil 2
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1554 (efs-cont (result line cont-lines) (command-format file abbr temp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1555 (if result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1556 (signal 'ftp-error (list "Opening input file"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1557 (format "FTP Error: \"%s\" " line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1558 file))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1559 (message "Spooling %s..." abbr)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1560 (set-process-sentinel
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1561 (start-process (format "*print %s /// %s*" abbr temp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1562 (generate-new-buffer-name " *print temp*")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1563 "sh" "-c" (format command-format temp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1564 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1565 (lambda (proc status)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1566 (let ((buff (process-buffer proc))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1567 (name (process-name proc)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1568 (if (and buff (get-buffer buff))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1569 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1570 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1571 (set-buffer buff)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1572 (if (> (buffer-size) 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1573 (let ((log-buff (get-buffer-create
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1574 "*Shell Command Output*")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1575 (set-buffer log-buff)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1576 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1577 (or (bobp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1578 (insert "\n"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1579 (insert-buffer-substring buff)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1580 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1581 (display-buffer log-buff))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1582 (condition-case nil (kill-buffer buff) (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1583 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1584 (if (string-match "^\\*print \\(.*\\) /// \\(.*\\)\\*$"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1585 name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1586 (let ((abbr (substring name (match-beginning 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1587 (match-end 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1588 (temp (substring name (match-beginning 2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1589 (match-end 2))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1590 (or (= (match-beginning 2) (match-end 2))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1591 (efs-del-tmp-name temp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1592 (message "Spooling %s...done" abbr))))))))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1593 t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1594
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1595 ;;;; --------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1596 ;;;; Attaching onto dired.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1597 ;;;; --------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1598
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1599 ;;; Look out for MULE
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1600 (if (or (boundp 'MULE) (featurep 'mule)) (load "efs-dired-mule"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1601
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1602 ;;; Magic file name hooks for dired.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1603
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1604 (put 'dired-print-file 'efs 'efs-dired-print-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1605 (put 'dired-make-compressed-filename 'efs 'efs-dired-make-compressed-filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1606 (put 'dired-compress-file 'efs 'efs-dired-compress-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1607 (put 'dired-recursive-delete-directory 'efs
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1608 'efs-dired-recursive-delete-directory)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1609 (put 'dired-uncache 'efs 'efs-dired-uncache)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1610 (put 'dired-shell-call-process 'efs 'efs-dired-shell-call-process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1611 (put 'dired-shell-unhandle-file-name 'efs 'efs-dired-shell-unhandle-file-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1612 (put 'dired-file-modtime 'efs 'efs-dired-file-modtime)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1613 (put 'dired-set-file-modtime 'efs 'efs-dired-set-file-modtime)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1614
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1615 ;;; Overwriting functions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1616
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1617 (efs-overwrite-fn "efs" 'dired-call-process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1618 (efs-overwrite-fn "efs" 'dired-insert-headerline)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1619 (efs-overwrite-fn "efs" 'dired-manual-move-to-filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1620 (efs-overwrite-fn "efs" 'dired-manual-move-to-end-of-filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1621 (efs-overwrite-fn "efs" 'dired-make-filename-string)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1622 (efs-overwrite-fn "efs" 'dired-flag-backup-files)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1623 (efs-overwrite-fn "efs" 'dired-create-files)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1624 (efs-overwrite-fn "efs" 'dired-find-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1625 (efs-overwrite-fn "efs" 'dired-find-file-other-window)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1626 (efs-overwrite-fn "efs" 'dired-find-file-other-frame)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1627 (efs-overwrite-fn "efs" 'dired-collect-file-versions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1628 (efs-overwrite-fn "efs" 'dired-file-name-lessp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1629
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1630 ;;; Hooks
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1631
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1632 (add-hook 'dired-before-readin-hook 'efs-dired-before-readin)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1633
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1634 ;;; Handle dired-grep.el too.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1635
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1636 (if (featurep 'dired-grep)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1637 (efs-overwrite-fn "efs" 'dired-grep-delete-local-temp-file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1638 'efs-diff/grep-del-temp-file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1639 (add-hook 'dired-grep-load-hook
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1640 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1641 (lambda ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1642 (efs-overwrite-fn "efs" 'dired-grep-delete-local-temp-file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1643 'efs-diff/grep-del-temp-file)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1644
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1645 ;;; end of efs-dired.el