Mercurial > emacs
annotate lisp/ange-ftp.el @ 1825:ba2fcbf5d6a1
(sendmail-program): Try /usr/ucblib/sendmail.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 28 Jan 1993 06:17:47 +0000 |
parents | 174817d23858 |
children | bd3c525fa6fc |
rev | line source |
---|---|
1106 | 1 ;; -*-Emacs-Lisp-*- |
1174 | 2 ;;; ??? Waiting for papers from several people. |
1106 | 3 ;; Description: transparent FTP support for GNU Emacs |
4 | |
5 ;;; Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. | |
6 ;;; | |
7 ;;; Author: Andy Norman (ange@hplb.hpl.hp.com) | |
8 ;;; | |
9 ;;; This program is free software; you can redistribute it and/or modify | |
10 ;;; it under the terms of the GNU General Public License as published by | |
11 ;;; the Free Software Foundation; either version 1, or (at your option) | |
12 ;;; any later version. | |
13 ;;; | |
14 ;;; This program is distributed in the hope that it will be useful, | |
15 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;;; GNU General Public License for more details. | |
18 ;;; | |
19 ;;; A copy of the GNU General Public License can be obtained from this | |
20 ;;; program's author (send electronic mail to ange@hplb.hpl.hp.com) or from | |
21 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA | |
22 ;;; 02139, USA. | |
23 | |
24 ;;; Description: | |
25 ;;; | |
26 ;;; This package attempts to make accessing files and directories using FTP | |
27 ;;; from within GNU Emacs as simple and transparent as possible. A subset of | |
28 ;;; the common file-handling routines are extended to interact with FTP. | |
29 | |
30 ;;; Usage: | |
31 ;;; | |
32 ;;; Some of the common GNU Emacs file-handling operations have been made | |
33 ;;; FTP-smart. If one of these routines is given a filename that matches | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
34 ;;; '/user@host:name' then it will spawn an FTP process connecting to machine |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
35 ;;; 'host' as account 'user' and perform its operation on the file 'name'. |
1106 | 36 ;;; |
37 ;;; For example: if find-file is given a filename of: | |
38 ;;; | |
39 ;;; /ange@anorman:/tmp/notes | |
40 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
41 ;;; then ange-ftp spawns an FTP process, connect to the host 'anorman' as |
1106 | 42 ;;; user 'ange', get the file '/tmp/notes' and pop up a buffer containing the |
43 ;;; contents of that file as if it were on the local filesystem. If ange-ftp | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
44 ;;; needs a password to connect then it reads one in the echo area. |
1106 | 45 |
46 ;;; Extended filename syntax: | |
47 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
48 ;;; The default extended filename syntax is '/user@host:name', where the |
1106 | 49 ;;; 'user@' part may be omitted. This syntax can be customised to a certain |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
50 ;;; extent by changing ange-ftp-name-format. There are limitations. |
1106 | 51 ;;; |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
52 ;;; If the user part is omitted then ange-ftp generates a default user |
1106 | 53 ;;; instead whose value depends on the variable ange-ftp-default-user. |
54 | |
55 ;;; Passwords: | |
56 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
57 ;;; A password is required for each host/user pair. Ange-ftp reads passwords |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
58 ;;; as needed. You can also specify a password with ange-ftp-set-passwd, or |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
59 ;;; in a *valid* ~/.netrc file. |
1106 | 60 |
61 ;;; Passwords for user "anonymous": | |
62 ;;; | |
1174 | 63 ;;; Passwords for the user "anonymous" (or "ftp") are handled |
64 ;;; specially. The variable `ange-ftp-generate-anonymous-password' | |
65 ;;; controls what happens: if the value of this variable is a string, | |
66 ;;; then this is used as the password; if non-nil (the default), then | |
67 ;;; a password is created from the name of the user and the hostname | |
68 ;;; of the machine on which GNU Emacs is running; if nil then the user | |
69 ;;; is prompted for a password as normal. | |
1106 | 70 |
71 ;;; "Dumb" UNIX hosts: | |
72 ;;; | |
73 ;;; The FTP servers on some UNIX machines have problems if the 'ls' command is | |
74 ;;; used. | |
75 ;;; | |
76 ;;; The routine ange-ftp-add-dumb-unix-host can be called to tell ange-ftp to | |
77 ;;; limit itself to the DIR command and not 'ls' for a given UNIX host. Note | |
78 ;;; that this change will take effect for the current GNU Emacs session only. | |
79 ;;; See below for a discussion of non-UNIX hosts. If a large number of | |
80 ;;; machines with similar hostnames have this problem then it is easier to set | |
81 ;;; the value of ange-ftp-dumb-unix-host-regexp in your .emacs file. ange-ftp | |
82 ;;; is unable to automatically recognize dumb unix hosts. | |
83 | |
84 ;;; File name completion: | |
85 ;;; | |
86 ;;; Full file-name completion is supported on UNIX, VMS, CMS, and MTS hosts. | |
87 ;;; To do filename completion, ange-ftp needs a listing from the remote host. | |
88 ;;; Therefore, for very slow connections, it might not save any time. | |
89 | |
90 ;;; FTP processes: | |
91 ;;; | |
92 ;;; When ange-ftp starts up an FTP process, it leaves it running for speed | |
93 ;;; purposes. Some FTP servers will close the connection after a period of | |
94 ;;; time, but ange-ftp should be able to quietly reconnect the next time that | |
95 ;;; the process is needed. | |
96 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
97 ;;; Killing the "*ftp user@host*" buffer also kills the ftp process. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
98 ;;; This should not cause ange-ftp any grief. |
1106 | 99 |
100 ;;; Binary file transfers: | |
101 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
102 ;;; By default ange-ftp transfers files in ASCII mode. If a file being |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
103 ;;; transferred matches the value of ange-ftp-binary-file-name-regexp then |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
104 ;;; binary mode is used for that transfer. |
1106 | 105 |
106 ;;; Account passwords: | |
107 ;;; | |
108 ;;; Some FTP servers require an additional password which is sent by the | |
109 ;;; ACCOUNT command. ange-ftp partially supports this by allowing the user to | |
110 ;;; specify an account password by either calling ange-ftp-set-account, or by | |
111 ;;; specifying an account token in the .netrc file. If the account password | |
112 ;;; is set by either of these methods then ange-ftp will issue an ACCOUNT | |
113 ;;; command upon starting the FTP process. | |
114 | |
115 ;;; Preloading: | |
116 ;;; | |
117 ;;; ange-ftp can be preloaded, but must be put in the site-init.el file and | |
118 ;;; not the site-load.el file in order for the documentation strings for the | |
119 ;;; functions being overloaded to be available. | |
120 | |
121 ;;; Status reports: | |
122 ;;; | |
123 ;;; Most ange-ftp commands that talk to the FTP process output a status | |
124 ;;; message on what they are doing. In addition, ange-ftp can take advantage | |
125 ;;; of the FTP client's HASH command to display the status of transferring | |
126 ;;; files and listing directories. See the documentation for the variables | |
127 ;;; ange-ftp-{ascii,binary}-hash-mark-size, ange-ftp-send-hash and | |
128 ;;; ange-ftp-process-verbose for more details. | |
129 | |
130 ;;; Gateways: | |
131 ;;; | |
132 ;;; Sometimes it is neccessary for the FTP process to be run on a different | |
133 ;;; machine than the machine running GNU Emacs. This can happen when the | |
134 ;;; local machine has restrictions on what hosts it can access. | |
135 ;;; | |
136 ;;; ange-ftp has support for running the ftp process on a different (gateway) | |
137 ;;; machine. The way it works is as follows: | |
138 ;;; | |
139 ;;; 1) Set the variable 'ange-ftp-gateway-host' to the name of a machine | |
140 ;;; that doesn't have the access restrictions. | |
141 ;;; | |
142 ;;; 2) Set the variable 'ange-ftp-local-host-regexp' to a regular expression | |
143 ;;; that matches hosts that can be contacted from running a local ftp | |
144 ;;; process, but fails to match hosts that can't be accessed locally. For | |
145 ;;; example: | |
146 ;;; | |
147 ;;; "\\.hp\\.com$\\|^[^.]*$" | |
148 ;;; | |
149 ;;; will match all hosts that are in the .hp.com domain, or don't have an | |
150 ;;; explicit domain in their name, but will fail to match hosts with | |
151 ;;; explicit domains or that are specified by their ip address. | |
152 ;;; | |
153 ;;; 3) Using NFS and symlinks, make sure that there is a shared directory with | |
154 ;;; the *same* name between the local machine and the gateway machine. | |
155 ;;; This directory is neccessary for temporary files created by ange-ftp. | |
156 ;;; | |
157 ;;; 4) Set the variable 'ange-ftp-gateway-tmp-name-template' to the name of | |
158 ;;; this directory plus an identifying filename prefix. For example: | |
159 ;;; | |
160 ;;; "/nfs/hplose/ange/ange-ftp" | |
161 ;;; | |
162 ;;; where /nfs/hplose/ange is a directory that is shared between the | |
163 ;;; gateway machine and the local machine. | |
164 ;;; | |
165 ;;; The simplest way of getting a ftp process running on the gateway machine | |
166 ;;; is if you can spawn a remote shell using either 'rsh' or 'remsh'. If you | |
167 ;;; can't do this for some reason such as security then points 7 onwards will | |
168 ;;; discuss an alternative approach. | |
169 ;;; | |
170 ;;; 5) Set the variable ange-ftp-gateway-program to the name of the remote | |
171 ;;; shell process such as 'remsh' or 'rsh' if the default isn't correct. | |
172 ;;; | |
173 ;;; 6) Set the variable ange-ftp-gateway-program-interactive to nil if it | |
174 ;;; isn't already. This tells ange-ftp that you are using a remote shell | |
175 ;;; rather than logging in using telnet or rlogin. | |
176 ;;; | |
177 ;;; That should be all you need to allow ange-ftp to spawn a ftp process on | |
178 ;;; the gateway machine. If you have to use telnet or rlogin to get to the | |
179 ;;; gateway machine then follow the instructions below. | |
180 ;;; | |
181 ;;; 7) Set the variable ange-ftp-gateway-program to the name of the program | |
182 ;;; that lets you log onto the gateway machine. This may be something like | |
183 ;;; telnet or rlogin. | |
184 ;;; | |
185 ;;; 8) Set the variable ange-ftp-gateway-prompt-pattern to a regular | |
186 ;;; expression that matches the prompt you get when you login to the | |
187 ;;; gateway machine. Be very specific here; this regexp must not match | |
188 ;;; *anything* in your login banner except this prompt. | |
189 ;;; shell-prompt-pattern is far too general as it appears to match some | |
190 ;;; login banners from Sun machines. For example: | |
191 ;;; | |
192 ;;; "^$*$ *" | |
193 ;;; | |
194 ;;; 9) Set the variable ange-ftp-gateway-program-interactive to 't' to let | |
195 ;;; ange-ftp know that it has to "hand-hold" the login to the gateway | |
196 ;;; machine. | |
197 ;;; | |
198 ;;; 10) Set the variable ange-ftp-gateway-setup-term-command to a UNIX command | |
199 ;;; that will put the pty connected to the gateway machine into a | |
200 ;;; no-echoing mode, and will strip off carriage-returns from output from | |
201 ;;; the gateway machine. For example: | |
202 ;;; | |
203 ;;; "stty -onlcr -echo" | |
204 ;;; | |
205 ;;; will work on HP-UX machines, whereas: | |
206 ;;; | |
207 ;;; "stty -echo nl" | |
208 ;;; | |
209 ;;; appears to work for some Sun machines. | |
210 ;;; | |
211 ;;; That's all there is to it. | |
212 | |
213 ;;; Smart gateways: | |
214 ;;; | |
215 ;;; If you have a "smart" ftp program that allows you to issue commands like | |
216 ;;; "USER foo@bar" which do nice proxy things, then look at the variables | |
217 ;;; ange-ftp-smart-gateway and ange-ftp-smart-gateway-port. | |
218 | |
219 ;;; Tips for using ange-ftp: | |
220 ;;; | |
221 ;;; 1. For dired to work on a host which marks symlinks with a trailing @ in | |
222 ;;; an ls -alF listing, you need to (setq dired-ls-F-marks-symlinks t). | |
223 ;;; Most UNIX systems do not do this, but ULTRIX does. If you think that | |
224 ;;; there is a chance you might connect to an ULTRIX machine (such as | |
225 ;;; prep.ai.mit.edu), then set this variable accordingly. This will have | |
226 ;;; the side effect that dired will have problems with symlinks whose names | |
227 ;;; end in an @. If you get youself into this situation then editing | |
228 ;;; dired's ls-switches to remove "F", will temporarily fix things. | |
229 ;;; | |
230 ;;; 2. If you know that you are connecting to a certain non-UNIX machine | |
231 ;;; frequently, and ange-ftp seems to be unable to guess its host-type, | |
232 ;;; then setting the appropriate host-type regexp | |
233 ;;; (ange-ftp-vms-host-regexp, ange-ftp-mts-host-regexp, or | |
234 ;;; ange-ftp-cms-host-regexp) accordingly should help. Also, please report | |
235 ;;; ange-ftp's inability to recognize the host-type as a bug. | |
236 ;;; | |
237 ;;; 3. For slow connections, you might get "listing unreadable" error | |
238 ;;; messages, or get an empty buffer for a file that you know has something | |
239 ;;; in it. The solution is to increase the value of ange-ftp-retry-time. | |
240 ;;; Its default value is 5 which is plenty for reasonable connections. | |
241 ;;; However, for some transatlantic connections I set this to 20. | |
242 ;;; | |
243 ;;; 4. Beware of compressing files on non-UNIX hosts. Ange-ftp will do it by | |
244 ;;; copying the file to the local machine, compressing it there, and then | |
245 ;;; sending it back. Binary file transfers between machines of different | |
246 ;;; architectures can be a risky business. Test things out first on some | |
247 ;;; test files. See "Bugs" below. Also, note that ange-ftp copies files by | |
248 ;;; moving them through the local machine. Again, be careful when doing | |
249 ;;; this with binary files on non-Unix machines. | |
250 ;;; | |
251 ;;; 5. Beware that dired over ftp will use your setting of dired-no-confirm | |
252 ;;; (list of dired commands for which confirmation is not asked). You | |
253 ;;; might want to reconsider your setting of this variable, because you | |
254 ;;; might want confirmation for more commands on remote direds than on | |
255 ;;; local direds. For example, I strongly recommend that you not include | |
256 ;;; compress and uncompress in this list. If there is enough demand it | |
257 ;;; might be a good idea to have an alist ange-ftp-dired-no-confirm of | |
258 ;;; pairs ( TYPE . LIST ), where TYPE is an operating system type and LIST | |
259 ;;; is a list of commands for which confirmation would be suppressed. Then | |
260 ;;; remote dired listings would take their (buffer-local) value of | |
261 ;;; dired-no-confirm from this alist. Who votes for this? | |
262 | |
263 ;;; --------------------------------------------------------------------- | |
264 ;;; Non-UNIX support: | |
265 ;;; --------------------------------------------------------------------- | |
266 | |
267 ;;; VMS support: | |
268 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
269 ;;; Ange-ftp has full support for VMS hosts. It |
1106 | 270 ;;; should be able to automatically recognize any VMS machine. However, if it |
271 ;;; fails to do this, you can use the command ange-ftp-add-vms-host. As well, | |
272 ;;; you can set the variable ange-ftp-vms-host-regexp in your .emacs file. We | |
273 ;;; would be grateful if you would report any failures to automatically | |
274 ;;; recognize a VMS host as a bug. | |
275 ;;; | |
276 ;;; Filename Syntax: | |
277 ;;; | |
278 ;;; For ease of *implementation*, the user enters the VMS filename syntax in a | |
279 ;;; UNIX-y way. For example: | |
280 ;;; PUB$:[ANONYMOUS.SDSCPUB.NEXT]README.TXT;1 | |
281 ;;; would be entered as: | |
282 ;;; /PUB$$:/ANONYMOUS/SDSCPUB/NEXT/README.TXT;1 | |
283 ;;; i.e. to log in as anonymous on ymir.claremont.edu and grab the file: | |
284 ;;; [.CSV.POLICY]RULES.MEM | |
285 ;;; you would type: | |
286 ;;; C-x C-f /anonymous@ymir.claremont.edu:CSV/POLICY/RULES.MEM | |
287 ;;; | |
288 ;;; A legal VMS filename is of the form: FILE.TYPE;## | |
289 ;;; where FILE can be up to 39 characters | |
290 ;;; TYPE can be up to 39 characters | |
291 ;;; ## is a version number (an integer between 1 and 32,767) | |
292 ;;; Valid characters in FILE and TYPE are A-Z 0-9 _ - $ | |
293 ;;; $ cannot begin a filename, and - cannot be used as the first or last | |
294 ;;; character. | |
295 ;;; | |
296 ;;; Tips: | |
297 ;;; 1. Although VMS is not case sensitive, EMACS running under UNIX is. | |
298 ;;; Therefore, to access a VMS file, you must enter the filename with upper | |
299 ;;; case letters. | |
300 ;;; 2. To access the latest version of file under VMS, you use the filename | |
301 ;;; without the ";" and version number. You should always edit the latest | |
302 ;;; version of a file. If you want to edit an earlier version, copy it to a | |
303 ;;; new file first. This has nothing to do with ange-ftp, but is simply | |
304 ;;; good VMS operating practice. Therefore, to edit FILE.TXT;3 (say 3 is | |
305 ;;; latest version), do C-x C-f /ymir.claremont.edu:FILE.TXT. If you | |
306 ;;; inadvertently do C-x C-f /ymir.claremont.edu:FILE.TXT;3, you will find | |
307 ;;; that VMS will not allow you to save the file because it will refuse to | |
308 ;;; overwrite FILE.TXT;3, but instead will want to create FILE.TXT;4, and | |
309 ;;; attach the buffer to this file. To get out of this situation, M-x | |
310 ;;; write-file /ymir.claremont.edu:FILE.TXT will attach the buffer to | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
311 ;;; latest version of the file. For this reason, in dired "f" |
1106 | 312 ;;; (dired-find-file), always loads the file sans version, whereas "v", |
313 ;;; (dired-view-file), always loads the explicit version number. The | |
314 ;;; reasoning being that it reasonable to view old versions of a file, but | |
315 ;;; not to edit them. | |
316 ;;; 3. EMACS has a feature in which it does environment variable substitution | |
317 ;;; in filenames. Therefore, to enter a $ in a filename, you must quote it | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
318 ;;; by typing $$. |
1106 | 319 |
320 ;;; MTS support: | |
321 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
322 ;;; Ange-ftp has full support for hosts running |
1106 | 323 ;;; the Michigan terminal system. It should be able to automatically |
324 ;;; recognize any MTS machine. However, if it fails to do this, you can use | |
325 ;;; the command ange-ftp-add-mts-host. As well, you can set the variable | |
326 ;;; ange-ftp-mts-host-regexp in your .emacs file. We would be grateful if you | |
327 ;;; would report any failures to automatically recognize a MTS host as a bug. | |
328 ;;; | |
329 ;;; Filename syntax: | |
330 ;;; | |
331 ;;; MTS filenames are entered in a UNIX-y way. For example, if your account | |
332 ;;; was YYYY, the file FILE in the account XXXX: on mtsg.ubc.ca would be | |
333 ;;; entered as | |
334 ;;; /YYYY@mtsg.ubc.ca:/XXXX:/FILE | |
335 ;;; In other words, MTS accounts are treated as UNIX directories. Of course, | |
336 ;;; to access a file in another account, you must have access permission for | |
337 ;;; it. If FILE were in your own account, then you could enter it in a | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
338 ;;; relative name fashion as |
1106 | 339 ;;; /YYYY@mtsg.ubc.ca:FILE |
340 ;;; MTS filenames can be up to 12 characters. Like UNIX, the structure of the | |
341 ;;; filename does not contain a TYPE (i.e. it can have as many "."'s as you | |
342 ;;; like.) MTS filenames are always in upper case, and hence be sure to enter | |
343 ;;; them as such! MTS is not case sensitive, but an EMACS running under UNIX | |
344 ;;; is. | |
345 | |
346 ;;; CMS support: | |
347 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
348 ;;; Ange-ftp has full support for hosts running |
1106 | 349 ;;; CMS. It should be able to automatically recognize any CMS machine. |
350 ;;; However, if it fails to do this, you can use the command | |
351 ;;; ange-ftp-add-cms-host. As well, you can set the variable | |
352 ;;; ange-ftp-cms-host-regexp in your .emacs file. We would be grateful if you | |
353 ;;; would report any failures to automatically recognize a CMS host as a bug. | |
354 ;;; | |
355 ;;; Filename syntax: | |
356 ;;; | |
357 ;;; CMS filenames are entered in a UNIX-y way. In otherwords, minidisks are | |
358 ;;; treated as UNIX directories. For example to access the file READ.ME in | |
359 ;;; minidisk *.311 on cuvmb.cc.columbia.edu, you would enter | |
360 ;;; /anonymous@cuvmb.cc.columbia.edu:/*.311/READ.ME | |
361 ;;; If *.301 is the default minidisk for this account, you could access | |
362 ;;; FOO.BAR on this minidisk as | |
363 ;;; /anonymous@cuvmb.cc.columbia.edu:FOO.BAR | |
364 ;;; CMS filenames are of the form FILE.TYPE, where both FILE and TYPE can be | |
365 ;;; up to 8 characters. Again, beware that CMS filenames are always upper | |
366 ;;; case, and hence must be entered as such. | |
367 ;;; | |
368 ;;; Tips: | |
369 ;;; 1. CMS machines, with the exception of anonymous accounts, nearly always | |
370 ;;; need an account password. To have ange-ftp send an account password, | |
371 ;;; you can either include it in your .netrc file, or use | |
372 ;;; ange-ftp-set-account. | |
373 ;;; 2. Ange-ftp cannot send "write passwords" for a minidisk. Hopefully, we | |
374 ;;; can fix this. | |
375 ;;; | |
376 ;;; ------------------------------------------------------------------ | |
377 ;;; Bugs: | |
378 ;;; ------------------------------------------------------------------ | |
379 ;;; | |
380 ;;; 1. Umask problems: | |
381 ;;; Be warned that files created by using ange-ftp will take account of the | |
382 ;;; umask of the ftp daemon process rather than the umask of the creating | |
383 ;;; user. This is particulary important when logging in as the root user. | |
384 ;;; The way that I tighten up the ftp daemon's umask under HP-UX is to make | |
385 ;;; sure that the umask is changed to 027 before I spawn /etc/inetd. I | |
386 ;;; suspect that there is something similar on other systems. | |
387 ;;; | |
388 ;;; 2. Some combinations of FTP clients and servers break and get out of sync | |
389 ;;; when asked to list a non-existent directory. Some of the ai.mit.edu | |
390 ;;; machines cause this problem for some FTP clients. Using | |
391 ;;; ange-ftp-kill-process can be used to restart the ftp process, which | |
392 ;;; should get things back in synch. | |
393 ;;; | |
394 ;;; 3. Ange-ftp does not check to make sure that when creating a new file, | |
395 ;;; you provide a valid filename for the remote operating system. | |
396 ;;; If you do not, then the remote FTP server will most likely | |
397 ;;; translate your filename in some way. This may cause ange-ftp to | |
398 ;;; get confused about what exactly is the name of the file. The | |
399 ;;; most common causes of this are using lower case filenames on systems | |
400 ;;; which support only upper case, and using filenames which are too | |
401 ;;; long. | |
402 ;;; | |
403 ;;; 4. Null (blank) passwords confuse both ange-ftp and some FTP daemons. | |
404 ;;; | |
405 ;;; 5. Ange-ftp likes to use pty's to talk to its FTP processes. If GNU Emacs | |
406 ;;; for some reason creates a FTP process that only talks via pipes then | |
407 ;;; ange-ftp won't be getting the information it requires at the time that | |
408 ;;; it wants it since pipes flush at different times to pty's. One | |
409 ;;; disgusting way around this problem is to talk to the FTP process via | |
410 ;;; rlogin which does the 'right' things with pty's. | |
411 ;;; | |
412 ;;; 6. For CMS support, we send too many cd's. Since cd's are cheap, I haven't | |
413 ;;; worried about this too much. Eventually, we should have some caching | |
414 ;;; of the current minidisk. | |
415 ;;; | |
416 ;;; 7. Some CMS machines do not assign a default minidisk when you ftp them as | |
417 ;;; anonymous. It is then necessary to guess a valid minidisk name, and cd | |
418 ;;; to it. This is (understandably) beyond ange-ftp. | |
419 ;;; | |
420 ;;; 8. Remote to remote copying of files on non-Unix machines can be risky. | |
421 ;;; Depending on the variable ange-ftp-binary-file-name-regexp, ange-ftp | |
422 ;;; will use binary mode for the copy. Between systems of different | |
423 ;;; architecture, this still may not be enough to guarantee the integrity | |
424 ;;; of binary files. Binary file transfers from VMS machines are | |
425 ;;; particularly problematical. Should ange-ftp-binary-file-name-regexp be | |
426 ;;; an alist of OS type, regexp pairs? | |
427 ;;; | |
428 ;;; 9. The code to do compression of files over ftp is not as careful as it | |
429 ;;; should be. It deletes the old remote version of the file, before | |
430 ;;; actually checking if the local to remote transfer of the compressed | |
431 ;;; file succeeds. Of course to delete the original version of the file | |
432 ;;; after transferring the compressed version back is also dangerous, | |
433 ;;; because some OS's have severe restrictions on the length of filenames, | |
434 ;;; and when the compressed version is copied back the "-Z" or ".Z" may be | |
435 ;;; truncated. Then, ange-ftp would delete the only remaining version of | |
436 ;;; the file. Maybe ange-ftp should make backups when it compresses files | |
437 ;;; (of course, the backup "~" could also be truncated off, sigh...). | |
438 ;;; Suggestions? | |
439 ;;; | |
440 | |
441 ;;; 10. If a dir listing is attempted for an empty directory on (at least | |
442 ;;; some) VMS hosts, an ftp error is given. This is really an ftp bug, and | |
443 ;;; I don't know how to get ange-ftp work to around it. | |
444 ;;; | |
445 ;;; 11. Bombs on filenames that start with a space. Deals well with filenames | |
446 ;;; containing spaces, but beware that the remote ftpd may not like them | |
447 ;;; much. | |
448 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
449 ;;; 12. The dired support for non-Unix-like systems does not currently work. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
450 ;;; It needs to be reimplemented by modifying the parse-...-listing |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
451 ;;; functions to convert the directory listing to ls -l format. |
1106 | 452 ;;; |
453 ;;; 13. The famous @ bug. As mentioned above in TIPS, ULTRIX marks symlinks | |
454 ;;; with a trailing @ in a ls -alF listing. In order to account for this | |
455 ;;; ange-ftp looks to chop trailing @'s off of symlink names when it is | |
456 ;;; parsing a listing with the F switch. This will cause ange-ftp to | |
457 ;;; incorrectly get the name of a symlink on a non-ULTRIX host if its name | |
458 ;;; ends in an @. ange-ftp will correct itself if you take F out of the | |
459 ;;; dired ls switches (C-u s will allow you to edit the switches). The | |
460 ;;; dired buffer will be automatically reverted, which will allow ange-ftp | |
461 ;;; to fix its files hashtable. A cookie to anyone who can think of a | |
462 ;;; fast, sure-fire way to recognize ULTRIX over ftp. | |
463 | |
464 ;;; If you find any bugs or problems with this package, PLEASE either e-mail | |
465 ;;; the above author, or send a message to the ange-ftp-lovers mailing list | |
466 ;;; below. Ideas and constructive comments are especially welcome. | |
467 | |
468 ;;; ange-ftp-lovers: | |
469 ;;; | |
470 ;;; ange-ftp has its own mailing list modestly called ange-ftp-lovers. All | |
471 ;;; users of ange-ftp are welcome to subscribe (see below) and to discuss | |
472 ;;; aspects of ange-ftp. New versions of ange-ftp are posted periodically to | |
473 ;;; the mailing list. | |
474 ;;; | |
475 ;;; To [un]subscribe to ange-ftp-lovers, or to report mailer problems with the | |
476 ;;; list, please mail one of the following addresses: | |
477 ;;; | |
478 ;;; ange-ftp-lovers-request@anorman.hpl.hp.com | |
479 ;;; or | |
480 ;;; ange-ftp-lovers-request%anorman.hpl.hp.com@hplb.hpl.hp.com | |
481 ;;; | |
482 ;;; Please don't forget the -request part. | |
483 ;;; | |
484 ;;; For mail to be posted directly to ange-ftp-lovers, send to one of the | |
485 ;;; following addresses: | |
486 ;;; | |
487 ;;; ange-ftp-lovers@anorman.hpl.hp.com | |
488 ;;; or | |
489 ;;; ange-ftp-lovers%anorman.hpl.hp.com@hplb.hpl.hp.com | |
490 ;;; | |
491 ;;; Alternatively, there is a mailing list that only gets announcements of new | |
492 ;;; ange-ftp releases. This is called ange-ftp-lovers-announce, and can be | |
493 ;;; subscribed to by e-mailing to the -request address as above. Please make | |
494 ;;; it clear in the request which mailing list you wish to join. | |
495 | |
496 ;;; The latest version of ange-ftp can usually be obtained via anonymous ftp | |
497 ;;; from: | |
498 ;;; alpha.gnu.ai.mit.edu:ange-ftp/ange-ftp.tar.Z | |
499 ;;; or: | |
500 ;;; ugle.unit.no:/pub/gnu/emacs-lisp/ange-ftp.tar.Z | |
501 ;;; or: | |
502 ;;; archive.cis.ohio-state.edu:pub/gnu/emacs/elisp-archive/packages/ange-ftp.tar.Z | |
503 | |
504 ;;; The archives for ange-ftp-lovers can be found via anonymous ftp under: | |
505 ;;; | |
506 ;;; ftp.reed.edu:pub/mailing-lists/ange-ftp/ | |
507 | |
508 ;;; ----------------------------------------------------------- | |
509 ;;; Technical information on this package: | |
510 ;;; ----------------------------------------------------------- | |
511 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
512 ;;; ange-ftp works by putting a handler on file-name-handler-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
513 ;;; which is called by many primitives, and a few non-primitives, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
514 ;;; whenever they see a file name of the appropriate sort. |
1106 | 515 |
516 ;;; Checklist for adding non-UNIX support for TYPE | |
517 ;;; | |
518 ;;; The following functions may need TYPE versions: | |
519 ;;; (not all functions will be needed for every OS) | |
520 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
521 ;;; ange-ftp-fix-name-for-TYPE |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
522 ;;; ange-ftp-fix-dir-name-for-TYPE |
1106 | 523 ;;; ange-ftp-TYPE-host |
524 ;;; ange-ftp-TYPE-add-host | |
525 ;;; ange-ftp-parse-TYPE-listing | |
526 ;;; ange-ftp-TYPE-delete-file-entry | |
527 ;;; ange-ftp-TYPE-add-file-entry | |
528 ;;; ange-ftp-TYPE-file-name-as-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
529 ;;; ange-ftp-TYPE-make-compressed-filename |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
530 ;;; ange-ftp-TYPE-file-name-sans-versions |
1106 | 531 ;;; |
532 ;;; Variables: | |
533 ;;; | |
534 ;;; ange-ftp-TYPE-host-regexp | |
535 ;;; May need to add TYPE to ange-ftp-dumb-host-types | |
536 ;;; | |
537 ;;; Check the following functions for OS dependent coding: | |
538 ;;; | |
539 ;;; ange-ftp-host-type | |
540 ;;; ange-ftp-guess-host-type | |
541 ;;; ange-ftp-allow-child-lookup | |
542 | |
543 ;;; Host type conventions: | |
544 ;;; | |
545 ;;; The function ange-ftp-host-type and the variable ange-ftp-dired-host-type | |
546 ;;; (mostly) follow the following conventions for remote host types. At | |
547 ;;; least, I think that future code should try to follow these conventions, | |
548 ;;; and the current code should eventually be made compliant. | |
549 ;;; | |
550 ;;; nil = local host type, whatever that is (probably unix). | |
551 ;;; Think nil as in "not a remote host". This value is used by | |
552 ;;; ange-ftp-dired-host-type for local buffers. | |
553 ;;; | |
554 ;;; t = a remote host of unknown type. Think t is in true, it's remote. | |
555 ;;; Currently, 'unix is used as the default remote host type. | |
556 ;;; Maybe we should use t. | |
557 ;;; | |
558 ;;; 'type = a remote host of TYPE type. | |
559 ;;; | |
560 ;;; 'type:list = a remote host of TYPE type, using a specialized ftp listing | |
561 ;;; program called list. This is currently only used for Unix | |
562 ;;; dl (descriptive listings), when ange-ftp-dired-host-type | |
563 ;;; is set to 'unix:dl. | |
564 | |
565 ;;; Bug report codes: | |
566 ;;; | |
567 ;;; Because of their naive faith in this code, there are certain situations | |
568 ;;; which the writers of this program believe could never happen. However, | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
569 ;;; being realists they have put calls to `error' in the program at these |
1106 | 570 ;;; points. These errors provide a code, which is an integer, greater than 1. |
571 ;;; To aid debugging. the error codes, and the functions in which they reside | |
572 ;;; are listed below. | |
573 ;;; | |
574 ;;; 1: See ange-ftp-ls | |
575 ;;; | |
576 | |
577 ;;; ----------------------------------------------------------- | |
578 ;;; Hall of fame: | |
579 ;;; ----------------------------------------------------------- | |
580 ;;; | |
581 ;;; Thanks to Roland McGrath for improving the filename syntax handling, | |
582 ;;; for suggesting many enhancements and for numerous cleanups to the code. | |
583 ;;; | |
584 ;;; Thanks to Jamie Zawinski for bugfixes and for ideas such as gateways. | |
585 ;;; | |
586 ;;; Thanks to Ken Laprade for improved .netrc parsing, password reading, and | |
587 ;;; dired / shell auto-loading. | |
588 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
589 ;;; Thanks to Sebastian Kremer for dired support and for many ideas and |
1106 | 590 ;;; bugfixes. |
591 ;;; | |
592 ;;; Thanks to Joe Wells for bugfixes, the original non-UNIX system support, | |
593 ;;; VOS support, and hostname completion. | |
594 ;;; | |
595 ;;; Thanks to Nakagawa Takayuki for many good ideas, filename-completion, help | |
596 ;;; with file-name expansion, efficiency worries, stylistic concerns and many | |
597 ;;; bugfixes. | |
598 ;;; | |
599 ;;; Thanks to Sandy Rutherford who re-wrote most of ange-ftp to support VMS, | |
600 ;;; MTS, CMS and UNIX-dls. Sandy also added dired-support for non-UNIX OS and | |
601 ;;; auto-recognition of the host type. | |
602 ;;; | |
603 ;;; Thanks to Dave Smith who wrote the info file for ange-ftp. | |
604 ;;; | |
605 ;;; Finally, thanks to Keith Waclena, Mark D. Baushke, Terence Kelleher, Ping | |
606 ;;; Zhou, Edward Vielmetti, Jack Repenning, Mike Balenger, Todd Kaufmann, | |
607 ;;; Kjetil Svarstad, Tom Wurgler, Linus Tolke, Niko Makila, Carl Edman, Bill | |
608 ;;; Trost, Dave Brennan, Dan Jacobson, Andy Scott, Steve Anderson, Sanjay | |
609 ;;; Mathur, the folks on the ange-ftp-lovers mailing list and many others | |
610 ;;; whose names I've forgotten who have helped to debug and fix problems with | |
611 ;;; ange-ftp.el. | |
612 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
613 (require 'comint) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
614 |
1106 | 615 ;;;; ------------------------------------------------------------ |
616 ;;;; User customization variables. | |
617 ;;;; ------------------------------------------------------------ | |
618 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
619 (defvar ange-ftp-name-format |
1106 | 620 '("^/\\(\\([^@/:]*\\)@\\)?\\([^@/:]*\\):\\(.*\\)" . (3 2 4)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
621 "*Format of a fully expanded remote file name. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
622 This is a list of the form \(REGEXP HOST USER NAME\), |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
623 where REGEXP is a regular expression matching |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
624 the full remote name, and HOST, USER, and NAME are the numbers of |
1106 | 625 parenthesized expressions in REGEXP for the components (in that order).") |
626 | |
627 ;; ange-ftp-multi-skip-msgs should only match ###-, where ### is one of | |
628 ;; the number codes corresponding to ange-ftp-good-msgs or ange-ftp-fatal-msgs. | |
629 ;; Otherwise, ange-ftp will go into multi-skip mode, and never come out. | |
630 | |
631 (defvar ange-ftp-multi-msgs | |
632 "^220-\\|^230-\\|^226\\|^25.-\\|^221-\\|^200-\\|^530-\\|^4[25]1-" | |
633 "*Regular expression matching messages from the ftp process that start | |
634 a multiline reply.") | |
635 | |
636 (defvar ange-ftp-good-msgs | |
637 "^220 \\|^230 \\|^226 \\|^25. \\|^221 \\|^200 \\|^[Hh]ash mark" | |
638 "*Regular expression matching messages from the ftp process that indicate | |
639 that the action that was initiated has completed successfully.") | |
640 | |
641 ;; CMS and the odd VMS machine say 200 Port rather than 200 PORT. | |
642 ;; Also CMS machines use a multiline 550- reply to say that you | |
643 ;; don't have write permission. ange-ftp gets into multi-line skip | |
644 ;; mode and hangs. Have it ignore 550- instead. It will then barf | |
645 ;; when it gets the 550 line, as it should. | |
646 | |
647 (defvar ange-ftp-skip-msgs | |
648 (concat "^200 \\(PORT\\|Port\\) \\|^331 \\|^150 \\|^350 \\|^[0-9]+ bytes \\|" | |
649 "^Connected \\|^$\\|^Remote system\\|^Using\\|^ \\|Password:\\|" | |
650 "^local:\\|^Trying\\|^125 \\|^550-\\|^221 .*oodbye") | |
651 "*Regular expression matching messages from the ftp process that can be | |
652 ignored.") | |
653 | |
654 (defvar ange-ftp-fatal-msgs | |
655 (concat "^ftp: \\|^Not connected\\|^530 \\|^4[25]1 \\|rcmd: \\|" | |
656 "^No control connection\\|unknown host\\|^lost connection") | |
657 "*Regular expression matching messages from the FTP process that indicate | |
658 something has gone drastically wrong attempting the action that was | |
659 initiated and that the FTP process should (or already has) been killed.") | |
660 | |
661 (defvar ange-ftp-gateway-fatal-msgs | |
662 "No route to host\\|Connection closed\\|No such host\\|Login incorrect" | |
663 "*Regular expression matching messages from the rlogin / telnet process that | |
664 indicates that logging in to the gateway machine has gone wrong.") | |
665 | |
666 (defvar ange-ftp-xfer-size-msgs | |
667 "^150 .* connection for .* (\\([0-9]+\\) bytes)" | |
668 "*Regular expression used to determine the number of bytes in a FTP transfer.") | |
669 | |
670 (defvar ange-ftp-tmp-name-template "/tmp/ange-ftp" | |
671 "*Template used to create temporary files.") | |
672 | |
673 (defvar ange-ftp-gateway-tmp-name-template "/tmp/ange-ftp" | |
674 "*Template used to create temporary files when ftp-ing through a gateway. | |
675 Files starting with this prefix need to be accessible from BOTH the local | |
676 machine and the gateway machine, and need to have the SAME name on both | |
677 machines, that is, /tmp is probably NOT what you want, since that is rarely | |
678 cross-mounted.") | |
679 | |
680 (defvar ange-ftp-netrc-filename "~/.netrc" | |
681 "*File in .netrc format to search for passwords.") | |
682 | |
683 (defvar ange-ftp-disable-netrc-security-check nil | |
684 "*If non-nil avoid checking permissions on the .netrc file.") | |
685 | |
686 (defvar ange-ftp-default-user nil | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
687 "*User name to use when none is specied in a file name. |
1106 | 688 If nil, then the name under which the user is logged in is used. |
689 If non-nil but not a string, the user is prompted for the name.") | |
690 | |
691 (defvar ange-ftp-default-password nil | |
692 "*Password to use when the user is the same as ange-ftp-default-user.") | |
693 | |
694 (defvar ange-ftp-default-account nil | |
695 "*Account password to use when the user is the same as ange-ftp-default-user.") | |
696 | |
1174 | 697 (defvar ange-ftp-generate-anonymous-password t |
1106 | 698 "*If t, use a password of user@host when logging in as the anonymous user. |
699 If a string then use that as the password. | |
700 If nil then prompt the user for a password.") | |
701 | |
702 (defvar ange-ftp-dumb-unix-host-regexp nil | |
703 "*If non-nil, if the host being ftp'd to matches this regexp then the FTP | |
704 process uses the \'dir\' command to get directory information.") | |
705 | |
706 (defvar ange-ftp-binary-file-name-regexp | |
707 (concat "\\.Z$\\|\\.lzh$\\|\\.arc$\\|\\.zip$\\|\\.zoo$\\|\\.tar$\\|" | |
708 "\\.dvi$\\|\\.ps$\\|\\.elc$\\|TAGS$\\|\\.gif$\\|" | |
709 "\\.EXE\\(;[0-9]+\\)?$\\|\\.Z-part-..$") | |
710 "*If a file matches this regexp then it is transferred in binary mode.") | |
711 | |
712 (defvar ange-ftp-gateway-host nil | |
713 "*Name of host to use as gateway machine when local FTP isn't possible.") | |
714 | |
715 (defvar ange-ftp-local-host-regexp ".*" | |
716 "*If a host being FTP'd to matches this regexp then the ftp process is started | |
717 locally, otherwise the FTP process is started on \`ange-ftp-gateway-host\' | |
718 instead.") | |
719 | |
720 (defvar ange-ftp-gateway-program-interactive nil | |
721 "*If non-nil then the gateway program is expected to connect to the gateway | |
722 machine and eventually give a shell prompt. Both telnet and rlogin do something | |
723 like this.") | |
724 | |
725 (defvar ange-ftp-gateway-program (if (eq system-type 'hpux) "remsh" "rsh") | |
726 "*Name of program to spawn a shell on the gateway machine. Valid candidates | |
727 are rsh (remsh on hp-ux), telnet and rlogin. See also the gateway variable | |
728 above.") | |
729 | |
730 (defvar ange-ftp-gateway-prompt-pattern "^[^#$%>;]*[#$%>;] *" | |
731 "*Regexp used to detect that the logging-in sequence is completed on the | |
732 gateway machine and that the shell is now awaiting input. Make this regexp as | |
733 strict as possible; it shouldn't match *anything* at all except the user's | |
734 initial prompt. The above string will fail under most SUN-3's since it | |
735 matches the login banner.") | |
736 | |
737 (defvar ange-ftp-gateway-setup-term-command | |
738 (if (eq system-type 'hpux) | |
739 "stty -onlcr -echo\n" | |
740 "stty -echo nl\n") | |
741 "*Command to use after logging in to the gateway machine to stop the terminal | |
742 echoing each command and to strip out trailing ^M characters.") | |
743 | |
744 (defvar ange-ftp-smart-gateway nil | |
745 "*If the gateway FTP is smart enough to use proxy server, then don't bother | |
746 telnetting etc, just issue a user@host command instead.") | |
747 | |
748 (defvar ange-ftp-smart-gateway-port "21" | |
749 "*Port on gateway machine to use when smart gateway is in operation.") | |
750 | |
751 (defvar ange-ftp-send-hash t | |
752 "*If non-nil, send the HASH command to the FTP client.") | |
753 | |
754 (defvar ange-ftp-binary-hash-mark-size nil | |
755 "*Default size, in bytes, between hash-marks when transferring a binary file. | |
756 If NIL, this variable will be locally overridden if the FTP client outputs a | |
757 suitable response to the HASH command. If non-NIL then this value takes | |
758 precedence over the local value.") | |
759 | |
760 (defvar ange-ftp-ascii-hash-mark-size 1024 | |
761 "*Default size, in bytes, between hash-marks when transferring an ASCII file. | |
762 This variable is buffer-local and will be locally overridden if the FTP client | |
763 outputs a suitable response to the HASH command.") | |
764 | |
765 (defvar ange-ftp-process-verbose t | |
766 "*If non-NIL then be chatty about interaction with the FTP process.") | |
767 | |
768 (defvar ange-ftp-ftp-program-name "ftp" | |
769 "*Name of FTP program to run.") | |
770 | |
771 (defvar ange-ftp-gateway-ftp-program-name "ftp" | |
772 "*Name of FTP program to run on gateway machine. | |
773 Some AT&T folks claim to use something called `pftp' here.") | |
774 | |
775 (defvar ange-ftp-ftp-program-args '("-i" "-n" "-g" "-v") | |
776 "*A list of arguments passed to the FTP program when started.") | |
777 | |
778 (defvar ange-ftp-nslookup-program nil | |
779 "*If non-NIL then a string naming nslookup program." ) | |
780 | |
781 (defvar ange-ftp-make-backup-files () | |
782 "*A list of operating systems for which ange-ftp will make Emacs backup | |
783 files files on the remote host. For example, '\(unix\) makes sense, but | |
784 '\(unix vms\) or '\(vms\) would be silly, since vms makes its own backups.") | |
785 | |
786 (defvar ange-ftp-retry-time 5 | |
787 "*Number of seconds to wait before retrying if a file or listing | |
788 doesn't arrive. This might need to be increased for very slow connections.") | |
789 | |
790 (defvar ange-ftp-auto-save 0 | |
791 "If 1, allows ange-ftp files to be auto-saved. | |
792 If 0, suppresses auto-saving of ange-ftp files. | |
793 Don't use any other value.") | |
794 | |
795 ;;;; ------------------------------------------------------------ | |
796 ;;;; Hash table support. | |
797 ;;;; ------------------------------------------------------------ | |
798 | |
799 (require 'backquote) | |
800 | |
801 (defun ange-ftp-make-hashtable (&optional size) | |
802 "Make an obarray suitable for use as a hashtable. | |
803 SIZE, if supplied, should be a prime number." | |
804 (make-vector (or size 31) 0)) | |
805 | |
806 (defun ange-ftp-map-hashtable (fun tbl) | |
807 "Call FUNCTION on each key and value in HASHTABLE." | |
808 (mapatoms | |
809 (function | |
810 (lambda (sym) | |
811 (funcall fun (get sym 'key) (get sym 'val)))) | |
812 tbl)) | |
813 | |
814 (defmacro ange-ftp-make-hash-key (key) | |
815 "Convert KEY into a suitable key for a hashtable." | |
816 (` (if (stringp (, key)) | |
817 (, key) | |
818 (prin1-to-string (, key))))) | |
819 | |
820 (defun ange-ftp-get-hash-entry (key tbl) | |
821 "Return the value associated with KEY in HASHTABLE." | |
822 (let ((sym (intern-soft (ange-ftp-make-hash-key key) tbl))) | |
823 (and sym (get sym 'val)))) | |
824 | |
825 (defun ange-ftp-put-hash-entry (key val tbl) | |
826 "Record an association between KEY and VALUE in HASHTABLE." | |
827 (let ((sym (intern (ange-ftp-make-hash-key key) tbl))) | |
828 (put sym 'val val) | |
829 (put sym 'key key))) | |
830 | |
831 (defun ange-ftp-del-hash-entry (key tbl) | |
832 "Copy all symbols except KEY in HASHTABLE and return modified hashtable." | |
833 (let* ((len (length tbl)) | |
834 (new-tbl (ange-ftp-make-hashtable len)) | |
835 (i (1- len))) | |
836 (ange-ftp-map-hashtable | |
837 (function | |
838 (lambda (k v) | |
839 (or (equal k key) | |
840 (ange-ftp-put-hash-entry k v new-tbl)))) | |
841 tbl) | |
842 (while (>= i 0) | |
843 (aset tbl i (aref new-tbl i)) | |
844 (setq i (1- i))) | |
845 tbl)) | |
846 | |
847 (defun ange-ftp-hash-entry-exists-p (key tbl) | |
848 "Return whether there is an association for KEY in TABLE." | |
849 (intern-soft (ange-ftp-make-hash-key key) tbl)) | |
850 | |
851 (defun ange-ftp-hash-table-keys (tbl) | |
1233 | 852 "Return a sorted list of all the active keys in TABLE, as strings." |
1106 | 853 (sort (all-completions "" tbl) |
854 (function string-lessp))) | |
855 | |
856 ;;;; ------------------------------------------------------------ | |
857 ;;;; Internal variables. | |
858 ;;;; ------------------------------------------------------------ | |
859 | |
1670
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
860 (defconst ange-ftp-version "$Revision: 1.12 $") |
1106 | 861 |
862 (defvar ange-ftp-data-buffer-name " *ftp data*" | |
863 "Buffer name to hold directory listing data received from ftp process.") | |
864 | |
865 (defvar ange-ftp-netrc-modtime nil | |
866 "Last modified time of the netrc file from file-attributes.") | |
867 | |
868 (defvar ange-ftp-user-hashtable (ange-ftp-make-hashtable) | |
869 "Hash table holding associations between HOST, USER pairs.") | |
870 | |
871 (defvar ange-ftp-passwd-hashtable (ange-ftp-make-hashtable) | |
872 "Mapping between a HOST, USER pair and a PASSWORD for them.") | |
873 | |
874 (defvar ange-ftp-account-hashtable (ange-ftp-make-hashtable) | |
875 "Mapping between a HOST, USER pair and a ACCOUNT password for them.") | |
876 | |
877 (defvar ange-ftp-files-hashtable (ange-ftp-make-hashtable 97) | |
878 "Hash table for storing directories and their respective files.") | |
879 | |
880 (defvar ange-ftp-ls-cache-lsargs nil | |
881 "Last set of args used by ange-ftp-ls.") | |
882 | |
883 (defvar ange-ftp-ls-cache-file nil | |
884 "Last file passed to ange-ftp-ls.") | |
885 | |
886 (defvar ange-ftp-ls-cache-res nil | |
887 "Last result returned from ange-ftp-ls.") | |
888 | |
889 (defconst ange-ftp-expand-dir-hashtable (ange-ftp-make-hashtable)) | |
890 | |
891 (defconst ange-ftp-expand-dir-regexp "^5.0 \\([^: ]+\\):") | |
892 | |
893 ;; These are local variables in each FTP process buffer. | |
894 (defvar ange-ftp-hash-mark-unit nil) | |
895 (defvar ange-ftp-hash-mark-count nil) | |
896 (defvar ange-ftp-xfer-size nil) | |
897 (defvar ange-ftp-process-string nil) | |
898 (defvar ange-ftp-process-result-line nil) | |
899 (defvar ange-ftp-process-busy nil) | |
900 (defvar ange-ftp-process-result nil) | |
901 (defvar ange-ftp-process-multi-skip nil) | |
902 (defvar ange-ftp-process-msg nil) | |
903 (defvar ange-ftp-process-continue nil) | |
904 (defvar ange-ftp-last-percent nil) | |
905 | |
906 ;; These variables are bound by one function and examined by another. | |
907 ;; Leave them void globally for error checking. | |
908 (defvar ange-ftp-this-file) | |
909 (defvar ange-ftp-this-dir) | |
910 (defvar ange-ftp-this-user) | |
911 (defvar ange-ftp-this-host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
912 (defvar ange-ftp-this-msg) |
1106 | 913 (defvar ange-ftp-completion-ignored-pattern) |
914 (defvar ange-ftp-trample-marker) | |
915 | |
916 ;; New error symbols. | |
917 (put 'ftp-error 'error-conditions '(ftp-error file-error error)) | |
918 ;; (put 'ftp-error 'error-message "FTP error") | |
919 | |
920 ;;; ------------------------------------------------------------ | |
921 ;;; Match-data support (stolen from Kyle I think) | |
922 ;;; ------------------------------------------------------------ | |
923 | |
924 (defmacro ange-ftp-save-match-data (&rest body) | |
925 "Execute the BODY forms, restoring the global value of the match data. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
926 Also makes matching case-sensitive within BODY." |
1106 | 927 (let ((original (make-symbol "match-data")) |
928 case-fold-search) | |
929 (list | |
930 'let (list (list original '(match-data))) | |
931 (list 'unwind-protect | |
932 (cons 'progn body) | |
933 (list 'store-match-data original))))) | |
934 | |
935 (put 'ange-ftp-save-match-data 'lisp-indent-hook 0) | |
936 (put 'ange-ftp-save-match-data 'edebug-form-hook '(&rest form)) | |
937 | |
938 ;;; ------------------------------------------------------------ | |
939 ;;; Enhanced message support. | |
940 ;;; ------------------------------------------------------------ | |
941 | |
942 (defun ange-ftp-message (fmt &rest args) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
943 "Display message in echo area, but indicate if truncated. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
944 Args are as in `message': a format string, plus arguments to be formatted." |
1106 | 945 (let ((msg (apply (function format) fmt args)) |
946 (max (window-width (minibuffer-window)))) | |
947 (if (>= (length msg) max) | |
948 (setq msg (concat "> " (substring msg (- 3 max))))) | |
949 (message "%s" msg))) | |
950 | |
951 (defun ange-ftp-abbreviate-filename (file &optional new) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
952 "Abbreviate the file name FILE relative to the default-directory. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
953 If the optional parameter NEW is given and the non-directory parts match, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
954 only return the directory part of FILE." |
1106 | 955 (ange-ftp-save-match-data |
956 (if (and default-directory | |
957 (string-match (concat "^" | |
958 (regexp-quote default-directory) | |
959 ".") file)) | |
960 (setq file (substring file (1- (match-end 0))))) | |
961 (if (and new | |
962 (string-equal (file-name-nondirectory file) | |
963 (file-name-nondirectory new))) | |
964 (setq file (file-name-directory file))) | |
965 (or file "./"))) | |
966 | |
967 ;;;; ------------------------------------------------------------ | |
968 ;;;; User / Host mapping support. | |
969 ;;;; ------------------------------------------------------------ | |
970 | |
971 (defun ange-ftp-set-user (host user) | |
972 "For a given HOST, set or change the default USER." | |
973 (interactive "sHost: \nsUser: ") | |
974 (ange-ftp-put-hash-entry host user ange-ftp-user-hashtable)) | |
975 | |
976 (defun ange-ftp-get-user (host) | |
977 "Given a HOST, return the default USER." | |
978 (ange-ftp-parse-netrc) | |
979 (let ((user (ange-ftp-get-hash-entry host ange-ftp-user-hashtable))) | |
980 (or user | |
981 (prog1 | |
982 (setq user | |
983 (cond ((stringp ange-ftp-default-user) | |
984 ;; We have a default name. Use it. | |
985 ange-ftp-default-user) | |
986 (ange-ftp-default-user | |
987 ;; Ask the user. | |
988 (let ((enable-recursive-minibuffers t)) | |
989 (read-string (format "User for %s: " host) | |
990 (user-login-name)))) | |
991 ;; Default to the user's login name. | |
992 (t | |
993 (user-login-name)))) | |
994 (ange-ftp-set-user host user))))) | |
995 | |
996 ;;;; ------------------------------------------------------------ | |
997 ;;;; Password support. | |
998 ;;;; ------------------------------------------------------------ | |
999 | |
1000 (defun ange-ftp-read-passwd (prompt &optional default) | |
1001 "Read a password, echoing `.' for each character typed. | |
1002 End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. | |
1003 Optional DEFAULT is password to start with." | |
1004 (let ((pass (if default default "")) | |
1005 (c 0) | |
1006 (echo-keystrokes 0) | |
1007 (cursor-in-echo-area t)) | |
1008 (while (progn (message "%s%s" | |
1009 prompt | |
1010 (make-string (length pass) ?.)) | |
1011 (setq c (read-char)) | |
1012 (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) | |
1013 (if (= c ?\C-u) | |
1014 (setq pass "") | |
1015 (if (and (/= c ?\b) (/= c ?\177)) | |
1016 (setq pass (concat pass (char-to-string c))) | |
1017 (if (> (length pass) 0) | |
1018 (setq pass (substring pass 0 -1)))))) | |
1019 (message "") | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1020 (ange-ftp-repaint-minibuffer) |
1106 | 1021 pass)) |
1022 | |
1023 (defmacro ange-ftp-generate-passwd-key (host user) | |
1024 (` (concat (, host) "/" (, user)))) | |
1025 | |
1026 (defmacro ange-ftp-lookup-passwd (host user) | |
1027 (` (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key (, host) (, user)) | |
1028 ange-ftp-passwd-hashtable))) | |
1029 | |
1030 (defun ange-ftp-set-passwd (host user passwd) | |
1031 "For a given HOST and USER, set or change the associated PASSWORD." | |
1032 (interactive (list (read-string "Host: ") | |
1033 (read-string "User: ") | |
1034 (ange-ftp-read-passwd "Password: "))) | |
1035 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) | |
1036 passwd | |
1037 ange-ftp-passwd-hashtable)) | |
1038 | |
1039 (defun ange-ftp-get-host-with-passwd (user) | |
1040 "Given a USER, return a host we know the password for." | |
1041 (ange-ftp-parse-netrc) | |
1042 (catch 'found-one | |
1043 (ange-ftp-map-hashtable | |
1044 (function (lambda (host val) | |
1045 (if (ange-ftp-lookup-passwd host user) | |
1046 (throw 'found-one host)))) | |
1047 ange-ftp-user-hashtable) | |
1048 (ange-ftp-save-match-data | |
1049 (ange-ftp-map-hashtable | |
1050 (function | |
1051 (lambda (key value) | |
1052 (if (string-match "^[^/]*\\(/\\).*$" key) | |
1053 (let ((host (substring key 0 (match-beginning 1)))) | |
1054 (if (and (string-equal user (substring key (match-end 1))) | |
1055 value) | |
1056 (throw 'found-one host)))))) | |
1057 ange-ftp-passwd-hashtable)) | |
1058 nil)) | |
1059 | |
1060 (defun ange-ftp-get-passwd (host user) | |
1061 "Return the password for specified HOST and USER, asking user if necessary." | |
1062 (ange-ftp-parse-netrc) | |
1063 | |
1064 ;; look up password in the hash table first; user might have overriden the | |
1065 ;; defaults. | |
1066 (cond ((ange-ftp-lookup-passwd host user)) | |
1067 | |
1068 ;; see if default user and password set from the .netrc file. | |
1069 ((and (stringp ange-ftp-default-user) | |
1070 ange-ftp-default-password | |
1071 (string-equal user ange-ftp-default-user)) | |
1072 ange-ftp-default-password) | |
1073 | |
1074 ;; anonymous ftp password is handled specially since there is an | |
1075 ;; unwritten rule about how that is used on the Internet. | |
1076 ((and (or (string-equal user "anonymous") | |
1077 (string-equal user "ftp")) | |
1078 ange-ftp-generate-anonymous-password) | |
1079 (if (stringp ange-ftp-generate-anonymous-password) | |
1080 ange-ftp-generate-anonymous-password | |
1081 (concat (user-login-name) "@" (system-name)))) | |
1082 | |
1083 ;; see if same user has logged in to other hosts; if so then prompt | |
1084 ;; with the password that was used there. | |
1085 (t | |
1086 (let* ((other (ange-ftp-get-host-with-passwd user)) | |
1087 (passwd (if other | |
1088 | |
1089 ;; found another machine with the same user. | |
1090 ;; Try that account. | |
1091 (ange-ftp-read-passwd | |
1092 (format "passwd for %s@%s (same as %s@%s): " | |
1093 user host user other) | |
1094 (ange-ftp-lookup-passwd other user)) | |
1095 | |
1096 ;; I give up. Ask the user for the password. | |
1097 (ange-ftp-read-passwd | |
1098 (format "Password for %s@%s: " user host))))) | |
1099 (ange-ftp-set-passwd host user passwd) | |
1100 passwd)))) | |
1101 | |
1102 ;;;; ------------------------------------------------------------ | |
1103 ;;;; Account support | |
1104 ;;;; ------------------------------------------------------------ | |
1105 | |
1106 ;; Account passwords must be either specified in the .netrc file, or set | |
1107 ;; manually by calling ange-ftp-set-account. For the moment, ange-ftp doesn't | |
1108 ;; check to see whether the FTP process is actually prompting for an account | |
1109 ;; password. | |
1110 | |
1111 (defun ange-ftp-set-account (host user account) | |
1112 "For a given HOST and USER, set or change the associated ACCOUNT password." | |
1113 (interactive (list (read-string "Host: ") | |
1114 (read-string "User: ") | |
1115 (ange-ftp-read-passwd "Account password: "))) | |
1116 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) | |
1117 account | |
1118 ange-ftp-account-hashtable)) | |
1119 | |
1120 (defun ange-ftp-get-account (host user) | |
1121 "Given a HOST and USER, return the FTP account." | |
1122 (ange-ftp-parse-netrc) | |
1123 (or (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key host user) | |
1124 ange-ftp-account-hashtable) | |
1125 (and (stringp ange-ftp-default-user) | |
1126 (string-equal user ange-ftp-default-user) | |
1127 ange-ftp-default-account))) | |
1128 | |
1129 ;;;; ------------------------------------------------------------ | |
1130 ;;;; ~/.netrc support | |
1131 ;;;; ------------------------------------------------------------ | |
1132 | |
1133 (defun ange-ftp-chase-symlinks (file) | |
1233 | 1134 "Return the filename that FILE references, following all symbolic links." |
1106 | 1135 (let (temp) |
1136 (while (setq temp (ange-ftp-real-file-symlink-p file)) | |
1137 (setq file | |
1138 (if (file-name-absolute-p temp) | |
1139 temp | |
1140 (concat (file-name-directory file) temp))))) | |
1141 file) | |
1142 | |
1143 (defun ange-ftp-parse-netrc-token (token limit) | |
1144 "Move along current line looking for the value of the TOKEN. | |
1145 Valid separators between TOKEN and its value are commas and | |
1146 whitespace. Second arg LIMIT is a limit for the search." | |
1147 (if (search-forward token limit t) | |
1148 (let (beg) | |
1149 (skip-chars-forward ", \t\r\n" limit) | |
1150 (if (eq (following-char) ?\") ;quoted token value | |
1151 (progn (forward-char 1) | |
1152 (setq beg (point)) | |
1153 (skip-chars-forward "^\"" limit) | |
1154 (forward-char 1) | |
1155 (buffer-substring beg (1- (point)))) | |
1156 (setq beg (point)) | |
1157 (skip-chars-forward "^, \t\r\n" limit) | |
1158 (buffer-substring beg (point)))))) | |
1159 | |
1160 (defun ange-ftp-parse-netrc-group () | |
1161 "Extract the values for the tokens \`machine\', \`login\', \`password\' | |
1162 and \`account\' in the current buffer. If successful, record the information | |
1163 found." | |
1164 (beginning-of-line) | |
1165 (let ((start (point)) | |
1166 (end (progn (re-search-forward "machine\\|default" | |
1167 (point-max) 'end 2) (point))) | |
1168 machine login password account) | |
1169 (goto-char start) | |
1170 (setq machine (ange-ftp-parse-netrc-token "machine" end) | |
1171 login (ange-ftp-parse-netrc-token "login" end) | |
1172 password (ange-ftp-parse-netrc-token "password" end) | |
1173 account (ange-ftp-parse-netrc-token "account" end)) | |
1174 (if (and machine login) | |
1175 ;; found a `machine` token. | |
1176 (progn | |
1177 (ange-ftp-set-user machine login) | |
1178 (ange-ftp-set-passwd machine login password) | |
1179 (and account | |
1180 (ange-ftp-set-account machine login account))) | |
1181 (goto-char start) | |
1182 (if (search-forward "default" end t) | |
1183 ;; found a `default' token | |
1184 (progn | |
1185 (setq login (ange-ftp-parse-netrc-token "login" end) | |
1186 password (ange-ftp-parse-netrc-token "password" end) | |
1187 account (ange-ftp-parse-netrc-token "account" end)) | |
1188 (and login | |
1189 (setq ange-ftp-default-user login)) | |
1190 (and password | |
1191 (setq ange-ftp-default-password password)) | |
1192 (and account | |
1193 (setq ange-ftp-default-account account))))) | |
1194 (goto-char end))) | |
1195 | |
1196 (defun ange-ftp-parse-netrc () | |
1233 | 1197 "Read in ~/.netrc, if one exists. |
1198 If ~/.netrc file exists and has the correct permissions then extract the | |
1106 | 1199 \`machine\', \`login\', \`password\' and \`account\' information from within." |
1200 | |
1201 ;; We set this before actually doing it to avoid the possibility | |
1202 ;; of an infinite loop if ange-ftp-netrc-filename is an FTP file. | |
1203 (interactive) | |
1204 (let* ((file (ange-ftp-chase-symlinks | |
1205 (ange-ftp-real-expand-file-name ange-ftp-netrc-filename))) | |
1206 (attr (ange-ftp-real-file-attributes file))) | |
1207 (if (and attr ; file exists. | |
1208 (not (equal (nth 5 attr) ange-ftp-netrc-modtime))) ; file changed | |
1209 (ange-ftp-save-match-data | |
1210 (if (or ange-ftp-disable-netrc-security-check | |
1211 (and (eq (nth 2 attr) (user-uid)) ; Same uids. | |
1212 (string-match ".r..------" (nth 8 attr)))) | |
1213 (save-excursion | |
1214 ;; we are cheating a bit here. I'm trying to do the equivalent | |
1215 ;; of find-file on the .netrc file, but then nuke it afterwards. | |
1216 ;; with the bit of logic below we should be able to have | |
1217 ;; encrypted .netrc files. | |
1218 (set-buffer (generate-new-buffer "*ftp-.netrc*")) | |
1219 (ange-ftp-real-insert-file-contents file) | |
1220 (setq buffer-file-name file) | |
1221 (setq default-directory (file-name-directory file)) | |
1222 (normal-mode t) | |
1223 (mapcar 'funcall find-file-hooks) | |
1224 (setq buffer-file-name nil) | |
1225 (goto-char (point-min)) | |
1226 (while (not (eobp)) | |
1227 (ange-ftp-parse-netrc-group)) | |
1228 (kill-buffer (current-buffer))) | |
1229 (ange-ftp-message "%s either not owned by you or badly protected." | |
1230 ange-ftp-netrc-filename) | |
1231 (sit-for 1)) | |
1232 (setq ange-ftp-netrc-modtime (nth 5 attr)))))) | |
1233 | |
1234 (defun ange-ftp-generate-root-prefixes () | |
1235 "Return a list of prefixes of the form 'user@host:' to be used when | |
1236 completion is done in the root directory." | |
1237 (ange-ftp-parse-netrc) | |
1238 (ange-ftp-save-match-data | |
1239 (let (res) | |
1240 (ange-ftp-map-hashtable | |
1241 (function | |
1242 (lambda (key value) | |
1243 (if (string-match "^[^/]*\\(/\\).*$" key) | |
1244 (let ((host (substring key 0 (match-beginning 1))) | |
1245 (user (substring key (match-end 1)))) | |
1246 (setq res (cons (list (concat user "@" host ":")) | |
1247 res)))))) | |
1248 ange-ftp-passwd-hashtable) | |
1249 (ange-ftp-map-hashtable | |
1250 (function (lambda (host user) | |
1251 (setq res (cons (list (concat host ":")) | |
1252 res)))) | |
1253 ange-ftp-user-hashtable) | |
1254 (or res (list nil))))) | |
1255 | |
1256 ;;;; ------------------------------------------------------------ | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1257 ;;;; Remote file name syntax support. |
1106 | 1258 ;;;; ------------------------------------------------------------ |
1259 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1260 (defmacro ange-ftp-ftp-name-component (n ns name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1261 "Extract the Nth ftp file name component from NS." |
1106 | 1262 (` (let ((elt (nth (, n) (, ns)))) |
1263 (if (match-beginning elt) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1264 (substring (, name) (match-beginning elt) (match-end elt)))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1265 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1266 (defvar ange-ftp-ftp-name-arg "") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1267 (defvar ange-ftp-ftp-name-res nil) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1268 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1269 (defun ange-ftp-ftp-name (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1270 "Parse NAME according to `ange-ftp-name-format' (which see). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1271 Returns a list (HOST USER NAME), or nil if NAME does not match the format." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1272 (if (string-equal name ange-ftp-ftp-name-arg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1273 ange-ftp-ftp-name-res |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1274 (setq ange-ftp-ftp-name-arg name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1275 ange-ftp-ftp-name-res |
1106 | 1276 (ange-ftp-save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1277 (if (string-match (car ange-ftp-name-format) name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1278 (let* ((ns (cdr ange-ftp-name-format)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1279 (host (ange-ftp-ftp-name-component 0 ns name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1280 (user (ange-ftp-ftp-name-component 1 ns name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1281 (name (ange-ftp-ftp-name-component 2 ns name))) |
1106 | 1282 (if (zerop (length user)) |
1283 (setq user (ange-ftp-get-user host))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1284 (list host user name)) |
1106 | 1285 nil))))) |
1286 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1287 (defun ange-ftp-replace-name-component (fullname name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1288 "Take a FULLNAME that matches according to ange-ftp-name-format and |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1289 replace the name component with NAME." |
1106 | 1290 (ange-ftp-save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1291 (if (string-match (car ange-ftp-name-format) fullname) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1292 (let* ((ns (cdr ange-ftp-name-format)) |
1106 | 1293 (elt (nth 2 ns))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1294 (concat (substring fullname 0 (match-beginning elt)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1295 name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1296 (substring fullname (match-end elt))))))) |
1106 | 1297 |
1298 ;;;; ------------------------------------------------------------ | |
1299 ;;;; Miscellaneous utils. | |
1300 ;;;; ------------------------------------------------------------ | |
1301 | |
1302 ;; (setq ange-ftp-tmp-keymap (make-sparse-keymap)) | |
1303 ;; (define-key ange-ftp-tmp-keymap "\C-m" 'exit-minibuffer) | |
1304 | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1305 (defun ange-ftp-repaint-minibuffer () |
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1306 "Clear any existing minibuffer message; let the minibuffer contents show." |
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1307 (message nil)) |
1106 | 1308 |
1309 (defun ange-ftp-ftp-process-buffer (host user) | |
1310 "Return the name of the buffer that collects output from the ftp process | |
1311 connected to the given HOST and USER pair." | |
1312 (concat "*ftp " user "@" host "*")) | |
1313 | |
1314 (defun ange-ftp-error (host user msg) | |
1315 "Display the last chunk of output from the ftp process for the given HOST | |
1316 USER pair, and signal an error including MSG in the text." | |
1317 (let ((cur (selected-window)) | |
1318 (pop-up-windows t)) | |
1319 (pop-to-buffer | |
1320 (get-buffer-create | |
1321 (ange-ftp-ftp-process-buffer host user))) | |
1322 (goto-char (point-max)) | |
1323 (select-window cur)) | |
1324 (signal 'ftp-error (list (format "FTP Error: %s" msg)))) | |
1325 | |
1326 (defun ange-ftp-set-buffer-mode () | |
1327 "Set the correct modes for the current buffer if it is visiting a remote | |
1328 file." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1329 (make-local-variable 'make-backup-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1330 (setq make-backup-files ange-ftp-make-backup-files) |
1106 | 1331 (if (and (stringp buffer-file-name) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1332 (ange-ftp-ftp-name buffer-file-name)) |
1106 | 1333 (progn |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
1334 (auto-save-mode ange-ftp-auto-save)))) |
1106 | 1335 |
1336 (defun ange-ftp-kill-ftp-process (buffer) | |
1242
82774f4b69dd
(ange-ftp-kill-ftp-process): Delete spurious ".
Richard M. Stallman <rms@gnu.org>
parents:
1233
diff
changeset
|
1337 "Kill the FTP process associated with BUFFER. |
1233 | 1338 If the BUFFER's visited filename or default-directory is an ftp filename |
1106 | 1339 then kill the related ftp process." |
1340 (interactive "bKill FTP process associated with buffer: ") | |
1341 (if (null buffer) | |
1342 (setq buffer (current-buffer))) | |
1343 (let ((file (or (buffer-file-name) default-directory))) | |
1344 (if file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1345 (let ((parsed (ange-ftp-ftp-name (expand-file-name file)))) |
1106 | 1346 (if parsed |
1347 (let ((host (nth 0 parsed)) | |
1348 (user (nth 1 parsed))) | |
1349 (kill-buffer (ange-ftp-ftp-process-buffer host user)))))))) | |
1350 | |
1351 (defun ange-ftp-quote-string (string) | |
1352 "Quote any characters in STRING that may confuse the ftp process." | |
1353 (apply (function concat) | |
1354 (mapcar (function | |
1355 (lambda (char) | |
1356 (if (or (<= char ? ) | |
1357 (> char ?\~) | |
1358 (= char ?\") | |
1359 (= char ?\\)) | |
1360 (vector ?\\ char) | |
1361 (vector char)))) | |
1362 string))) | |
1363 | |
1364 (defun ange-ftp-barf-if-not-directory (directory) | |
1365 (or (file-directory-p directory) | |
1366 (signal 'file-error | |
1367 (list "Opening directory" | |
1368 (if (file-exists-p directory) | |
1369 "not a directory" | |
1370 "no such file or directory") | |
1371 directory)))) | |
1372 | |
1373 ;;;; ------------------------------------------------------------ | |
1374 ;;;; FTP process filter support. | |
1375 ;;;; ------------------------------------------------------------ | |
1376 | |
1377 (defun ange-ftp-process-handle-line (line proc) | |
1378 "Look at the given LINE from the ftp process PROC. Try to catagorize it | |
1379 into one of four categories: good, skip, fatal, or unknown." | |
1380 (cond ((string-match ange-ftp-xfer-size-msgs line) | |
1381 (setq ange-ftp-xfer-size | |
1382 (ash (string-to-int (substring line | |
1383 (match-beginning 1) | |
1384 (match-end 1))) | |
1385 -10))) | |
1386 ((string-match ange-ftp-skip-msgs line) | |
1387 t) | |
1388 ((string-match ange-ftp-good-msgs line) | |
1389 (setq ange-ftp-process-busy nil | |
1390 ange-ftp-process-result t | |
1391 ange-ftp-process-result-line line)) | |
1392 ((string-match ange-ftp-fatal-msgs line) | |
1393 (delete-process proc) | |
1394 (setq ange-ftp-process-busy nil | |
1395 ange-ftp-process-result-line line)) | |
1396 ((string-match ange-ftp-multi-msgs line) | |
1397 (setq ange-ftp-process-multi-skip t)) | |
1398 (ange-ftp-process-multi-skip | |
1399 t) | |
1400 (t | |
1401 (setq ange-ftp-process-busy nil | |
1402 ange-ftp-process-result-line line)))) | |
1403 | |
1404 (defun ange-ftp-process-log-string (proc str) | |
1405 "For a given PROCESS, log the given STRING at the end of its | |
1406 associated buffer." | |
1407 (let ((old-buffer (current-buffer))) | |
1408 (unwind-protect | |
1409 (let (moving) | |
1410 (set-buffer (process-buffer proc)) | |
1411 (setq moving (= (point) (process-mark proc))) | |
1412 (save-excursion | |
1413 ;; Insert the text, moving the process-marker. | |
1414 (goto-char (process-mark proc)) | |
1415 (insert str) | |
1416 (set-marker (process-mark proc) (point))) | |
1417 (if moving (goto-char (process-mark proc)))) | |
1418 (set-buffer old-buffer)))) | |
1419 | |
1420 (defun ange-ftp-set-xfer-size (host user bytes) | |
1421 "Set the size of the next FTP transfer in bytes." | |
1422 (let ((proc (ange-ftp-get-process host user))) | |
1423 (if proc | |
1424 (let ((buf (process-buffer proc))) | |
1425 (if buf | |
1426 (save-excursion | |
1427 (set-buffer buf) | |
1428 (setq ange-ftp-xfer-size (ash bytes -10)))))))) | |
1429 | |
1430 (defun ange-ftp-process-handle-hash (str) | |
1431 "Remove hash marks from STRING and display count so far." | |
1432 (setq str (concat (substring str 0 (match-beginning 0)) | |
1433 (substring str (match-end 0))) | |
1434 ange-ftp-hash-mark-count (+ (- (match-end 0) | |
1435 (match-beginning 0)) | |
1436 ange-ftp-hash-mark-count)) | |
1437 (and ange-ftp-process-msg | |
1438 ange-ftp-process-verbose | |
1439 (not (eq (selected-window) (minibuffer-window))) | |
1440 (not (boundp 'search-message)) ;screws up isearch otherwise | |
1441 (not cursor-in-echo-area) ;screws up y-or-n-p otherwise | |
1442 (let ((kbytes (ash (* ange-ftp-hash-mark-unit | |
1443 ange-ftp-hash-mark-count) | |
1444 -6))) | |
1445 (if (zerop ange-ftp-xfer-size) | |
1446 (ange-ftp-message "%s...%dk" ange-ftp-process-msg kbytes) | |
1447 (let ((percent (/ (* 100 kbytes) ange-ftp-xfer-size))) | |
1448 ;; cut out the redisplay of identical %-age messages. | |
1449 (if (not (eq percent ange-ftp-last-percent)) | |
1450 (progn | |
1451 (setq ange-ftp-last-percent percent) | |
1452 (ange-ftp-message "%s...%d%%" ange-ftp-process-msg percent))))))) | |
1453 str) | |
1454 | |
1455 (defun ange-ftp-call-cont (cont result line) | |
1456 "Call the function specified by CONT. CONT can be either a function or a | |
1457 list of a function and some args. The first two parameters passed to the | |
1458 function will be RESULT and LINE. The remaining args will be taken from CONT | |
1459 if a list was passed." | |
1460 (if cont | |
1461 (if (and (listp cont) | |
1462 (not (eq (car cont) 'lambda))) | |
1463 (apply (car cont) result line (cdr cont)) | |
1464 (funcall cont result line)))) | |
1465 | |
1466 (defun ange-ftp-process-filter (proc str) | |
1467 "Build up a complete line of output from the ftp PROCESS and pass it | |
1468 on to ange-ftp-process-handle-line to deal with." | |
1469 (let ((buffer (process-buffer proc)) | |
1470 (old-buffer (current-buffer))) | |
1471 | |
1472 ;; see if the buffer is still around... it could have been deleted. | |
1473 (if (buffer-name buffer) | |
1474 (unwind-protect | |
1475 (ange-ftp-save-match-data | |
1476 (set-buffer (process-buffer proc)) | |
1477 | |
1478 ;; handle hash mark printing | |
1479 (and ange-ftp-hash-mark-unit | |
1480 ange-ftp-process-busy | |
1481 (string-match "^#+$" str) | |
1482 (setq str (ange-ftp-process-handle-hash str))) | |
1483 (ange-ftp-process-log-string proc str) | |
1484 (if ange-ftp-process-busy | |
1485 (progn | |
1486 (setq ange-ftp-process-string (concat ange-ftp-process-string | |
1487 str)) | |
1488 | |
1489 ;; if we gave an empty password to the USER command earlier | |
1490 ;; then we should send a null password now. | |
1491 (if (string-match "Password: *$" ange-ftp-process-string) | |
1492 (send-string proc "\n")))) | |
1493 (while (and ange-ftp-process-busy | |
1494 (string-match "\n" ange-ftp-process-string)) | |
1495 (let ((line (substring ange-ftp-process-string | |
1496 0 | |
1497 (match-beginning 0)))) | |
1498 (setq ange-ftp-process-string (substring ange-ftp-process-string | |
1499 (match-end 0))) | |
1500 (while (string-match "^ftp> *" line) | |
1501 (setq line (substring line (match-end 0)))) | |
1502 (ange-ftp-process-handle-line line proc))) | |
1503 | |
1504 ;; has the ftp client finished? if so then do some clean-up | |
1505 ;; actions. | |
1506 (if (not ange-ftp-process-busy) | |
1507 (progn | |
1508 ;; reset the xfer size | |
1509 (setq ange-ftp-xfer-size 0) | |
1510 | |
1511 ;; issue the "done" message since we've finished. | |
1512 (if (and ange-ftp-process-msg | |
1513 ange-ftp-process-verbose | |
1514 ange-ftp-process-result) | |
1515 (progn | |
1516 (ange-ftp-message "%s...done" ange-ftp-process-msg) | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1517 (ange-ftp-repaint-minibuffer) |
1106 | 1518 (setq ange-ftp-process-msg nil))) |
1519 | |
1520 ;; is there a continuation we should be calling? if so, | |
1521 ;; we'd better call it, making sure we only call it once. | |
1522 (if ange-ftp-process-continue | |
1523 (let ((cont ange-ftp-process-continue)) | |
1524 (setq ange-ftp-process-continue nil) | |
1525 (ange-ftp-call-cont cont | |
1526 ange-ftp-process-result | |
1527 ange-ftp-process-result-line)))))) | |
1528 (set-buffer old-buffer))))) | |
1529 | |
1530 (defun ange-ftp-process-sentinel (proc str) | |
1531 "When ftp process changes state, nuke all file-entries in cache." | |
1532 (ange-ftp-save-match-data | |
1533 (let ((name (process-name proc))) | |
1534 (if (string-match "\\*ftp \\([^@]+\\)@\\([^*]+\\)*" name) | |
1535 (let ((user (substring name (match-beginning 1) (match-end 1))) | |
1536 (host (substring name (match-beginning 2) (match-end 2)))) | |
1537 (ange-ftp-wipe-file-entries host user)))) | |
1538 (setq ange-ftp-ls-cache-file nil))) | |
1539 | |
1540 ;;;; ------------------------------------------------------------ | |
1541 ;;;; Gateway support. | |
1542 ;;;; ------------------------------------------------------------ | |
1543 | |
1544 (defun ange-ftp-use-gateway-p (host) | |
1545 "Returns whether to access this host via a normal (non-smart) gateway." | |
1546 ;; yes, I know that I could simplify the following expression, but it is | |
1547 ;; clearer (to me at least) this way. | |
1548 (and (not ange-ftp-smart-gateway) | |
1549 (ange-ftp-save-match-data | |
1550 (not (string-match ange-ftp-local-host-regexp host))))) | |
1551 | |
1552 (defun ange-ftp-use-smart-gateway-p (host) | |
1553 "Returns whether to access this host via a smart gateway." | |
1554 (and ange-ftp-smart-gateway | |
1555 (ange-ftp-save-match-data | |
1556 (not (string-match ange-ftp-local-host-regexp host))))) | |
1557 | |
1558 | |
1559 ;;; ------------------------------------------------------------ | |
1560 ;;; Temporary file location and deletion... | |
1561 ;;; ------------------------------------------------------------ | |
1562 | |
1563 (defvar ange-ftp-tmp-name-files ()) | |
1564 (defvar ange-ftp-tmp-name-hashtable (ange-ftp-make-hashtable 10)) | |
1565 (defvar ange-ftp-pid nil) | |
1566 | |
1567 (defun ange-ftp-get-pid () | |
1568 "Half-hearted attempt to get the current process's id." | |
1569 (setq ange-ftp-pid (substring (make-temp-name "") 1))) | |
1570 | |
1571 (defun ange-ftp-make-tmp-name (host) | |
1572 "This routine will return the name of a new file." | |
1573 (let* ((template (if (ange-ftp-use-gateway-p host) | |
1574 ange-ftp-gateway-tmp-name-template | |
1575 ange-ftp-tmp-name-template)) | |
1576 (pid (or ange-ftp-pid (ange-ftp-get-pid))) | |
1577 (start ?a) | |
1578 file entry) | |
1579 (while | |
1580 (progn | |
1581 (setq file (format "%s%c%s" template start pid)) | |
1582 (setq entry (intern file ange-ftp-tmp-name-hashtable)) | |
1583 (or (memq entry ange-ftp-tmp-name-files) | |
1584 (ange-ftp-real-file-exists-p file))) | |
1585 (if (> (setq start (1+ start)) ?z) | |
1586 (progn | |
1587 (setq template (concat template "X")) | |
1588 (setq start ?a)))) | |
1589 (setq ange-ftp-tmp-name-files | |
1590 (cons entry ange-ftp-tmp-name-files)) | |
1591 file)) | |
1592 | |
1593 (defun ange-ftp-del-tmp-name (temp) | |
1594 (setq ange-ftp-tmp-name-files | |
1595 (delq (intern temp ange-ftp-tmp-name-hashtable) | |
1596 ange-ftp-tmp-name-files)) | |
1597 (condition-case () | |
1598 (ange-ftp-real-delete-file temp) | |
1599 (error nil))) | |
1600 | |
1601 ;;;; ------------------------------------------------------------ | |
1602 ;;;; Interactive gateway program support. | |
1603 ;;;; ------------------------------------------------------------ | |
1604 | |
1605 (defvar ange-ftp-gwp-running t) | |
1606 (defvar ange-ftp-gwp-status nil) | |
1607 | |
1608 (defun ange-ftp-gwp-sentinel (proc str) | |
1609 (setq ange-ftp-gwp-running nil)) | |
1610 | |
1611 (defun ange-ftp-gwp-filter (proc str) | |
1612 (ange-ftp-save-match-data | |
1613 (ange-ftp-process-log-string proc str) | |
1614 (cond ((string-match "login: *$" str) | |
1615 (send-string proc | |
1616 (concat | |
1617 (let ((ange-ftp-default-user t)) | |
1618 (ange-ftp-get-user ange-ftp-gateway-host)) | |
1619 "\n"))) | |
1620 ((string-match "Password: *$" str) | |
1621 (send-string proc | |
1622 (concat | |
1623 (ange-ftp-get-passwd ange-ftp-gateway-host | |
1624 (ange-ftp-get-user | |
1625 ange-ftp-gateway-host)) | |
1626 "\n"))) | |
1627 ((string-match ange-ftp-gateway-fatal-msgs str) | |
1628 (delete-process proc) | |
1629 (setq ange-ftp-gwp-running nil)) | |
1630 ((string-match ange-ftp-gateway-prompt-pattern str) | |
1631 (setq ange-ftp-gwp-running nil | |
1632 ange-ftp-gwp-status t))))) | |
1633 | |
1634 (defun ange-ftp-gwp-start (host user name args) | |
1635 "Login to the gateway machine and fire up an ftp process." | |
1636 (let* ((gw-user (ange-ftp-get-user ange-ftp-gateway-host)) | |
1637 (proc (start-process name name | |
1638 ange-ftp-gateway-program | |
1639 ange-ftp-gateway-host)) | |
1640 (ftp (mapconcat (function identity) args " "))) | |
1641 (process-kill-without-query proc) | |
1642 (set-process-sentinel proc (function ange-ftp-gwp-sentinel)) | |
1643 (set-process-filter proc (function ange-ftp-gwp-filter)) | |
1644 (set-marker (process-mark proc) (point)) | |
1645 (setq ange-ftp-gwp-running t | |
1646 ange-ftp-gwp-status nil) | |
1647 (ange-ftp-message "Connecting to gateway %s..." ange-ftp-gateway-host) | |
1648 (while ange-ftp-gwp-running ;perform login sequence | |
1649 (accept-process-output proc)) | |
1650 (if (not ange-ftp-gwp-status) | |
1651 (ange-ftp-error host user "unable to login to gateway")) | |
1652 (ange-ftp-message "Connecting to gateway %s...done" ange-ftp-gateway-host) | |
1653 (setq ange-ftp-gwp-running t | |
1654 ange-ftp-gwp-status nil) | |
1655 (process-send-string proc ange-ftp-gateway-setup-term-command) | |
1656 (while ange-ftp-gwp-running ;zap ^M's and double echoing. | |
1657 (accept-process-output proc)) | |
1658 (if (not ange-ftp-gwp-status) | |
1659 (ange-ftp-error host user "unable to set terminal modes on gateway")) | |
1660 (setq ange-ftp-gwp-running t | |
1661 ange-ftp-gwp-status nil) | |
1662 (process-send-string proc (concat "exec " ftp "\n")) ;spawn ftp process | |
1663 proc)) | |
1664 | |
1665 ;;;; ------------------------------------------------------------ | |
1666 ;;;; Support for sending commands to the ftp process. | |
1667 ;;;; ------------------------------------------------------------ | |
1668 | |
1669 (defun ange-ftp-raw-send-cmd (proc cmd &optional msg cont nowait) | |
1670 "Low-level routine to send the given ftp CMD to the ftp PROCESS. | |
1671 MSG is an optional message to output before and after the command. | |
1672 If CONT is non-NIL then it is either a function or a list of function and | |
1673 some arguments. The function will be called when the ftp command has completed. | |
1674 If CONT is NIL then this routine will return \( RESULT . LINE \) where RESULT | |
1675 is whether the command was successful, and LINE is the line from the FTP | |
1676 process that caused the command to complete. | |
1677 If NOWAIT is given then the routine will return immediately the command has | |
1678 been queued with no result. CONT will still be called, however." | |
1679 (if (memq (process-status proc) '(run open)) | |
1680 (save-excursion | |
1681 (set-buffer (process-buffer proc)) | |
1682 (while ange-ftp-process-busy | |
1683 (accept-process-output)) | |
1684 (setq ange-ftp-process-string "" | |
1685 ange-ftp-process-result-line "" | |
1686 ange-ftp-process-busy t | |
1687 ange-ftp-process-result nil | |
1688 ange-ftp-process-multi-skip nil | |
1689 ange-ftp-process-msg msg | |
1690 ange-ftp-process-continue cont | |
1691 ange-ftp-hash-mark-count 0 | |
1692 ange-ftp-last-percent -1 | |
1693 cmd (concat cmd "\n")) | |
1694 (and msg ange-ftp-process-verbose (ange-ftp-message "%s..." msg)) | |
1695 (goto-char (point-max)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1696 (move-marker comint-last-input-start (point)) |
1106 | 1697 ;; don't insert the password into the buffer on the USER command. |
1698 (ange-ftp-save-match-data | |
1699 (if (string-match "^user \"[^\"]*\"" cmd) | |
1700 (insert (substring cmd 0 (match-end 0)) " Turtle Power!\n") | |
1701 (insert cmd))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1702 (move-marker comint-last-input-end (point)) |
1106 | 1703 (send-string proc cmd) |
1704 (set-marker (process-mark proc) (point)) | |
1705 (if nowait | |
1706 nil | |
1707 ;; hang around for command to complete | |
1708 (while ange-ftp-process-busy | |
1709 (accept-process-output proc)) | |
1710 (if cont | |
1711 nil ;cont has already been called | |
1712 (cons ange-ftp-process-result ange-ftp-process-result-line)))))) | |
1713 | |
1714 (defun ange-ftp-nslookup-host (host) | |
1715 "Attempt to resolve the given HOSTNAME using nslookup if possible." | |
1716 (interactive "sHost: ") | |
1717 (if ange-ftp-nslookup-program | |
1718 (let ((proc (start-process " *nslookup*" " *nslookup*" | |
1719 ange-ftp-nslookup-program host)) | |
1720 (res host)) | |
1721 (process-kill-without-query proc) | |
1722 (save-excursion | |
1723 (set-buffer (process-buffer proc)) | |
1724 (while (memq (process-status proc) '(run open)) | |
1725 (accept-process-output proc)) | |
1726 (goto-char (point-min)) | |
1727 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t) | |
1728 (setq res (buffer-substring (match-beginning 1) | |
1729 (match-end 1)))) | |
1730 (kill-buffer (current-buffer))) | |
1731 res) | |
1732 host)) | |
1733 | |
1734 (defun ange-ftp-start-process (host user name) | |
1735 "Spawn a new ftp process ready to connect to machine HOST and give it NAME. | |
1736 If HOST is only ftp-able through a gateway machine then spawn a shell | |
1737 on the gateway machine to do the ftp instead." | |
1738 (let* ((use-gateway (ange-ftp-use-gateway-p host)) | |
1739 (ftp-prog (if use-gateway | |
1740 ange-ftp-gateway-ftp-program-name | |
1741 ange-ftp-ftp-program-name)) | |
1742 (args (append (list ftp-prog) ange-ftp-ftp-program-args)) | |
1743 proc) | |
1744 (if use-gateway | |
1745 (if ange-ftp-gateway-program-interactive | |
1746 (setq proc (ange-ftp-gwp-start host user name args)) | |
1747 (setq proc (apply 'start-process name name | |
1748 (append (list ange-ftp-gateway-program | |
1749 ange-ftp-gateway-host) | |
1750 args)))) | |
1751 (setq proc (apply 'start-process name name args))) | |
1752 (process-kill-without-query proc) | |
1753 (save-excursion | |
1754 (set-buffer (process-buffer proc)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1755 (ange-ftp-mode)) |
1106 | 1756 (set-process-sentinel proc (function ange-ftp-process-sentinel)) |
1757 (set-process-filter proc (function ange-ftp-process-filter)) | |
1758 (accept-process-output proc) ;wait for ftp startup message | |
1759 proc)) | |
1760 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1761 (defun ange-ftp-mode () |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1762 (interactive) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1763 (comint-mode) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1764 (setq major-mode 'ange-ftp-mode) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1765 (setq mode-name "Ange-ftp") |
1106 | 1766 (let ((proc (get-buffer-process (current-buffer)))) |
1767 (goto-char (point-max)) | |
1768 (set-marker (process-mark proc) (point)) | |
1769 (make-local-variable 'ange-ftp-process-string) | |
1770 (setq ange-ftp-process-string "") | |
1771 (make-local-variable 'ange-ftp-process-busy) | |
1772 (make-local-variable 'ange-ftp-process-result) | |
1773 (make-local-variable 'ange-ftp-process-msg) | |
1774 (make-local-variable 'ange-ftp-process-multi-skip) | |
1775 (make-local-variable 'ange-ftp-process-result-line) | |
1776 (make-local-variable 'ange-ftp-process-continue) | |
1777 (make-local-variable 'ange-ftp-hash-mark-count) | |
1778 (make-local-variable 'ange-ftp-binary-hash-mark-size) | |
1779 (make-local-variable 'ange-ftp-ascii-hash-mark-size) | |
1780 (make-local-variable 'ange-ftp-hash-mark-unit) | |
1781 (make-local-variable 'ange-ftp-xfer-size) | |
1782 (make-local-variable 'ange-ftp-last-percent) | |
1783 (setq ange-ftp-hash-mark-count 0) | |
1784 (setq ange-ftp-xfer-size 0) | |
1785 (setq ange-ftp-process-result-line ""))) | |
1786 | |
1787 (defun ange-ftp-smart-login (host user pass account proc) | |
1788 "Connect to the FTP-server on HOST as USER using PASSWORD and ACCOUNT. | |
1789 PROC is the FTP-client's process. This routine uses the smart-gateway | |
1790 host specified in ``ange-ftp-gateway-host''." | |
1791 (let ((result (ange-ftp-raw-send-cmd | |
1792 proc | |
1793 (format "open %s %s" | |
1794 (ange-ftp-nslookup-host ange-ftp-gateway-host) | |
1795 ange-ftp-smart-gateway-port) | |
1796 (format "Opening FTP connection to %s via %s" | |
1797 host | |
1798 ange-ftp-gateway-host)))) | |
1799 (or (car result) | |
1800 (ange-ftp-error host user | |
1801 (concat "OPEN request failed: " | |
1802 (cdr result)))) | |
1803 (setq result (ange-ftp-raw-send-cmd | |
1804 proc (format "user \"%s\"@%s %s %s" | |
1805 user | |
1806 (ange-ftp-nslookup-host host) | |
1807 pass | |
1808 account) | |
1809 (format "Logging in as user %s@%s" | |
1810 user host))) | |
1811 (or (car result) | |
1812 (progn | |
1813 (ange-ftp-set-passwd host user nil) ; reset password | |
1814 (ange-ftp-set-account host user nil) ; reset account | |
1815 (ange-ftp-error host user | |
1816 (concat "USER request failed: " | |
1817 (cdr result))))))) | |
1818 | |
1819 (defun ange-ftp-normal-login (host user pass account proc) | |
1820 "Connect to the FTP-server on HOST as USER using PASSWORD and ACCOUNT. | |
1821 PROC is the process to the FTP-client." | |
1822 (let ((result (ange-ftp-raw-send-cmd | |
1823 proc | |
1824 (format "open %s" (ange-ftp-nslookup-host host)) | |
1825 (format "Opening FTP connection to %s" host)))) | |
1826 (or (car result) | |
1827 (ange-ftp-error host user | |
1828 (concat "OPEN request failed: " | |
1829 (cdr result)))) | |
1830 (setq result (ange-ftp-raw-send-cmd | |
1831 proc | |
1832 (format "user \"%s\" %s %s" user pass account) | |
1833 (format "Logging in as user %s@%s" user host))) | |
1834 (or (car result) | |
1835 (progn | |
1836 (ange-ftp-set-passwd host user nil) ;reset password. | |
1837 (ange-ftp-set-account host user nil) ;reset account. | |
1838 (ange-ftp-error host user | |
1839 (concat "USER request failed: " | |
1840 (cdr result))))))) | |
1841 | |
1842 (defvar ange-ftp-hash-mark-msgs | |
1843 "[hH]ash mark [^0-9]*\\([0-9]+\\)" | |
1844 "*Regexp matching the FTP client's output upon doing a HASH command.") | |
1845 | |
1846 (defun ange-ftp-guess-hash-mark-size (proc) | |
1847 (if ange-ftp-send-hash | |
1848 (save-excursion | |
1849 (set-buffer (process-buffer proc)) | |
1850 (let* ((status (ange-ftp-raw-send-cmd proc "hash")) | |
1851 (result (car status)) | |
1852 (line (cdr status))) | |
1853 (ange-ftp-save-match-data | |
1854 (if (string-match ange-ftp-hash-mark-msgs line) | |
1855 (let ((size (string-to-int | |
1856 (substring line | |
1857 (match-beginning 1) | |
1858 (match-end 1))))) | |
1859 (setq ange-ftp-ascii-hash-mark-size size | |
1860 ange-ftp-hash-mark-unit (ash size -4)) | |
1861 | |
1862 ;; if a default value for this is set, use that value. | |
1863 (or ange-ftp-binary-hash-mark-size | |
1864 (setq ange-ftp-binary-hash-mark-size size))))))))) | |
1865 | |
1866 (defun ange-ftp-get-process (host user) | |
1867 "Return the process object for a FTP process connected to HOST and | |
1868 logged in as USER. Create a new process if needed." | |
1869 (let* ((name (ange-ftp-ftp-process-buffer host user)) | |
1870 (proc (get-process name))) | |
1871 (if (and proc (memq (process-status proc) '(run open))) | |
1872 proc | |
1873 (let ((pass (ange-ftp-quote-string | |
1874 (ange-ftp-get-passwd host user))) | |
1875 (account (ange-ftp-quote-string | |
1876 (ange-ftp-get-account host user)))) | |
1877 ;; grab a suitable process. | |
1878 (setq proc (ange-ftp-start-process host user name)) | |
1879 | |
1880 ;; login to FTP server. | |
1881 (if (ange-ftp-use-smart-gateway-p host) | |
1882 (ange-ftp-smart-login host user pass account proc) | |
1883 (ange-ftp-normal-login host user pass account proc)) | |
1884 | |
1885 ;; Tell client to send back hash-marks as progress. It isn't usually | |
1886 ;; fatal if this command fails. | |
1887 (ange-ftp-guess-hash-mark-size proc) | |
1888 | |
1889 ;; Guess at the host type. | |
1890 (ange-ftp-guess-host-type host user) | |
1891 | |
1892 ;; Run any user-specified hooks. Note that proc, host and user are | |
1893 ;; dynamically bound at this point. | |
1894 (run-hooks 'ange-ftp-process-startup-hook)) | |
1895 proc))) | |
1896 | |
1897 ;; Variables for caching host and host-type | |
1898 (defvar ange-ftp-host-cache nil) | |
1899 (defvar ange-ftp-host-type-cache nil) | |
1900 | |
1901 ;; If ange-ftp-host-type is called with the optional user | |
1902 ;; argument, it will attempt to guess the host type by connecting | |
1903 ;; as user, if necessary. For efficiency, I have tried to give this | |
1904 ;; optional second argument only when necessary. Have I missed any calls | |
1905 ;; to ange-ftp-host-type where it should have been supplied? | |
1906 | |
1907 (defun ange-ftp-host-type (host &optional user) | |
1908 "Return a symbol which represents the type of the HOST given. | |
1909 If the optional argument USER is given, attempts to guess the | |
1910 host-type by logging in as USER." | |
1911 (if (eq host ange-ftp-host-cache) | |
1912 ange-ftp-host-type-cache | |
1913 ;; Trigger an ftp connection, in case we need to guess at the host type. | |
1914 (if (and user (ange-ftp-get-process host user) (eq host ange-ftp-host-cache)) | |
1915 ange-ftp-host-type-cache | |
1916 (setq ange-ftp-host-cache host | |
1917 ange-ftp-host-type-cache | |
1918 (cond ((ange-ftp-dumb-unix-host host) | |
1919 'dumb-unix) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1920 ;; ((and (fboundp 'ange-ftp-vos-host) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1921 ;; (ange-ftp-vos-host host)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1922 ;; 'vos) |
1106 | 1923 ((and (fboundp 'ange-ftp-vms-host) |
1924 (ange-ftp-vms-host host)) | |
1925 'vms) | |
1926 ((and (fboundp 'ange-ftp-mts-host) | |
1927 (ange-ftp-mts-host host)) | |
1928 'mts) | |
1929 ((and (fboundp 'ange-ftp-cms-host) | |
1930 (ange-ftp-cms-host host)) | |
1931 'cms) | |
1932 (t | |
1933 'unix)))))) | |
1934 | |
1935 ;; It would be nice to abstract the functions ange-ftp-TYPE-host and | |
1936 ;; ange-ftp-add-TYPE-host. The trick is to abstract these functions | |
1937 ;; without sacrificing speed. Also, having separate variables | |
1938 ;; ange-ftp-TYPE-regexp is more user friendly then requiring the user to | |
1939 ;; set an alist to indicate that a host is of a given type. Even with | |
1940 ;; automatic host type recognition, setting a regexp is still a good idea | |
1941 ;; (for efficiency) if you log into a particular non-UNIX host frequently. | |
1942 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1943 (defvar ange-ftp-fix-name-func-alist nil |
1106 | 1944 "Association list of \( TYPE \. FUNC \) pairs, where FUNC is a routine |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1945 which can change a UNIX file name into a name more suitable for a host of type |
1106 | 1946 TYPE.") |
1947 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1948 (defvar ange-ftp-fix-dir-name-func-alist nil |
1106 | 1949 "Association list of \( TYPE \. FUNC \) pairs, where FUNC is a routine |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1950 which can change UNIX directory name into a directory name more suitable |
1106 | 1951 for a host of type TYPE.") |
1952 | |
1953 ;; *** Perhaps the sense of this variable should be inverted, since there | |
1954 ;; *** is only 1 host type that can take ls-style listing options. | |
1955 (defvar ange-ftp-dumb-host-types '(dumb-unix) | |
1956 "List of host types that can't take UNIX ls-style listing options.") | |
1957 | |
1958 (defun ange-ftp-send-cmd (host user cmd &optional msg cont nowait) | |
1959 "Find an ftp process connected to HOST logged in as USER and send it CMD. | |
1960 MSG is an optional status message to be output before and after issuing the | |
1961 command. | |
1962 See the documentation for ange-ftp-raw-send-cmd for a description of CONT | |
1963 and NOWAIT." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1964 ;; Handle conversion to remote file name syntax and remote ls option |
1106 | 1965 ;; capability. |
1966 (let ((cmd0 (car cmd)) | |
1967 (cmd1 (nth 1 cmd)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1968 cmd2 cmd3 host-type fix-name-func) |
1106 | 1969 |
1970 (cond | |
1971 | |
1972 ;; pwd case (We don't care what host-type.) | |
1973 ((null cmd1)) | |
1974 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1975 ;; cmd == 'dir "remote-name" "local-name" "ls-switches" |
1106 | 1976 ((progn |
1977 (setq cmd2 (nth 2 cmd) | |
1978 host-type (ange-ftp-host-type host user)) | |
1979 ;; This will trigger an FTP login, if one doesn't exist | |
1980 (eq cmd0 'dir)) | |
1981 (setq cmd1 (funcall | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1982 (or (cdr (assq host-type ange-ftp-fix-dir-name-func-alist)) |
1106 | 1983 'identity) |
1984 cmd1) | |
1985 cmd3 (nth 3 cmd)) | |
1986 ;; Need to deal with the HP-UX ftp bug. This should also allow | |
1987 ;; us to resolve symlinks to directories on SysV machines. (Sebastian will | |
1988 ;; be happy.) | |
1989 (and (eq host-type 'unix) | |
1990 (string-match "/$" cmd1) | |
1991 (not (string-match "R" cmd3)) | |
1992 (setq cmd1 (concat cmd1 "."))) | |
1993 ;; If the remote ls can take switches, put them in | |
1994 (or (memq host-type ange-ftp-dumb-host-types) | |
1995 (setq cmd0 'ls | |
1996 cmd1 (format "\"%s %s\"" cmd3 cmd1)))) | |
1997 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1998 ;; First argument is the remote name |
1106 | 1999 ((let ((ange-ftp-this-user user) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2000 (ange-ftp-this-host host) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2001 (ange-ftp-this-msg msg)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2002 (setq fix-name-func (or (cdr (assq host-type |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2003 ange-ftp-fix-name-func-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2004 'identity)) |
1106 | 2005 (memq cmd0 '(get delete mkdir rmdir cd))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2006 (setq cmd1 (funcall fix-name-func cmd1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2007 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2008 ;; Second argument is the remote name |
1106 | 2009 ((memq cmd0 '(append put chmod)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2010 (setq cmd2 (funcall fix-name-func cmd2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2011 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2012 ;; Both arguments are remote names |
1106 | 2013 ((eq cmd0 'rename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2014 (setq cmd1 (funcall fix-name-func cmd1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2015 cmd2 (funcall fix-name-func cmd2)))) |
1106 | 2016 |
2017 ;; Turn the command into one long string | |
2018 (setq cmd0 (symbol-name cmd0)) | |
2019 (setq cmd (concat cmd0 | |
2020 (and cmd1 (concat " " cmd1)) | |
2021 (and cmd2 (concat " " cmd2)))) | |
2022 | |
2023 ;; Actually send the resulting command. | |
2024 (let (afsc-result | |
2025 afsc-line) | |
2026 (ange-ftp-raw-send-cmd | |
2027 (ange-ftp-get-process host user) | |
2028 cmd | |
2029 msg | |
2030 (list | |
2031 (function (lambda (result line host user | |
2032 cmd msg cont nowait) | |
2033 (or cont | |
2034 (setq afsc-result result | |
2035 afsc-line line)) | |
2036 (if result | |
2037 (ange-ftp-call-cont cont result line) | |
2038 (ange-ftp-raw-send-cmd | |
2039 (ange-ftp-get-process host user) | |
2040 cmd | |
2041 msg | |
2042 (list | |
2043 (function (lambda (result line cont) | |
2044 (or cont | |
2045 (setq afsc-result result | |
2046 afsc-line line)) | |
2047 (ange-ftp-call-cont cont result line))) | |
2048 cont) | |
2049 nowait)))) | |
2050 host user cmd msg cont nowait) | |
2051 nowait) | |
2052 | |
2053 (if nowait | |
2054 nil | |
2055 (if cont | |
2056 nil | |
2057 (cons afsc-result afsc-line)))))) | |
2058 | |
2059 ;; It might be nice to message users about the host type identified, | |
2060 ;; but there is so much other messaging going on, it would not be | |
2061 ;; seen. No point in slowing things down just so users can read | |
2062 ;; a host type message. | |
2063 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2064 (defconst ange-ftp-cms-name-template |
1106 | 2065 (concat |
2066 "^[-A-Z0-9$*][-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?" | |
2067 "[-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?\\.[0-9][0-9][0-9A-Z]$")) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2068 (defconst ange-ftp-vms-name-template |
1106 | 2069 "^[-A-Z0-9_$]+:\\[[-A-Z0-9_$]+\\(\\.[-A-Z0-9_$]+\\)*\\]$") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2070 (defconst ange-ftp-mts-name-template |
1106 | 2071 "^[A-Z0-9._][A-Z0-9._][A-Z0-9._][A-Z0-9._]:$") |
2072 | |
2073 (defun ange-ftp-guess-host-type (host user) | |
2074 "Guess at the the host type of HOST by doing a pwd, and examining | |
2075 the directory syntax." | |
2076 (let ((host-type (ange-ftp-host-type host)) | |
2077 (key (concat host "/" user "/~"))) | |
2078 (if (eq host-type 'unix) | |
2079 ;; Note that ange-ftp-host-type returns unix as the default value. | |
2080 (ange-ftp-save-match-data | |
2081 (let* ((result (ange-ftp-get-pwd host user)) | |
2082 (dir (car result)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2083 fix-name-func) |
1106 | 2084 (cond ((null dir) |
2085 (message "Warning! Unable to get home directory") | |
2086 (sit-for 1) | |
2087 (if (string-match | |
2088 "^450 No current working directory defined$" | |
2089 (cdr result)) | |
2090 | |
2091 ;; We'll assume that if pwd bombs with this | |
2092 ;; error message, then it's CMS. | |
2093 (progn | |
2094 (ange-ftp-add-cms-host host) | |
2095 (setq ange-ftp-host-cache host | |
2096 ange-ftp-host-type-cache 'cms)))) | |
2097 | |
2098 ;; try for VMS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2099 ((string-match ange-ftp-vms-name-template dir) |
1106 | 2100 (ange-ftp-add-vms-host host) |
2101 ;; The add-host functions clear the host type cache. | |
2102 ;; Therefore, need to set the cache afterwards. | |
2103 (setq ange-ftp-host-cache host | |
2104 ange-ftp-host-type-cache 'vms)) | |
2105 | |
2106 ;; try for MTS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2107 ((string-match ange-ftp-mts-name-template dir) |
1106 | 2108 (ange-ftp-add-mts-host host) |
2109 (setq ange-ftp-host-cache host | |
2110 ange-ftp-host-type-cache 'mts)) | |
2111 | |
2112 ;; try for CMS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2113 ((string-match ange-ftp-cms-name-template dir) |
1106 | 2114 (ange-ftp-add-cms-host host) |
2115 (setq ange-ftp-host-cache host | |
2116 ange-ftp-host-type-cache 'cms)) | |
2117 | |
2118 ;; assume UN*X | |
2119 (t | |
2120 (setq ange-ftp-host-cache host | |
2121 ange-ftp-host-type-cache 'unix))) | |
2122 | |
2123 ;; Now that we have done a pwd, might as well put it in | |
2124 ;; the expand-dir hashtable. | |
2125 (let ((ange-ftp-this-user user) | |
2126 (ange-ftp-this-host host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2127 (setq fix-name-func (cdr (assq ange-ftp-host-type-cache |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2128 ange-ftp-fix-name-func-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2129 (if fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2130 (setq dir (funcall fix-name-func dir 'reverse)))) |
1106 | 2131 (ange-ftp-put-hash-entry key dir |
2132 ange-ftp-expand-dir-hashtable)))) | |
2133 | |
2134 ;; In the special case of CMS make sure that know the | |
2135 ;; expansion of the home minidisk now, because we will | |
2136 ;; be doing a lot of cd's. | |
2137 (if (and (eq host-type 'cms) | |
2138 (not (ange-ftp-hash-entry-exists-p | |
2139 key ange-ftp-expand-dir-hashtable))) | |
2140 (let ((dir (car (ange-ftp-get-pwd host user)))) | |
2141 (if dir | |
2142 (ange-ftp-put-hash-entry key (concat "/" dir) | |
2143 ange-ftp-expand-dir-hashtable) | |
2144 (message "Warning! Unable to get home directory") | |
2145 (sit-for 1)))))) | |
2146 | |
2147 | |
2148 ;;;; ------------------------------------------------------------ | |
2149 ;;;; Remote file and directory listing support. | |
2150 ;;;; ------------------------------------------------------------ | |
2151 | |
2152 (defun ange-ftp-dumb-unix-host (host) | |
2153 "Returns whether HOST's FTP server doesn't like \'ls\' or \'dir\' commands | |
2154 to take switch arguments." | |
2155 (and ange-ftp-dumb-unix-host-regexp | |
2156 (ange-ftp-save-match-data | |
2157 (string-match ange-ftp-dumb-unix-host-regexp host)))) | |
2158 | |
2159 (defun ange-ftp-add-dumb-unix-host (host) | |
2160 "Interactively adds a given HOST to ange-ftp-dumb-unix-host-regexp." | |
2161 (interactive | |
2162 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2163 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2164 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 2165 (if (not (ange-ftp-dumb-unix-host host)) |
2166 (setq ange-ftp-dumb-unix-host-regexp | |
2167 (concat "^" (regexp-quote host) "$" | |
2168 (and ange-ftp-dumb-unix-host-regexp "\\|") | |
2169 ange-ftp-dumb-unix-host-regexp) | |
2170 ange-ftp-host-cache nil))) | |
2171 | |
2172 (defvar ange-ftp-parse-list-func-alist nil | |
2173 "Association list of \( TYPE \. FUNC \) pairs. The FUNC is a routine | |
2174 which can parse the output from a DIR listing for a host of type TYPE.") | |
2175 | |
2176 ;; With no-error nil, this function returns: | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2177 ;; an error if file is not an ange-ftp-name |
1106 | 2178 ;; (This should never happen.) |
2179 ;; an error if either the listing is unreadable or there is an ftp error. | |
2180 ;; the listing (a string), if everything works. | |
2181 ;; | |
2182 ;; With no-error t, it returns: | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2183 ;; an error if not an ange-ftp-name |
1106 | 2184 ;; error if listing is unreable (most likely caused by a slow connection) |
2185 ;; nil if ftp error (this is because although asking to list a nonexistent | |
2186 ;; directory on a remote unix machine usually (except | |
2187 ;; maybe for dumb hosts) returns an ls error, but no | |
2188 ;; ftp error, if the same is done on a VMS machine, | |
2189 ;; an ftp error is returned. Need to trap the error | |
2190 ;; so we can go on and try to list the parent.) | |
2191 ;; the listing, if everything works. | |
2192 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2193 ;; If WILDCARD is non-nil, then this implements the guts of insert-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2194 ;; in the wildcard case. Then we make a relative directory listing |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2195 ;; of FILE within the directory specified by `default-directory'. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2196 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2197 (defun ange-ftp-ls (file lsargs parse &optional no-error wildcard) |
1106 | 2198 "Return the output of an `DIR' or `ls' command done over ftp. |
2199 FILE is the full name of the remote file, LSARGS is any args to pass to the | |
2200 `ls' command, and PARSE specifies that the output should be parsed and stored | |
2201 away in the internal cache." | |
2202 ;; If parse is t, we assume that file is a directory. i.e. we only parse | |
2203 ;; full directory listings. | |
2204 (let* ((ange-ftp-this-file (ange-ftp-expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2205 (parsed (ange-ftp-ftp-name ange-ftp-this-file))) |
1106 | 2206 (if parsed |
2207 (let* ((host (nth 0 parsed)) | |
2208 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2209 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2210 (key (directory-file-name ange-ftp-this-file)) |
2211 (host-type (ange-ftp-host-type host user)) | |
2212 (dumb (memq host-type ange-ftp-dumb-host-types)) | |
2213 result | |
2214 temp | |
2215 lscmd parse-func) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2216 (if (string-equal name "") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2217 (setq name |
1106 | 2218 (ange-ftp-real-file-name-as-directory |
2219 (ange-ftp-expand-dir host user "~")))) | |
2220 (if (and ange-ftp-ls-cache-file | |
2221 (string-equal key ange-ftp-ls-cache-file) | |
2222 ;; Don't care about lsargs for dumb hosts. | |
2223 (or dumb (string-equal lsargs ange-ftp-ls-cache-lsargs))) | |
2224 ange-ftp-ls-cache-res | |
2225 (setq temp (ange-ftp-make-tmp-name host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2226 (if wildcard |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2227 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2228 (ange-ftp-cd host user (file-name-directory name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2229 (setq lscmd (list 'dir file temp lsargs))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2230 (setq lscmd (list 'dir name temp lsargs))) |
1106 | 2231 (unwind-protect |
2232 (if (car (setq result (ange-ftp-send-cmd | |
2233 host | |
2234 user | |
2235 lscmd | |
2236 (format "Listing %s" | |
2237 (ange-ftp-abbreviate-filename | |
2238 ange-ftp-this-file))))) | |
2239 (save-excursion | |
2240 (set-buffer (get-buffer-create | |
2241 ange-ftp-data-buffer-name)) | |
2242 (erase-buffer) | |
2243 (if (ange-ftp-real-file-readable-p temp) | |
2244 (ange-ftp-real-insert-file-contents temp) | |
2245 (sleep-for ange-ftp-retry-time) | |
2246 ;wait for file to possibly appear | |
2247 (if (ange-ftp-real-file-readable-p temp) | |
2248 ;; Try again. | |
2249 (ange-ftp-real-insert-file-contents temp) | |
2250 (ange-ftp-error host user | |
2251 (format | |
2252 "list data file %s not readable" | |
2253 temp)))) | |
2254 (if parse | |
2255 (ange-ftp-set-files | |
2256 ange-ftp-this-file | |
2257 (if (setq | |
2258 parse-func | |
2259 (cdr (assq host-type | |
2260 ange-ftp-parse-list-func-alist))) | |
2261 (funcall parse-func) | |
2262 (ange-ftp-parse-dired-listing lsargs)))) | |
2263 (setq ange-ftp-ls-cache-file key | |
2264 ange-ftp-ls-cache-lsargs lsargs | |
2265 ; For dumb hosts-types this is | |
2266 ; meaningless but harmless. | |
2267 ange-ftp-ls-cache-res (buffer-string)) | |
2268 ;; (kill-buffer (current-buffer)) | |
2269 ange-ftp-ls-cache-res) | |
2270 (if no-error | |
2271 nil | |
2272 (ange-ftp-error host user | |
2273 (concat "DIR failed: " (cdr result))))) | |
2274 (ange-ftp-del-tmp-name temp)))) | |
2275 (error "Should never happen. Please report. Bug ref. no.: 1")))) | |
2276 | |
2277 ;;;; ------------------------------------------------------------ | |
2278 ;;;; Directory information caching support. | |
2279 ;;;; ------------------------------------------------------------ | |
2280 | |
2281 (defconst ange-ftp-date-regexp | |
2282 (concat | |
2283 " \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct" | |
2284 "\\|Nov\\|Dec\\) +[0-3]?[0-9] ")) | |
2285 | |
2286 (defvar ange-ftp-add-file-entry-alist nil | |
2287 "Association list of pairs \( TYPE \. FUNC \), where FUNC | |
2288 is a function to be used to add a file entry for the OS TYPE. The | |
2289 main reason for this alist is to deal with file versions in VMS.") | |
2290 | |
2291 (defvar ange-ftp-delete-file-entry-alist nil | |
2292 "Association list of pairs \( TYPE \. FUNC \), where FUNC | |
2293 is a function to be used to delete a file entry for the OS TYPE. | |
2294 The main reason for this alist is to deal with file versions in | |
2295 VMS.") | |
2296 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2297 (defun ange-ftp-add-file-entry (name &optional dir-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2298 "Add a file entry for file NAME, if its directory info exists." |
1106 | 2299 (funcall (or (cdr (assq (ange-ftp-host-type |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2300 (car (ange-ftp-ftp-name name))) |
1106 | 2301 ange-ftp-add-file-entry-alist)) |
2302 'ange-ftp-internal-add-file-entry) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2303 name dir-p) |
1106 | 2304 (setq ange-ftp-ls-cache-file nil)) |
2305 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2306 (defun ange-ftp-delete-file-entry (name &optional dir-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2307 "Delete the file entry for file NAME, if its directory info exists." |
1106 | 2308 (funcall (or (cdr (assq (ange-ftp-host-type |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2309 (car (ange-ftp-ftp-name name))) |
1106 | 2310 ange-ftp-delete-file-entry-alist)) |
2311 'ange-ftp-internal-delete-file-entry) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2312 name dir-p) |
1106 | 2313 (setq ange-ftp-ls-cache-file nil)) |
2314 | |
2315 (defmacro ange-ftp-parse-filename () | |
2316 ;;Extract the filename from the current line of a dired-like listing. | |
2317 (` (let ((eol (progn (end-of-line) (point)))) | |
2318 (beginning-of-line) | |
2319 (if (re-search-forward ange-ftp-date-regexp eol t) | |
2320 (progn | |
2321 (skip-chars-forward " ") | |
2322 (skip-chars-forward "^ " eol) | |
2323 (skip-chars-forward " " eol) | |
2324 ;; We bomb on filenames starting with a space. | |
2325 (buffer-substring (point) eol)))))) | |
2326 | |
2327 ;; This deals with the F switch. Should also do something about | |
2328 ;; unquoting names obtained with the SysV b switch and the GNU Q | |
2329 ;; switch. See Sebastian's dired-get-filename. | |
2330 | |
2331 (defmacro ange-ftp-ls-parser () | |
2332 ;; Note that switches is dynamically bound. | |
2333 ;; Meant to be called by ange-ftp-parse-dired-listing | |
2334 (` (let ((tbl (ange-ftp-make-hashtable)) | |
2335 (used-F (and (stringp switches) | |
2336 (string-match "F" switches))) | |
2337 file-type symlink directory file) | |
2338 (while (setq file (ange-ftp-parse-filename)) | |
2339 (beginning-of-line) | |
2340 (skip-chars-forward "\t 0-9") | |
2341 (setq file-type (following-char) | |
2342 directory (eq file-type ?d)) | |
2343 (if (eq file-type ?l) | |
2344 (if (string-match " -> " file) | |
2345 (setq symlink (substring file (match-end 0)) | |
2346 file (substring file 0 (match-beginning 0))) | |
2347 ;; Shouldn't happen | |
2348 (setq symlink "")) | |
2349 (setq symlink nil)) | |
2350 ;; Only do a costly regexp search if the F switch was used. | |
2351 (if (and used-F | |
2352 (not (string-equal file "")) | |
2353 (looking-at | |
2354 ".[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)")) | |
2355 (let ((socket (eq file-type ?s)) | |
2356 (executable | |
2357 (and (not symlink) ; x bits don't mean a thing for symlinks | |
2358 (string-match "[xst]" | |
2359 (concat | |
2360 (buffer-substring | |
2361 (match-beginning 1) | |
2362 (match-end 1)) | |
2363 (buffer-substring | |
2364 (match-beginning 2) | |
2365 (match-end 2)) | |
2366 (buffer-substring | |
2367 (match-beginning 3) | |
2368 (match-end 3))))))) | |
2369 ;; Some ls's with the F switch mark symlinks with an @ (ULTRIX) | |
2370 ;; and others don't. (sigh...) Beware, that some Unix's don't | |
2371 ;; seem to believe in the F-switch | |
2372 (if (or (and symlink (string-match "@$" file)) | |
2373 (and directory (string-match "/$" file)) | |
2374 (and executable (string-match "*$" file)) | |
2375 (and socket (string-match "=$" file))) | |
2376 (setq file (substring file 0 -1))))) | |
2377 (ange-ftp-put-hash-entry file (or symlink directory) tbl) | |
2378 (forward-line 1)) | |
2379 (ange-ftp-put-hash-entry "." t tbl) | |
2380 (ange-ftp-put-hash-entry ".." t tbl) | |
2381 tbl))) | |
2382 | |
2383 ;;; The dl stuff for descriptive listings | |
2384 | |
2385 (defvar ange-ftp-dl-dir-regexp nil | |
2386 "Regexp matching directories which are listed in dl format. This regexp | |
2387 shouldn't be anchored with a trailing $ so that it will match subdirectories | |
2388 as well.") | |
2389 | |
2390 (defun ange-ftp-add-dl-dir (dir) | |
1233 | 2391 "Interactively adds a DIR to ange-ftp-dl-dir-regexp." |
1106 | 2392 (interactive |
2393 (list (read-string "Directory: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2394 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2395 (and name (ange-ftp-ftp-name name) |
1106 | 2396 (file-name-directory name)))))) |
2397 (if (not (and ange-ftp-dl-dir-regexp | |
2398 (string-match ange-ftp-dl-dir-regexp dir))) | |
2399 (setq ange-ftp-dl-dir-regexp | |
2400 (concat "^" (regexp-quote dir) | |
2401 (and ange-ftp-dl-dir-regexp "\\|") | |
2402 ange-ftp-dl-dir-regexp)))) | |
2403 | |
2404 (defmacro ange-ftp-dl-parser () | |
2405 ;; Parse the current buffer, which is assumed to be a descriptive | |
2406 ;; listing, and return a hashtable. | |
2407 (` (let ((tbl (ange-ftp-make-hashtable))) | |
2408 (while (not (eobp)) | |
2409 (ange-ftp-put-hash-entry | |
2410 (buffer-substring (point) | |
2411 (progn | |
2412 (skip-chars-forward "^ /\n") | |
2413 (point))) | |
2414 (eq (following-char) ?/) | |
2415 tbl) | |
2416 (forward-line 1)) | |
2417 (ange-ftp-put-hash-entry "." t tbl) | |
2418 (ange-ftp-put-hash-entry ".." t tbl) | |
2419 tbl))) | |
2420 | |
2421 (defun ange-ftp-parse-dired-listing (&optional switches) | |
2422 "Parse the current buffer which is assumed to be in a dired-like listing | |
2423 format, and return a hashtable as the result. If the listing is not really | |
2424 a listing, then return nil." | |
2425 (ange-ftp-save-match-data | |
2426 (cond | |
2427 ((looking-at "^total [0-9]+$") | |
2428 (forward-line 1) | |
2429 (ange-ftp-ls-parser)) | |
2430 ((looking-at "[^\n]+\\( not found\\|: Not a directory\\)\n\\'") | |
2431 ;; It's an ls error message. | |
2432 nil) | |
2433 ((eobp) ; i.e. (zerop (buffer-size)) | |
2434 ;; This could be one of: | |
2435 ;; (1) An Ultrix ls error message | |
2436 ;; (2) A listing with the A switch of an empty directory | |
2437 ;; on a machine which doesn't give a total line. | |
2438 ;; (3) The twilight zone. | |
2439 ;; We'll assume (1) for now. | |
2440 nil) | |
2441 ((re-search-forward ange-ftp-date-regexp nil t) | |
2442 (beginning-of-line) | |
2443 (ange-ftp-ls-parser)) | |
2444 ((re-search-forward "^[^ \n\t]+ +\\([0-9]+\\|-\\|=\\) " nil t) | |
2445 ;; It's a dl listing (I hope). | |
2446 ;; file is bound by the call to ange-ftp-ls | |
2447 (ange-ftp-add-dl-dir ange-ftp-this-file) | |
2448 (beginning-of-line) | |
2449 (ange-ftp-dl-parser)) | |
2450 (t nil)))) | |
2451 | |
2452 (defun ange-ftp-set-files (directory files) | |
2453 "For a given DIRECTORY, set or change the associated FILES hashtable." | |
2454 (and files (ange-ftp-put-hash-entry (file-name-as-directory directory) | |
2455 files ange-ftp-files-hashtable))) | |
2456 | |
2457 (defun ange-ftp-get-files (directory &optional no-error) | |
2458 "Given a given DIRECTORY, return a hashtable of file entries. | |
2459 This will give an error or return nil, depending on the value of | |
2460 NO-ERROR, if a listing for DIRECTORY cannot be obtained." | |
2461 (setq directory (file-name-as-directory directory)) ;normalize | |
2462 (or (ange-ftp-get-hash-entry directory ange-ftp-files-hashtable) | |
2463 (ange-ftp-save-match-data | |
2464 (and (ange-ftp-ls directory | |
2465 ;; This is an efficiency hack. We try to | |
2466 ;; anticipate what sort of listing dired | |
2467 ;; might want, and cache just such a listing. | |
2468 (if (and (boundp 'dired-actual-switches) | |
2469 (stringp dired-actual-switches) | |
2470 ;; We allow the A switch, which lists | |
2471 ;; all files except "." and "..". | |
2472 ;; This is OK because we manually | |
2473 ;; insert these entries | |
2474 ;; in the hash table. | |
2475 (string-match | |
2476 "[aA]" dired-actual-switches) | |
2477 (string-match | |
2478 "l" dired-actual-switches) | |
2479 (not (string-match | |
2480 "R" dired-actual-switches))) | |
2481 dired-actual-switches | |
2482 (if (and (boundp 'dired-listing-switches) | |
2483 (stringp dired-listing-switches) | |
2484 (string-match | |
2485 "[aA]" dired-listing-switches) | |
2486 (string-match | |
2487 "l" dired-listing-switches) | |
2488 (not (string-match | |
2489 "R" dired-listing-switches))) | |
2490 dired-listing-switches | |
2491 "-al")) | |
2492 t no-error) | |
2493 (ange-ftp-get-hash-entry | |
2494 directory ange-ftp-files-hashtable))))) | |
2495 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2496 (defmacro ange-ftp-get-file-part (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2497 "Given NAME, return the file part that can be used for looking up the |
1106 | 2498 file's entry in a hashtable." |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2499 (` (let ((file (file-name-nondirectory (, name)))) |
1106 | 2500 (if (string-equal file "") |
2501 "." | |
2502 file)))) | |
2503 | |
2504 (defmacro ange-ftp-allow-child-lookup (dir file) | |
2505 "Return whether ange-ftp-file-entry-p and ange-ftp-get-file-entry are | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2506 allowed to determine if NAME is a sub-directory by listing it directly, |
1106 | 2507 rather than listing its parent directory. This is used for efficiency so |
2508 that a wasted listing is not done: | |
2509 1. When looking for a .dired file in dired-x.el. | |
2510 2. The syntax of FILE and DIR make it impossible that FILE could be a valid | |
2511 subdirectory. This is of course an OS dependent judgement." | |
2512 (` (not | |
2513 (let* ((efile (, file)) ; expand once. | |
2514 (edir (, dir)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2515 (parsed (ange-ftp-ftp-name edir)) |
1106 | 2516 (host-type (ange-ftp-host-type |
2517 (car parsed)))) | |
2518 (or | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2519 ;;; This variable seems not to exist in Emacs 19 -- rms. |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2520 ;;; ;; Deal with dired |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2521 ;;; (and (boundp 'dired-local-variables-file) |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2522 ;;; (stringp dired-local-variables-file) |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2523 ;;; (string-equal dired-local-variables-file efile)) |
1106 | 2524 ;; No dots in dir names in vms. |
2525 (and (eq host-type 'vms) | |
2526 (string-match "\\." efile)) | |
2527 ;; No subdirs in mts of cms. | |
2528 (and (memq host-type '(mts cms)) | |
2529 (not (string-equal "/" (nth 2 parsed))))))))) | |
2530 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2531 (defun ange-ftp-file-entry-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2532 "Given NAME, return whether there is a file entry for it." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2533 (let* ((name (directory-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2534 (dir (file-name-directory name)) |
1106 | 2535 (ent (ange-ftp-get-hash-entry dir ange-ftp-files-hashtable)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2536 (file (ange-ftp-get-file-part name))) |
1106 | 2537 (if ent |
2538 (ange-ftp-hash-entry-exists-p file ent) | |
2539 (or (and (ange-ftp-allow-child-lookup dir file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2540 (setq ent (ange-ftp-get-files name t)) |
1106 | 2541 ;; Try a child lookup. i.e. try to list file as a |
2542 ;; subdirectory of dir. This is a good idea because | |
2543 ;; we may not have read permission for file's parent. Also, | |
2544 ;; people tend to work down directory trees anyway. We use | |
2545 ;; no-error ;; because if file does not exist as a subdir., | |
2546 ;; then dumb hosts will give an ftp error. Smart unix hosts | |
2547 ;; will simply send back the ls | |
2548 ;; error message. | |
2549 (ange-ftp-get-hash-entry "." ent)) | |
2550 ;; Child lookup failed. Try the parent. If this bombs, | |
2551 ;; we are at wits end -- signal an error. | |
2552 ;; Problem: If this signals an error, the error message | |
2553 ;; may not have a lot to do with what went wrong. | |
2554 (ange-ftp-hash-entry-exists-p file | |
2555 (ange-ftp-get-files dir)))))) | |
2556 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2557 (defun ange-ftp-get-file-entry (name) |
1233 | 2558 "Given NAME, return the given file entry. |
2559 The entry will be either t for a directory, nil for a normal file, | |
2560 or a string for a symlink. If the file isn't in the hashtable, | |
2561 this also returns nil." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2562 (let* ((name (directory-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2563 (dir (file-name-directory name)) |
1106 | 2564 (ent (ange-ftp-get-hash-entry dir ange-ftp-files-hashtable)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2565 (file (ange-ftp-get-file-part name))) |
1106 | 2566 (if ent |
2567 (ange-ftp-get-hash-entry file ent) | |
2568 (or (and (ange-ftp-allow-child-lookup dir file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2569 (setq ent (ange-ftp-get-files name t)) |
1106 | 2570 (ange-ftp-get-hash-entry "." ent)) |
2571 ;; i.e. it's a directory by child lookup | |
2572 (ange-ftp-get-hash-entry file | |
2573 (ange-ftp-get-files dir)))))) | |
2574 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2575 (defun ange-ftp-internal-delete-file-entry (name &optional dir-p) |
1106 | 2576 (if dir-p |
2577 (progn | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2578 (setq name (file-name-as-directory name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2579 (ange-ftp-del-hash-entry name ange-ftp-files-hashtable) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2580 (setq name (directory-file-name name)))) |
1106 | 2581 ;; Note that file-name-as-directory followed by directory-file-name |
2582 ;; serves to canonicalize directory file names to their unix form. | |
2583 ;; i.e. in VMS, FOO.DIR -> FOO/ -> FOO | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2584 (let ((files (ange-ftp-get-hash-entry (file-name-directory name) |
1106 | 2585 ange-ftp-files-hashtable))) |
2586 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2587 (ange-ftp-del-hash-entry (ange-ftp-get-file-part name) |
1106 | 2588 files)))) |
2589 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2590 (defun ange-ftp-internal-add-file-entry (name &optional dir-p) |
1106 | 2591 (and dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2592 (setq name (directory-file-name name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2593 (let ((files (ange-ftp-get-hash-entry (file-name-directory name) |
1106 | 2594 ange-ftp-files-hashtable))) |
2595 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2596 (ange-ftp-put-hash-entry (ange-ftp-get-file-part name) |
1106 | 2597 dir-p |
2598 files)))) | |
2599 | |
2600 (defun ange-ftp-wipe-file-entries (host user) | |
2601 "Replace the file entry information hashtable with one that doesn't have any | |
2602 entries for the given HOST, USER pair." | |
2603 (let ((new-tbl (ange-ftp-make-hashtable (length ange-ftp-files-hashtable)))) | |
2604 (ange-ftp-map-hashtable | |
2605 (function | |
2606 (lambda (key val) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2607 (let ((parsed (ange-ftp-ftp-name key))) |
1106 | 2608 (if parsed |
2609 (let ((h (nth 0 parsed)) | |
2610 (u (nth 1 parsed))) | |
2611 (or (and (equal host h) (equal user u)) | |
2612 (ange-ftp-put-hash-entry key val new-tbl))))))) | |
2613 ange-ftp-files-hashtable) | |
2614 (setq ange-ftp-files-hashtable new-tbl))) | |
2615 | |
2616 ;;;; ------------------------------------------------------------ | |
2617 ;;;; File transfer mode support. | |
2618 ;;;; ------------------------------------------------------------ | |
2619 | |
2620 (defun ange-ftp-set-binary-mode (host user) | |
2621 "Tell the ftp process for the given HOST & USER to switch to binary mode." | |
2622 (let ((result (ange-ftp-send-cmd host user '(type "binary")))) | |
2623 (if (not (car result)) | |
2624 (ange-ftp-error host user (concat "BINARY failed: " (cdr result))) | |
2625 (save-excursion | |
2626 (set-buffer (process-buffer (ange-ftp-get-process host user))) | |
2627 (setq ange-ftp-hash-mark-unit (ash ange-ftp-binary-hash-mark-size -4)))))) | |
2628 | |
2629 (defun ange-ftp-set-ascii-mode (host user) | |
2630 "Tell the ftp process for the given HOST & USER to switch to ascii mode." | |
2631 (let ((result (ange-ftp-send-cmd host user '(type "ascii")))) | |
2632 (if (not (car result)) | |
2633 (ange-ftp-error host user (concat "ASCII failed: " (cdr result))) | |
2634 (save-excursion | |
2635 (set-buffer (process-buffer (ange-ftp-get-process host user))) | |
2636 (setq ange-ftp-hash-mark-unit (ash ange-ftp-ascii-hash-mark-size -4)))))) | |
2637 | |
2638 (defun ange-ftp-cd (host user dir) | |
2639 (let ((result (ange-ftp-send-cmd host user (list 'cd dir) "Doing CD"))) | |
2640 (or (car result) | |
2641 (ange-ftp-error host user (concat "CD failed: " (cdr result)))))) | |
2642 | |
2643 (defun ange-ftp-get-pwd (host user) | |
2644 "Attempts to get the current working directory for the given HOST/USER pair. | |
2645 Returns \( DIR . LINE \) where DIR is either the directory or NIL if not found, | |
2646 and LINE is the relevant success or fail line from the FTP-client." | |
2647 (let* ((result (ange-ftp-send-cmd host user '(pwd) "Getting PWD")) | |
2648 (line (cdr result)) | |
2649 dir) | |
2650 (if (car result) | |
2651 (ange-ftp-save-match-data | |
2652 (and (or (string-match "\"\\([^\"]*\\)\"" line) | |
2653 (string-match " \\([^ ]+\\) " line)) ; stone-age VMS servers! | |
2654 (setq dir (substring line | |
2655 (match-beginning 1) | |
2656 (match-end 1)))))) | |
2657 (cons dir line))) | |
2658 | |
2659 ;;; ------------------------------------------------------------ | |
2660 ;;; expand-file-name and friends...which currently don't work | |
2661 ;;; ------------------------------------------------------------ | |
2662 | |
2663 (defun ange-ftp-expand-dir (host user dir) | |
2664 "Return the result of doing a PWD in the current FTP session to machine HOST | |
2665 logged in as user USER and cd'd to directory DIR." | |
2666 (let* ((host-type (ange-ftp-host-type host user)) | |
2667 ;; It is more efficient to call ange-ftp-host-type | |
2668 ;; before binding res, because ange-ftp-host-type sometimes | |
2669 ;; adds to the info in the expand-dir-hashtable. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2670 (fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2671 (cdr (assq host-type ange-ftp-fix-name-func-alist))) |
1106 | 2672 (key (concat host "/" user "/" dir)) |
2673 (res (ange-ftp-get-hash-entry key ange-ftp-expand-dir-hashtable))) | |
2674 (or res | |
2675 (progn | |
2676 (or | |
2677 (string-equal user "anonymous") | |
2678 (string-equal user "ftp") | |
2679 (not (eq host-type 'unix)) | |
2680 (let* ((ange-ftp-good-msgs (concat ange-ftp-expand-dir-regexp | |
2681 "\\|" | |
2682 ange-ftp-good-msgs)) | |
2683 (result (ange-ftp-send-cmd host user | |
2684 (list 'get dir "/dev/null") | |
2685 (format "expanding %s" dir))) | |
2686 (line (cdr result))) | |
2687 (setq res | |
2688 (if (string-match ange-ftp-expand-dir-regexp line) | |
2689 (substring line | |
2690 (match-beginning 1) | |
2691 (match-end 1)))))) | |
2692 (or res | |
2693 (if (string-equal dir "~") | |
2694 (setq res (car (ange-ftp-get-pwd host user))) | |
2695 (let ((home (ange-ftp-expand-dir host user "~"))) | |
2696 (unwind-protect | |
2697 (and (ange-ftp-cd host user dir) | |
2698 (setq res (car (ange-ftp-get-pwd host user)))) | |
2699 (ange-ftp-cd host user home))))) | |
2700 (if res | |
2701 (let ((ange-ftp-this-user user) | |
2702 (ange-ftp-this-host host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2703 (if fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2704 (setq res (funcall fix-name-func res 'reverse))) |
1106 | 2705 (ange-ftp-put-hash-entry |
2706 key res ange-ftp-expand-dir-hashtable))) | |
2707 res)))) | |
2708 | |
2709 (defun ange-ftp-canonize-filename (n) | |
2710 "Take a string and short-circuit //, /. and /.." | |
2711 (if (string-match ".+//" n) ;don't upset Apollo users | |
2712 (setq n (substring n (1- (match-end 0))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2713 (let ((parsed (ange-ftp-ftp-name n))) |
1106 | 2714 (if parsed |
2715 (let ((host (car parsed)) | |
2716 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2717 (name (nth 2 parsed))) |
1106 | 2718 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2719 ;; See if remote name is absolute. If so then just expand it and |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2720 ;; replace the name component of the overall name. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2721 (cond ((string-match "^/" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2722 name) |
1106 | 2723 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2724 ;; Name starts with ~ or ~user. Resolve that part of the name |
1106 | 2725 ;; making it absolute then re-expand it. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2726 ((string-match "^~[^/]*" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2727 (let* ((tilda (substring name |
1106 | 2728 (match-beginning 0) |
2729 (match-end 0))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2730 (rest (substring name (match-end 0))) |
1106 | 2731 (dir (ange-ftp-expand-dir host user tilda))) |
2732 (if dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2733 (setq name (concat dir rest)) |
1106 | 2734 (error "User \"%s\" is not known" |
2735 (substring tilda 1))))) | |
2736 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2737 ;; relative name. Tack on homedir and re-expand. |
1106 | 2738 (t |
2739 (let ((dir (ange-ftp-expand-dir host user "~"))) | |
2740 (if dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2741 (setq name (concat |
1106 | 2742 (ange-ftp-real-file-name-as-directory dir) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2743 name)) |
1106 | 2744 (error "Unable to obtain CWD"))))) |
2745 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2746 (setq name (ange-ftp-real-expand-file-name name)) |
1106 | 2747 |
2748 ;; see if hit real expand-file-name bug... this will probably annoy | |
2749 ;; some Apollo people. I'll wait until they shout, however. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2750 (if (string-match "^//" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2751 (setq name (substring name 1))) |
1106 | 2752 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2753 ;; Now substitute the expanded name back into the overall filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2754 (ange-ftp-replace-name-component n name)) |
1106 | 2755 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2756 ;; non-ange-ftp name. Just expand normally. |
1106 | 2757 (if (eq (string-to-char n) ?/) |
2758 (ange-ftp-real-expand-file-name n) | |
2759 (ange-ftp-real-expand-file-name | |
2760 (ange-ftp-real-file-name-nondirectory n) | |
2761 (ange-ftp-real-file-name-directory n)))))) | |
2762 | |
2763 (defun ange-ftp-expand-file-name (name &optional default) | |
2764 "Documented as original." | |
2765 (ange-ftp-save-match-data | |
2766 (if (eq (string-to-char name) ?/) | |
2767 (while (cond ((string-match ".+//" name) ;don't upset Apollo users | |
2768 (setq name (substring name (1- (match-end 0))))) | |
2769 ((string-match "/~" name) | |
2770 (setq name (substring name (1- (match-end 0)))))))) | |
2771 (cond ((eq (string-to-char name) ?~) | |
2772 (ange-ftp-real-expand-file-name name)) | |
2773 ((eq (string-to-char name) ?/) | |
2774 (ange-ftp-canonize-filename name)) | |
2775 ((zerop (length name)) | |
2776 (ange-ftp-canonize-filename (or default default-directory))) | |
2777 ((ange-ftp-canonize-filename | |
2778 (concat (file-name-as-directory (or default default-directory)) | |
2779 name)))))) | |
2780 | |
2781 ;;; These are problems--they are currently not enabled. | |
2782 | |
2783 (defvar ange-ftp-file-name-as-directory-alist nil | |
2784 "Association list of \( TYPE \. FUNC \) pairs, where | |
2785 FUNC converts a filename to a directory name for the operating | |
2786 system TYPE.") | |
2787 | |
2788 (defun ange-ftp-file-name-as-directory (name) | |
2789 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2790 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2791 (if parsed |
2792 (if (string-equal (nth 2 parsed) "") | |
2793 name | |
2794 (funcall (or (cdr (assq | |
2795 (ange-ftp-host-type (car parsed)) | |
2796 ange-ftp-file-name-as-directory-alist)) | |
2797 'ange-ftp-real-file-name-as-directory) | |
2798 name)) | |
2799 (ange-ftp-real-file-name-as-directory name)))) | |
2800 | |
2801 (defun ange-ftp-file-name-directory (name) | |
2802 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2803 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2804 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2805 (let ((filename (nth 2 parsed))) |
1106 | 2806 (if (ange-ftp-save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2807 (string-match "^~[^/]*$" filename)) |
1106 | 2808 name |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2809 (ange-ftp-replace-name-component |
1106 | 2810 name |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2811 (ange-ftp-real-file-name-directory filename)))) |
1106 | 2812 (ange-ftp-real-file-name-directory name)))) |
2813 | |
2814 (defun ange-ftp-file-name-nondirectory (name) | |
2815 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2816 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2817 (if parsed |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
2818 (let ((filename (nth 2 parsed))) |
1106 | 2819 (if (ange-ftp-save-match-data |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
2820 (string-match "^~[^/]*$" filename)) |
1106 | 2821 "" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2822 (ange-ftp-real-file-name-nondirectory name))) |
1106 | 2823 (ange-ftp-real-file-name-nondirectory name)))) |
2824 | |
2825 (defun ange-ftp-directory-file-name (dir) | |
2826 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2827 (let ((parsed (ange-ftp-ftp-name dir))) |
1106 | 2828 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2829 (ange-ftp-replace-name-component |
1106 | 2830 dir |
2831 (ange-ftp-real-directory-file-name (nth 2 parsed))) | |
2832 (ange-ftp-real-directory-file-name dir)))) | |
2833 | |
2834 | |
2835 ;;; Hooks that handle Emacs primitives. | |
2836 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2837 ;; Returns non-nil if should transfer FILE in binary mode. |
1106 | 2838 (defun ange-ftp-binary-file (file) |
2839 (ange-ftp-save-match-data | |
2840 (string-match ange-ftp-binary-file-name-regexp file))) | |
2841 | |
2842 (defun ange-ftp-write-region (start end filename &optional append visit) | |
2843 (setq filename (expand-file-name filename)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2844 (let ((parsed (ange-ftp-ftp-name filename))) |
1106 | 2845 (if parsed |
2846 (let* ((host (nth 0 parsed)) | |
2847 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2848 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2849 (temp (ange-ftp-make-tmp-name host)) |
2850 (binary (ange-ftp-binary-file filename)) | |
2851 (cmd (if append 'append 'put)) | |
2852 (abbr (ange-ftp-abbreviate-filename filename))) | |
2853 (unwind-protect | |
2854 (progn | |
2855 (let ((executing-macro t) | |
2856 (filename (buffer-file-name)) | |
2857 (mod-p (buffer-modified-p))) | |
2858 (unwind-protect | |
2859 (ange-ftp-real-write-region start end temp nil visit) | |
2860 ;; cleanup forms | |
2861 (setq buffer-file-name filename) | |
2862 (set-buffer-modified-p mod-p))) | |
2863 (if binary | |
2864 (ange-ftp-set-binary-mode host user)) | |
2865 | |
2866 ;; tell the process filter what size the transfer will be. | |
2867 (let ((attr (file-attributes temp))) | |
2868 (if attr | |
2869 (ange-ftp-set-xfer-size host user (nth 7 attr)))) | |
2870 | |
2871 ;; put or append the file. | |
2872 (let ((result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2873 (list cmd temp name) |
1106 | 2874 (format "Writing %s" abbr)))) |
2875 (or (car result) | |
2876 (signal 'ftp-error | |
2877 (list | |
2878 "Opening output file" | |
2879 (format "FTP Error: \"%s\"" (cdr result)) | |
2880 filename))))) | |
2881 (ange-ftp-del-tmp-name temp) | |
2882 (if binary | |
2883 (ange-ftp-set-ascii-mode host user))) | |
2884 (if (eq visit t) | |
2885 (progn | |
2886 (ange-ftp-set-buffer-mode) | |
2887 (setq buffer-file-name filename) | |
2888 (set-buffer-modified-p nil))) | |
2889 (ange-ftp-message "Wrote %s" abbr) | |
2890 (ange-ftp-add-file-entry filename)) | |
2891 (ange-ftp-real-write-region start end filename append visit)))) | |
2892 | |
2893 (defun ange-ftp-insert-file-contents (filename &optional visit) | |
2894 (barf-if-buffer-read-only) | |
2895 (setq filename (expand-file-name filename)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2896 (let ((parsed (ange-ftp-ftp-name filename))) |
1106 | 2897 (if parsed |
2898 (progn | |
2899 (if visit | |
2900 (setq buffer-file-name filename)) | |
2901 (if (or (file-exists-p filename) | |
2902 (progn | |
2903 (setq ange-ftp-ls-cache-file nil) | |
2904 (ange-ftp-del-hash-entry (file-name-directory filename) | |
2905 ange-ftp-files-hashtable) | |
2906 (file-exists-p filename))) | |
2907 (let* ((host (nth 0 parsed)) | |
2908 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2909 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2910 (temp (ange-ftp-make-tmp-name host)) |
2911 (binary (ange-ftp-binary-file filename)) | |
2912 (abbr (ange-ftp-abbreviate-filename filename)) | |
2913 size) | |
2914 (unwind-protect | |
2915 (progn | |
2916 (if binary | |
2917 (ange-ftp-set-binary-mode host user)) | |
2918 (let ((result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2919 (list 'get name temp) |
1106 | 2920 (format "Retrieving %s" abbr)))) |
2921 (or (car result) | |
2922 (signal 'ftp-error | |
2923 (list | |
2924 "Opening input file" | |
2925 (format "FTP Error: \"%s\"" (cdr result)) | |
2926 filename)))) | |
2927 (if (or (ange-ftp-real-file-readable-p temp) | |
2928 (sleep-for ange-ftp-retry-time) | |
2929 ;; Wait for file to hopefully appear. | |
2930 (ange-ftp-real-file-readable-p temp)) | |
2931 (setq | |
2932 size | |
2933 (nth 1 (ange-ftp-real-insert-file-contents temp | |
2934 visit))) | |
2935 (signal 'ftp-error | |
2936 (list | |
2937 "Opening input file:" | |
2938 (format | |
2939 "FTP Error: %s not arrived or readable" | |
2940 filename))))) | |
2941 (if binary | |
2942 (ange-ftp-set-ascii-mode host user)) | |
2943 (ange-ftp-del-tmp-name temp)) | |
2944 (if visit | |
2945 (setq buffer-file-name filename)) | |
2946 (list filename size)) | |
2947 (signal 'file-error | |
2948 (list | |
2949 "Opening input file" | |
2950 filename)))) | |
2951 (ange-ftp-real-insert-file-contents filename visit)))) | |
2952 | |
2953 (defun ange-ftp-expand-symlink (file dir) | |
2954 (if (file-name-absolute-p file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2955 (ange-ftp-replace-name-component dir file) |
1106 | 2956 (expand-file-name file dir))) |
2957 | |
2958 (defun ange-ftp-file-symlink-p (file) | |
2959 ;; call ange-ftp-expand-file-name rather than the normal | |
2960 ;; expand-file-name to stop loops when using a package that | |
2961 ;; redefines both file-symlink-p and expand-file-name. | |
2962 (setq file (ange-ftp-expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2963 (if (ange-ftp-ftp-name file) |
1106 | 2964 (let ((file-ent |
2965 (ange-ftp-get-hash-entry | |
2966 (ange-ftp-get-file-part file) | |
2967 (ange-ftp-get-files (file-name-directory file))))) | |
2968 (if (stringp file-ent) | |
2969 (if (file-name-absolute-p file-ent) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2970 (ange-ftp-replace-name-component |
1106 | 2971 (file-name-directory file) file-ent) |
2972 file-ent))) | |
2973 (ange-ftp-real-file-symlink-p file))) | |
2974 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2975 (defun ange-ftp-file-exists-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2976 (setq name (expand-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2977 (if (ange-ftp-ftp-name name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2978 (if (ange-ftp-file-entry-p name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2979 (let ((file-ent (ange-ftp-get-file-entry name))) |
1106 | 2980 (if (stringp file-ent) |
2981 (file-exists-p | |
2982 (ange-ftp-expand-symlink file-ent | |
2983 (file-name-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2984 (directory-file-name name)))) |
1106 | 2985 t))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2986 (ange-ftp-real-file-exists-p name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2987 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2988 (defun ange-ftp-file-directory-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2989 (setq name (expand-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2990 (if (ange-ftp-ftp-name name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2991 ;; We do a file-name-as-directory on name here because some |
1106 | 2992 ;; machines (VMS) use a .DIR to indicate the filename associated |
2993 ;; with a directory. This needs to be canonicalized. | |
2994 (let ((file-ent (ange-ftp-get-file-entry | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2995 (ange-ftp-file-name-as-directory name)))) |
1106 | 2996 (if (stringp file-ent) |
2997 (file-directory-p | |
2998 (ange-ftp-expand-symlink file-ent | |
2999 (file-name-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3000 (directory-file-name name)))) |
1106 | 3001 file-ent)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3002 (ange-ftp-real-file-directory-p name))) |
1106 | 3003 |
3004 (defun ange-ftp-directory-files (directory &optional full match | |
3005 &rest v19-args) | |
3006 (setq directory (expand-file-name directory)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3007 (if (ange-ftp-ftp-name directory) |
1106 | 3008 (progn |
3009 (ange-ftp-barf-if-not-directory directory) | |
3010 (let ((tail (ange-ftp-hash-table-keys | |
3011 (ange-ftp-get-files directory))) | |
3012 files f) | |
3013 (setq directory (file-name-as-directory directory)) | |
3014 (ange-ftp-save-match-data | |
3015 (while tail | |
3016 (setq f (car tail) | |
3017 tail (cdr tail)) | |
3018 (if (or (not match) (string-match match f)) | |
3019 (setq files | |
3020 (cons (if full (concat directory f) f) files))))) | |
3021 (nreverse files))) | |
3022 (apply 'ange-ftp-real-directory-files directory full match v19-args))) | |
3023 | |
3024 (defun ange-ftp-file-attributes (file) | |
3025 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3026 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 3027 (if parsed |
3028 (let ((part (ange-ftp-get-file-part file)) | |
3029 (files (ange-ftp-get-files (file-name-directory file)))) | |
3030 (if (ange-ftp-hash-entry-exists-p part files) | |
3031 (let ((host (nth 0 parsed)) | |
3032 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3033 (name (nth 2 parsed)) |
1106 | 3034 (dirp (ange-ftp-get-hash-entry part files))) |
3035 (list (if (and (stringp dirp) (file-name-absolute-p dirp)) | |
3036 (ange-ftp-expand-symlink dirp | |
3037 (file-name-directory file)) | |
3038 dirp) ;0 file type | |
3039 -1 ;1 link count | |
3040 -1 ;2 uid | |
3041 -1 ;3 gid | |
3042 '(0 0) ;4 atime | |
3043 '(0 0) ;5 mtime | |
3044 '(0 0) ;6 ctime | |
3045 -1 ;7 size | |
3046 (concat (if (stringp dirp) "l" (if dirp "d" "-")) | |
3047 "?????????") ;8 mode | |
3048 nil ;9 gid weird | |
3049 ;; Hack to give remote files a unique "inode number". | |
3050 ;; It's actually the sum of the characters in its name. | |
3051 (apply '+ (nconc (mapcar 'identity host) | |
3052 (mapcar 'identity user) | |
3053 (mapcar 'identity | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3054 (directory-file-name name)))) |
1106 | 3055 -1 ;11 device number [v19 only] |
3056 )))) | |
3057 (ange-ftp-real-file-attributes file)))) | |
3058 | |
3059 (defun ange-ftp-file-writable-p (file) | |
3060 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3061 (if (ange-ftp-ftp-name file) |
1106 | 3062 (or (file-exists-p file) ;guess here for speed |
3063 (file-directory-p (file-name-directory file))) | |
3064 (ange-ftp-real-file-writable-p file))) | |
3065 | |
3066 (defun ange-ftp-file-readable-p (file) | |
3067 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3068 (if (ange-ftp-ftp-name file) |
1106 | 3069 (file-exists-p file) |
3070 (ange-ftp-real-file-readable-p file))) | |
3071 | |
3072 (defun ange-ftp-delete-file (file) | |
3073 (interactive "fDelete file: ") | |
3074 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3075 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 3076 (if parsed |
3077 (let* ((host (nth 0 parsed)) | |
3078 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3079 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 3080 (abbr (ange-ftp-abbreviate-filename file)) |
3081 (result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3082 (list 'delete name) |
1106 | 3083 (format "Deleting %s" abbr)))) |
3084 (or (car result) | |
3085 (signal 'ftp-error | |
3086 (list | |
3087 "Removing old name" | |
3088 (format "FTP Error: \"%s\"" (cdr result)) | |
3089 file))) | |
3090 (ange-ftp-delete-file-entry file)) | |
3091 (ange-ftp-real-delete-file file)))) | |
3092 | |
3093 (defun ange-ftp-verify-visited-file-modtime (buf) | |
3094 (let ((name (buffer-file-name buf))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3095 (if (and (stringp name) (ange-ftp-ftp-name name)) |
1106 | 3096 t |
3097 (ange-ftp-real-verify-visited-file-modtime buf)))) | |
3098 | |
3099 ;;;; ------------------------------------------------------------ | |
3100 ;;;; File copying support... totally re-written 6/24/92. | |
3101 ;;;; ------------------------------------------------------------ | |
3102 | |
3103 (defun ange-ftp-barf-or-query-if-file-exists (absname querystring interactive) | |
3104 (if (file-exists-p absname) | |
3105 (if (not interactive) | |
3106 (signal 'file-already-exists (list absname)) | |
3107 (if (not (yes-or-no-p (format "File %s already exists; %s anyway? " | |
3108 absname querystring))) | |
3109 (signal 'file-already-exists (list absname)))))) | |
3110 | |
3111 ;; async local copy commented out for now since I don't seem to get | |
3112 ;; the process sentinel called for some processes. | |
3113 ;; | |
3114 ;; (defun ange-ftp-copy-file-locally (filename newname ok-if-already-exists | |
3115 ;; keep-date cont) | |
3116 ;; "Kludge to copy a local file and call a continuation when the copy | |
3117 ;; finishes." | |
3118 ;; ;; check to see if we can overwrite | |
3119 ;; (if (or (not ok-if-already-exists) | |
3120 ;; (numberp ok-if-already-exists)) | |
3121 ;; (ange-ftp-barf-or-query-if-file-exists newname "copy to it" | |
3122 ;; (numberp ok-if-already-exists))) | |
3123 ;; (let ((proc (start-process " *copy*" | |
3124 ;; (generate-new-buffer "*copy*") | |
3125 ;; "cp" | |
3126 ;; filename | |
3127 ;; newname)) | |
3128 ;; res) | |
3129 ;; (set-process-sentinel proc (function ange-ftp-copy-file-locally-sentinel)) | |
3130 ;; (process-kill-without-query proc) | |
3131 ;; (save-excursion | |
3132 ;; (set-buffer (process-buffer proc)) | |
3133 ;; (make-variable-buffer-local 'copy-cont) | |
3134 ;; (setq copy-cont cont)))) | |
3135 ;; | |
3136 ;; (defun ange-ftp-copy-file-locally-sentinel (proc status) | |
3137 ;; (save-excursion | |
3138 ;; (set-buffer (process-buffer proc)) | |
3139 ;; (let ((cont copy-cont) | |
3140 ;; (result (buffer-string))) | |
3141 ;; (unwind-protect | |
3142 ;; (if (and (string-equal status "finished\n") | |
3143 ;; (zerop (length result))) | |
3144 ;; (ange-ftp-call-cont cont t nil) | |
3145 ;; (ange-ftp-call-cont cont | |
3146 ;; nil | |
3147 ;; (if (zerop (length result)) | |
3148 ;; (substring status 0 -1) | |
3149 ;; (substring result 0 -1)))) | |
3150 ;; (kill-buffer (current-buffer)))))) | |
3151 | |
3152 ;; this is the extended version of ange-ftp-copy-file-internal that works | |
3153 ;; asyncronously if asked nicely. | |
3154 (defun ange-ftp-copy-file-internal (filename newname ok-if-already-exists | |
3155 keep-date &optional msg cont nowait) | |
3156 (setq filename (expand-file-name filename) | |
3157 newname (expand-file-name newname)) | |
3158 | |
3159 ;; canonicalize newname if a directory. | |
3160 (if (file-directory-p newname) | |
3161 (setq newname (expand-file-name (file-name-nondirectory filename) newname))) | |
3162 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3163 (let ((f-parsed (ange-ftp-ftp-name filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3164 (t-parsed (ange-ftp-ftp-name newname))) |
1106 | 3165 |
3166 ;; local file to local file copy? | |
3167 (if (and (not f-parsed) (not t-parsed)) | |
3168 (progn | |
3169 (ange-ftp-real-copy-file filename newname ok-if-already-exists | |
3170 keep-date) | |
3171 (if cont | |
3172 (ange-ftp-call-cont cont t "Copied locally"))) | |
3173 ;; one or both files are remote. | |
3174 (let* ((f-host (and f-parsed (nth 0 f-parsed))) | |
3175 (f-user (and f-parsed (nth 1 f-parsed))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3176 (f-name (and f-parsed (ange-ftp-quote-string (nth 2 f-parsed)))) |
1106 | 3177 (f-abbr (ange-ftp-abbreviate-filename filename)) |
3178 (t-host (and t-parsed (nth 0 t-parsed))) | |
3179 (t-user (and t-parsed (nth 1 t-parsed))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3180 (t-name (and t-parsed (ange-ftp-quote-string (nth 2 t-parsed)))) |
1106 | 3181 (t-abbr (ange-ftp-abbreviate-filename newname filename)) |
3182 (binary (or (ange-ftp-binary-file filename) | |
3183 (ange-ftp-binary-file newname))) | |
3184 temp1 | |
3185 temp2) | |
3186 | |
3187 ;; check to see if we can overwrite | |
3188 (if (or (not ok-if-already-exists) | |
3189 (numberp ok-if-already-exists)) | |
3190 (ange-ftp-barf-or-query-if-file-exists newname "copy to it" | |
3191 (numberp ok-if-already-exists))) | |
3192 | |
3193 ;; do the copying. | |
3194 (if f-parsed | |
3195 | |
3196 ;; filename was remote. | |
3197 (progn | |
3198 (if (or (ange-ftp-use-gateway-p f-host) | |
3199 t-parsed) | |
3200 ;; have to use intermediate file if we are getting via | |
3201 ;; gateway machine or we are doing a remote to remote copy. | |
3202 (setq temp1 (ange-ftp-make-tmp-name f-host))) | |
3203 | |
3204 (if binary | |
3205 (ange-ftp-set-binary-mode f-host f-user)) | |
3206 | |
3207 (ange-ftp-send-cmd | |
3208 f-host | |
3209 f-user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3210 (list 'get f-name (or temp1 newname)) |
1106 | 3211 (or msg |
3212 (if (and temp1 t-parsed) | |
3213 (format "Getting %s" f-abbr) | |
3214 (format "Copying %s to %s" f-abbr t-abbr))) | |
3215 (list (function ange-ftp-cf1) | |
3216 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3217 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3218 t-parsed t-host t-user t-name t-abbr |
1106 | 3219 temp1 temp2 cont nowait) |
3220 nowait)) | |
3221 | |
3222 ;; filename wasn't remote. newname must be remote. call the | |
3223 ;; function which does the remainder of the copying work. | |
3224 (ange-ftp-cf1 t nil | |
3225 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3226 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3227 t-parsed t-host t-user t-name t-abbr |
1106 | 3228 nil nil cont nowait)))))) |
3229 | |
3230 ;; next part of copying routine. | |
3231 (defun ange-ftp-cf1 (result line | |
3232 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3233 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3234 t-parsed t-host t-user t-name t-abbr |
1106 | 3235 temp1 temp2 cont nowait) |
3236 (if line | |
3237 ;; filename must have been remote, and we must have just done a GET. | |
3238 (unwind-protect | |
3239 (or result | |
3240 ;; GET failed for some reason. Clean up and get out. | |
3241 (progn | |
3242 (and temp1 (ange-ftp-del-tmp-name temp1)) | |
3243 (or cont | |
3244 (signal 'ftp-error (list "Opening input file" | |
3245 (format "FTP Error: \"%s\"" line) | |
3246 filename))))) | |
3247 ;; cleanup | |
3248 (if binary | |
3249 (ange-ftp-set-ascii-mode f-host f-user)))) | |
3250 | |
3251 (if result | |
3252 ;; We now have to copy either temp1 or filename to newname. | |
3253 (if t-parsed | |
3254 | |
3255 ;; newname was remote. | |
3256 (progn | |
3257 (if (ange-ftp-use-gateway-p t-host) | |
3258 (setq temp2 (ange-ftp-make-tmp-name t-host))) | |
3259 | |
3260 ;; make sure data is moved into the right place for the | |
3261 ;; outgoing transfer. gateway temporary files complicate | |
3262 ;; things nicely. | |
3263 (if temp1 | |
3264 (if temp2 | |
3265 (if (string-equal temp1 temp2) | |
3266 (setq temp1 nil) | |
3267 (ange-ftp-real-copy-file temp1 temp2 t)) | |
3268 (setq temp2 temp1 temp1 nil)) | |
3269 (if temp2 | |
3270 (ange-ftp-real-copy-file filename temp2 t))) | |
3271 | |
3272 (if binary | |
3273 (ange-ftp-set-binary-mode t-host t-user)) | |
3274 | |
3275 ;; tell the process filter what size the file is. | |
3276 (let ((attr (file-attributes (or temp2 filename)))) | |
3277 (if attr | |
3278 (ange-ftp-set-xfer-size t-host t-user (nth 7 attr)))) | |
3279 | |
3280 (ange-ftp-send-cmd | |
3281 t-host | |
3282 t-user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3283 (list 'put (or temp2 filename) t-name) |
1106 | 3284 (or msg |
3285 (if (and temp2 f-parsed) | |
3286 (format "Putting %s" newname) | |
3287 (format "Copying %s to %s" f-abbr t-abbr))) | |
3288 (list (function ange-ftp-cf2) | |
3289 newname t-host t-user binary temp1 temp2 cont) | |
3290 nowait)) | |
3291 | |
3292 ;; newname wasn't remote. | |
3293 (ange-ftp-cf2 t nil newname t-host t-user binary temp1 temp2 cont)) | |
3294 | |
3295 ;; first copy failed, tell caller | |
3296 (ange-ftp-call-cont cont result line))) | |
3297 | |
3298 ;; last part of copying routine. | |
3299 (defun ange-ftp-cf2 (result line newname t-host t-user binary temp1 temp2 cont) | |
3300 (unwind-protect | |
3301 (if line | |
3302 ;; result from doing a local to remote copy. | |
3303 (unwind-protect | |
3304 (progn | |
3305 (or result | |
3306 (or cont | |
3307 (signal 'ftp-error | |
3308 (list "Opening output file" | |
3309 (format "FTP Error: \"%s\"" line) | |
3310 newname)))) | |
3311 | |
3312 (ange-ftp-add-file-entry newname)) | |
3313 | |
3314 ;; cleanup. | |
3315 (if binary | |
3316 (ange-ftp-set-ascii-mode t-host t-user))) | |
3317 | |
3318 ;; newname was local. | |
3319 (if temp1 | |
3320 (ange-ftp-real-copy-file temp1 newname t))) | |
3321 | |
3322 ;; clean up | |
3323 (and temp1 (ange-ftp-del-tmp-name temp1)) | |
3324 (and temp2 (ange-ftp-del-tmp-name temp2)) | |
3325 (ange-ftp-call-cont cont result line))) | |
3326 | |
3327 (defun ange-ftp-copy-file (filename newname &optional ok-if-already-exists | |
3328 keep-date) | |
3329 (interactive "fCopy file: \nFCopy %s to file: \np") | |
3330 (ange-ftp-copy-file-internal filename | |
3331 newname | |
3332 ok-if-already-exists | |
3333 keep-date | |
3334 nil | |
3335 nil | |
3336 (interactive-p))) | |
3337 | |
3338 ;;;; ------------------------------------------------------------ | |
3339 ;;;; File renaming support. | |
3340 ;;;; ------------------------------------------------------------ | |
3341 | |
3342 (defun ange-ftp-rename-remote-to-remote (filename newname f-parsed t-parsed | |
3343 binary) | |
3344 "Rename remote file FILE to remote file NEWNAME." | |
3345 (let ((f-host (nth 0 f-parsed)) | |
3346 (f-user (nth 1 f-parsed)) | |
3347 (t-host (nth 0 t-parsed)) | |
3348 (t-user (nth 1 t-parsed))) | |
3349 (if (and (string-equal f-host t-host) | |
3350 (string-equal f-user t-user)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3351 (let* ((f-name (ange-ftp-quote-string (nth 2 f-parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3352 (t-name (ange-ftp-quote-string (nth 2 t-parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3353 (cmd (list 'rename f-name t-name)) |
1106 | 3354 (fabbr (ange-ftp-abbreviate-filename filename)) |
3355 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3356 (result (ange-ftp-send-cmd f-host f-user cmd | |
3357 (format "Renaming %s to %s" | |
3358 fabbr | |
3359 nabbr)))) | |
3360 (or (car result) | |
3361 (signal 'ftp-error | |
3362 (list | |
3363 "Renaming" | |
3364 (format "FTP Error: \"%s\"" (cdr result)) | |
3365 filename | |
3366 newname))) | |
3367 (ange-ftp-add-file-entry newname) | |
3368 (ange-ftp-delete-file-entry filename)) | |
3369 (ange-ftp-copy-file-internal filename newname t nil) | |
3370 (delete-file filename)))) | |
3371 | |
3372 (defun ange-ftp-rename-local-to-remote (filename newname) | |
1233 | 3373 "Rename local FILENAME to remote file NEWNAME." |
1106 | 3374 (let* ((fabbr (ange-ftp-abbreviate-filename filename)) |
3375 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3376 (msg (format "Renaming %s to %s" fabbr nabbr))) | |
3377 (ange-ftp-copy-file-internal filename newname t nil msg) | |
3378 (let (ange-ftp-process-verbose) | |
3379 (delete-file filename)))) | |
3380 | |
3381 (defun ange-ftp-rename-remote-to-local (filename newname) | |
1233 | 3382 "Rename remote file FILENAME to local file NEWNAME." |
1106 | 3383 (let* ((fabbr (ange-ftp-abbreviate-filename filename)) |
3384 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3385 (msg (format "Renaming %s to %s" fabbr nabbr))) | |
3386 (ange-ftp-copy-file-internal filename newname t nil msg) | |
3387 (let (ange-ftp-process-verbose) | |
3388 (delete-file filename)))) | |
3389 | |
3390 (defun ange-ftp-rename-file (filename newname &optional ok-if-already-exists) | |
3391 (interactive "fRename file: \nFRename %s to file: \np") | |
3392 (setq filename (expand-file-name filename)) | |
3393 (setq newname (expand-file-name newname)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3394 (let* ((f-parsed (ange-ftp-ftp-name filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3395 (t-parsed (ange-ftp-ftp-name newname)) |
1106 | 3396 (binary (if (or f-parsed t-parsed) (ange-ftp-binary-file filename)))) |
3397 (if (and (or f-parsed t-parsed) | |
3398 (or (not ok-if-already-exists) | |
3399 (numberp ok-if-already-exists))) | |
3400 (ange-ftp-barf-or-query-if-file-exists | |
3401 newname | |
3402 "rename to it" | |
3403 (numberp ok-if-already-exists))) | |
3404 (if f-parsed | |
3405 (if t-parsed | |
3406 (ange-ftp-rename-remote-to-remote filename newname f-parsed | |
3407 t-parsed binary) | |
3408 (ange-ftp-rename-remote-to-local filename newname)) | |
3409 (if t-parsed | |
3410 (ange-ftp-rename-local-to-remote filename newname) | |
3411 (ange-ftp-real-rename-file filename newname ok-if-already-exists))))) | |
3412 | |
3413 ;;;; ------------------------------------------------------------ | |
3414 ;;;; File name completion support. | |
3415 ;;;; ------------------------------------------------------------ | |
3416 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3417 ;; If the file entry SYM is a symlink, returns whether its file exists. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3418 ;; Note that `ange-ftp-this-dir' is used as a free variable. |
1106 | 3419 (defun ange-ftp-file-entry-active-p (sym) |
3420 (let ((val (get sym 'val))) | |
3421 (or (not (stringp val)) | |
3422 (file-exists-p (ange-ftp-expand-symlink val ange-ftp-this-dir))))) | |
3423 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3424 ;; If the file entry is not a directory (nor a symlink pointing to a directory) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3425 ;; returns whether the file (or file pointed to by the symlink) is ignored |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3426 ;; by completion-ignored-extensions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3427 ;; Note that `ange-ftp-this-dir' and `ange-ftp-completion-ignored-pattern' |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3428 ;; are used as free variables. |
1106 | 3429 (defun ange-ftp-file-entry-not-ignored-p (sym) |
3430 (let ((val (get sym 'val)) | |
3431 (symname (symbol-name sym))) | |
3432 (if (stringp val) | |
3433 (let ((file (ange-ftp-expand-symlink val ange-ftp-this-dir))) | |
3434 (or (file-directory-p file) | |
3435 (and (file-exists-p file) | |
3436 (not (string-match ange-ftp-completion-ignored-pattern | |
3437 symname))))) | |
3438 (or val ; is a directory name | |
3439 (not (string-match ange-ftp-completion-ignored-pattern symname)))))) | |
3440 | |
3441 (defun ange-ftp-file-name-all-completions (file dir) | |
3442 (let ((ange-ftp-this-dir (expand-file-name dir))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3443 (if (ange-ftp-ftp-name ange-ftp-this-dir) |
1106 | 3444 (progn |
3445 (ange-ftp-barf-if-not-directory ange-ftp-this-dir) | |
3446 (setq ange-ftp-this-dir | |
3447 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir)) | |
3448 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir)) | |
3449 (completions | |
3450 (all-completions file tbl | |
3451 (function ange-ftp-file-entry-active-p)))) | |
3452 | |
3453 ;; see whether each matching file is a directory or not... | |
3454 (mapcar | |
3455 (function | |
3456 (lambda (file) | |
3457 (let ((ent (ange-ftp-get-hash-entry file tbl))) | |
3458 (if (and ent | |
3459 (or (not (stringp ent)) | |
3460 (file-directory-p | |
3461 (ange-ftp-expand-symlink ent | |
3462 ange-ftp-this-dir)))) | |
3463 (concat file "/") | |
3464 file)))) | |
3465 completions))) | |
3466 | |
3467 (if (string-equal "/" ange-ftp-this-dir) | |
3468 (nconc (all-completions file (ange-ftp-generate-root-prefixes)) | |
3469 (ange-ftp-real-file-name-all-completions file | |
3470 ange-ftp-this-dir)) | |
3471 (ange-ftp-real-file-name-all-completions file ange-ftp-this-dir))))) | |
3472 | |
3473 (defun ange-ftp-file-name-completion (file dir) | |
3474 (let ((ange-ftp-this-dir (expand-file-name dir))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3475 (if (ange-ftp-ftp-name ange-ftp-this-dir) |
1106 | 3476 (progn |
3477 (ange-ftp-barf-if-not-directory ange-ftp-this-dir) | |
3478 (if (equal file "") | |
3479 "" | |
3480 (setq ange-ftp-this-dir | |
3481 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir)) ;real? | |
3482 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir)) | |
3483 (ange-ftp-completion-ignored-pattern | |
3484 (mapconcat (function | |
3485 (lambda (s) (if (stringp s) | |
3486 (concat (regexp-quote s) "$") | |
3487 "/"))) ; / never in filename | |
3488 completion-ignored-extensions | |
3489 "\\|"))) | |
3490 (ange-ftp-save-match-data | |
3491 (or (ange-ftp-file-name-completion-1 | |
3492 file tbl ange-ftp-this-dir | |
3493 (function ange-ftp-file-entry-not-ignored-p)) | |
3494 (ange-ftp-file-name-completion-1 | |
3495 file tbl ange-ftp-this-dir | |
3496 (function ange-ftp-file-entry-active-p))))))) | |
3497 | |
3498 (if (string-equal "/" ange-ftp-this-dir) | |
3499 (try-completion | |
3500 file | |
3501 (nconc (ange-ftp-generate-root-prefixes) | |
3502 (mapcar 'list | |
3503 (ange-ftp-real-file-name-all-completions file "/")))) | |
3504 (ange-ftp-real-file-name-completion file ange-ftp-this-dir))))) | |
3505 | |
3506 | |
3507 (defun ange-ftp-file-name-completion-1 (file tbl dir predicate) | |
3508 (let ((bestmatch (try-completion file tbl predicate))) | |
3509 (if bestmatch | |
3510 (if (eq bestmatch t) | |
3511 (if (file-directory-p (expand-file-name file dir)) | |
3512 (concat file "/") | |
3513 t) | |
3514 (if (and (eq (try-completion bestmatch tbl predicate) t) | |
3515 (file-directory-p | |
3516 (expand-file-name bestmatch dir))) | |
3517 (concat bestmatch "/") | |
3518 bestmatch))))) | |
3519 | |
3520 ;; Put these lines uncommmented in your .emacs if you want C-r to refresh | |
3521 ;; ange-ftp's cache whilst doing filename completion. | |
3522 ;; | |
3523 ;;(define-key minibuffer-local-completion-map "\C-r" 'ange-ftp-re-read-dir) | |
3524 ;;(define-key minibuffer-local-must-match-map "\C-r" 'ange-ftp-re-read-dir) | |
3525 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3526 ;; Force a re-read of the directory DIR. If DIR is omitted then it defaults |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3527 ;; to the directory part of the contents of the current buffer. |
1106 | 3528 (defun ange-ftp-re-read-dir (&optional dir) |
3529 (interactive) | |
3530 (if dir | |
3531 (setq dir (expand-file-name dir)) | |
3532 (setq dir (file-name-directory (expand-file-name (buffer-string))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3533 (if (ange-ftp-ftp-name dir) |
1106 | 3534 (progn |
3535 (setq ange-ftp-ls-cache-file nil) | |
3536 (ange-ftp-del-hash-entry dir ange-ftp-files-hashtable) | |
3537 (ange-ftp-get-files dir t)))) | |
3538 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3539 (defun ange-ftp-make-directory (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3540 (interactive (list (expand-file-name (read-file-name "Make directory: ")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3541 (if (file-exists-p dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3542 (error "Cannot make directory %s: file already exists" dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3543 (let ((parsed (ange-ftp-ftp-name dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3544 (if parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3545 (let* ((host (nth 0 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3546 (user (nth 1 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3547 ;; Some ftp's on unix machines (at least on Suns) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3548 ;; insist that mkdir take a filename, and not a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3549 ;; directory-name name as an arg. Argh!! This is a bug. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3550 ;; Non-unix machines will probably always insist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3551 ;; that mkdir takes a directory-name as an arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3552 ;; (as the ftp man page says it should). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3553 (name (ange-ftp-quote-string |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3554 (if (eq (ange-ftp-host-type host) 'unix) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3555 (ange-ftp-real-directory-file-name (nth 2 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3556 (ange-ftp-real-file-name-as-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3557 (nth 2 parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3558 (abbr (ange-ftp-abbreviate-filename dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3559 (result (ange-ftp-send-cmd host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3560 (list 'mkdir name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3561 (format "Making directory %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3562 abbr)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3563 (or (car result) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3564 (ange-ftp-error host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3565 (format "Could not make directory %s: %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3566 dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3567 (cdr result)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3568 (ange-ftp-add-file-entry dir t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3569 (ange-ftp-real-make-directory dir))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3570 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3571 (defun ange-ftp-delete-directory (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3572 (if (file-directory-p dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3573 (let ((parsed (ange-ftp-ftp-name dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3574 (if parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3575 (let* ((host (nth 0 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3576 (user (nth 1 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3577 ;; Some ftp's on unix machines (at least on Suns) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3578 ;; insist that rmdir take a filename, and not a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3579 ;; directory-name name as an arg. Argh!! This is a bug. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3580 ;; Non-unix machines will probably always insist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3581 ;; that rmdir takes a directory-name as an arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3582 ;; (as the ftp man page says it should). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3583 (name (ange-ftp-quote-string |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3584 (if (eq (ange-ftp-host-type host) 'unix) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3585 (ange-ftp-real-directory-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3586 (nth 2 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3587 (ange-ftp-real-file-name-as-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3588 (nth 2 parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3589 (abbr (ange-ftp-abbreviate-filename dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3590 (result (ange-ftp-send-cmd host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3591 (list 'rmdir name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3592 (format "Removing directory %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3593 abbr)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3594 (or (car result) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3595 (ange-ftp-error host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3596 (format "Could not remove directory %s: %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3597 dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3598 (cdr result)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3599 (ange-ftp-delete-file-entry dir t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3600 (ange-ftp-real-delete-directory dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3601 (error "Not a directory: %s" dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3602 |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3603 ;; Make a local copy of FILE and return its name. |
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3604 |
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3605 (defun ange-ftp-file-local-copy (file) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3606 (let* ((fn1 (expand-file-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3607 (pa1 (ange-ftp-ftp-name fn1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3608 (if pa1 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3609 (let* ((tmp1 (ange-ftp-make-tmp-name (car pa1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3610 (bin1 (ange-ftp-binary-file fn1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3611 (ange-ftp-copy-file-internal fn1 tmp1 t nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3612 (format "Getting %s" fn1)) |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3613 tmp1)))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3614 |
1670
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3615 ;; Calculate default-unhandled-directory for a given ange-ftp buffer. |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3616 (defun ange-ftp-unhandled-file-name-directory (filename) |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3617 (file-name-directory ange-ftp-tmp-name-template)) |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3618 |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3619 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3620 ;; Need the following functions for making filenames of compressed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3621 ;; files, because some OS's (unlike UNIX) do not allow a filename to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3622 ;; have two extensions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3623 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3624 (defvar ange-ftp-make-compressed-filename-alist nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3625 "Alist of host-type-specific functions to process file names for compression. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3626 Each element has the form (TYPE . FUNC). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3627 FUNC should take one argument, a file name, and return a list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3628 of the form (COMPRESSING NEWNAME). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3629 COMPRESSING should be t if the specified file should be compressed, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3630 and nil if it should be uncompressed (that is, if it is a compressed file). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3631 NEWNAME should be the name to give the new compressed or uncompressed file.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3632 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3633 (defun ange-ftp-dired-compress-file (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3634 (let ((parsed (ange-ftp-ftp-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3635 conversion-func) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3636 (if (and parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3637 (setq conversion-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3638 (cdr (assq (ange-ftp-host-type (car parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3639 ange-ftp-make-compressed-filename-alist)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3640 (let* ((decision |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3641 (ange-ftp-save-match-data (funcall conversion-func name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3642 (compressing (car decision)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3643 (newfile (nth 1 decision))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3644 (if compressing |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3645 (ange-ftp-compress name newfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3646 (ange-ftp-uncompress name newfile))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3647 (let (file-name-handler-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3648 (dired-compress-filename name))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3649 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3650 ;; Copy FILE to this machine, compress it, and copy out to NFILE. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3651 (defun ange-ftp-compress (file nfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3652 (let* ((parsed (ange-ftp-ftp-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3653 (tmp1 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3654 (tmp2 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3655 (abbr (ange-ftp-abbreviate-filename file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3656 (nabbr (ange-ftp-abbreviate-filename nfile)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3657 (msg1 (format "Getting %s" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3658 (msg2 (format "Putting %s" nabbr))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3659 (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3660 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3661 (ange-ftp-copy-file-internal file tmp1 t nil msg1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3662 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3663 (ange-ftp-message "Compressing %s..." abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3664 (call-process-region (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3665 (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3666 shell-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3667 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3668 t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3669 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3670 "-c" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3671 (format "compress -f -c < %s > %s" tmp1 tmp2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3672 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3673 (ange-ftp-message "Compressing %s...done" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3674 (if (zerop (buffer-size)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3675 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3676 (let (ange-ftp-process-verbose) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3677 (delete-file file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3678 (ange-ftp-copy-file-internal tmp2 nfile t nil msg2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3679 (ange-ftp-del-tmp-name tmp1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3680 (ange-ftp-del-tmp-name tmp2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3681 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3682 ;; Copy FILE to this machine, uncompress it, and copy out to NFILE. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3683 (defun ange-ftp-uncompress (file nfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3684 (let* ((parsed (ange-ftp-ftp-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3685 (tmp1 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3686 (tmp2 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3687 (abbr (ange-ftp-abbreviate-filename file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3688 (nabbr (ange-ftp-abbreviate-filename nfile)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3689 (msg1 (format "Getting %s" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3690 (msg2 (format "Putting %s" nabbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3691 ;; ;; Cheap hack because of problems with binary file transfers from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3692 ;; ;; VMS hosts. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3693 ;; (gbinary (not (eq 'vms (ange-ftp-host-type (car parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3694 ) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3695 (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3696 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3697 (ange-ftp-copy-file-internal file tmp1 t nil msg1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3698 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3699 (ange-ftp-message "Uncompressing %s..." abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3700 (call-process-region (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3701 (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3702 shell-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3703 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3704 t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3705 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3706 "-c" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3707 (format "uncompress -c < %s > %s" tmp1 tmp2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3708 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3709 (ange-ftp-message "Uncompressing %s...done" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3710 (if (zerop (buffer-size)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3711 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3712 (let (ange-ftp-process-verbose) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3713 (delete-file file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3714 (ange-ftp-copy-file-internal tmp2 nfile t nil msg2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3715 (ange-ftp-del-tmp-name tmp1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3716 (ange-ftp-del-tmp-name tmp2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3717 |
1106 | 3718 ;;; Define the handler for special file names |
3719 ;;; that causes ange-ftp to be invoked. | |
3720 | |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3721 ;;;###autoload |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3722 (defun ange-ftp-hook-function (operation &rest args) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3723 (let ((fn (get operation 'ange-ftp))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3724 (if fn (apply fn args) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3725 (let (file-name-handler-alist) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3726 (apply operation args))))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3727 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3728 ;;;###autoload |
1535
ff23077bae01
* ange-ftp.el: Tighten the regular expression used in
Jim Blandy <jimb@redhat.com>
parents:
1456
diff
changeset
|
3729 (or (assoc "^/[^/:]+:" file-name-handler-alist) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3730 (setq file-name-handler-alist |
1535
ff23077bae01
* ange-ftp.el: Tighten the regular expression used in
Jim Blandy <jimb@redhat.com>
parents:
1456
diff
changeset
|
3731 (cons '("^/[^/:]+:" . ange-ftp-hook-function) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3732 file-name-handler-alist))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3733 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3734 ;;; The above two forms are sufficient to cause this file to be loaded |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3735 ;;; if the user ever uses a file name with a colon in it. |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3736 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3737 ;;; This sets the mode |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3738 (or (memq 'ange-ftp-set-buffer-mode find-file-hooks) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3739 (setq find-file-hooks |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3740 (cons 'ange-ftp-set-buffer-mode find-file-hooks))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3741 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3742 ;;; Now say where to find the handlers for particular operations. |
1106 | 3743 |
3744 (put 'file-name-directory 'ange-ftp 'ange-ftp-file-name-directory) | |
3745 (put 'file-name-nondirectory 'ange-ftp 'ange-ftp-file-name-nondirectory) | |
3746 (put 'file-name-as-directory 'ange-ftp 'ange-ftp-file-name-as-directory) | |
3747 (put 'directory-file-name 'ange-ftp 'ange-ftp-directory-file-name) | |
3748 (put 'expand-file-name 'ange-ftp 'ange-ftp-expand-file-name) | |
3749 (put 'make-directory 'ange-ftp 'ange-ftp-make-directory) | |
3750 (put 'delete-directory 'ange-ftp 'ange-ftp-delete-directory) | |
3751 (put 'insert-file-contents 'ange-ftp 'ange-ftp-insert-file-contents) | |
3752 (put 'directory-files 'ange-ftp 'ange-ftp-directory-files) | |
3753 (put 'file-directory-p 'ange-ftp 'ange-ftp-file-directory-p) | |
3754 (put 'file-writable-p 'ange-ftp 'ange-ftp-file-writable-p) | |
3755 (put 'file-readable-p 'ange-ftp 'ange-ftp-file-readable-p) | |
3756 (put 'file-symlink-p 'ange-ftp 'ange-ftp-file-symlink-p) | |
3757 (put 'delete-file 'ange-ftp 'ange-ftp-delete-file) | |
3758 (put 'read-file-name-internal 'ange-ftp 'ange-ftp-read-file-name-internal) | |
3759 (put 'verify-visited-file-modtime 'ange-ftp | |
3760 'ange-ftp-verify-visited-file-modtime) | |
3761 (put 'file-exists-p 'ange-ftp 'ange-ftp-file-exists-p) | |
3762 (put 'write-region 'ange-ftp 'ange-ftp-write-region) | |
3763 (put 'backup-buffer 'ange-ftp 'ange-ftp-backup-buffer) | |
3764 (put 'copy-file 'ange-ftp 'ange-ftp-copy-file) | |
3765 (put 'rename-file 'ange-ftp 'ange-ftp-rename-file) | |
3766 (put 'file-attributes 'ange-ftp 'ange-ftp-file-attributes) | |
3767 (put 'file-name-all-completions 'ange-ftp 'ange-ftp-file-name-all-completions) | |
3768 (put 'file-name-completion 'ange-ftp 'ange-ftp-file-name-completion) | |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3769 (put 'insert-directory 'ange-ftp 'ange-ftp-insert-directory) |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3770 (put 'file-local-copy 'ange-ftp 'ange-ftp-file-local-copy) |
1670
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3771 (put 'unhandled-file-name-directory 'ange-ftp |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3772 'ange-ftp-unhandled-file-name-directory) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3773 (put 'file-name-sans-versions 'ange-ftp 'ange-ftp-file-name-sans-versions) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3774 (put 'dired-uncache 'ange-ftp 'ange-ftp-dired-uncache) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3775 (put 'dired-compress-file 'ange-ftp 'ange-ftp-dired-compress-file) |
1454
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3776 |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3777 ;; Turn off truename processing to save time. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3778 ;; Treat each name as its own truename. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3779 (put 'file-truename 'ange-ftp 'identity) |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3780 |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3781 ;; Turn off RCS/SCCS processing to save time. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3782 ;; This returns nil for any file name as argument. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3783 (put 'vc-registered 'ange-ftp 'null) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3784 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3785 ;;; Define ways of getting at unmodified Emacs primitives, |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3786 ;;; turning off our handler. |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3787 |
1106 | 3788 (defun ange-ftp-real-file-name-directory (&rest args) |
3789 (let (file-name-handler-alist) | |
3790 (apply 'file-name-directory args))) | |
3791 (defun ange-ftp-real-file-name-nondirectory (&rest args) | |
3792 (let (file-name-handler-alist) | |
3793 (apply 'file-name-nondirectory args))) | |
3794 (defun ange-ftp-real-file-name-as-directory (&rest args) | |
3795 (let (file-name-handler-alist) | |
3796 (apply 'file-name-as-directory args))) | |
3797 (defun ange-ftp-real-directory-file-name (&rest args) | |
3798 (let (file-name-handler-alist) | |
3799 (apply 'directory-file-name args))) | |
3800 (defun ange-ftp-real-expand-file-name (&rest args) | |
3801 (let (file-name-handler-alist) | |
3802 (apply 'expand-file-name args))) | |
3803 (defun ange-ftp-real-make-directory (&rest args) | |
3804 (let (file-name-handler-alist) | |
3805 (apply 'make-directory args))) | |
3806 (defun ange-ftp-real-delete-directory (&rest args) | |
3807 (let (file-name-handler-alist) | |
3808 (apply 'delete-directory args))) | |
3809 (defun ange-ftp-real-insert-file-contents (&rest args) | |
3810 (let (file-name-handler-alist) | |
3811 (apply 'insert-file-contents args))) | |
3812 (defun ange-ftp-real-directory-files (&rest args) | |
3813 (let (file-name-handler-alist) | |
3814 (apply 'directory-files args))) | |
3815 (defun ange-ftp-real-file-directory-p (&rest args) | |
3816 (let (file-name-handler-alist) | |
3817 (apply 'file-directory-p args))) | |
3818 (defun ange-ftp-real-file-writable-p (&rest args) | |
3819 (let (file-name-handler-alist) | |
3820 (apply 'file-writable-p args))) | |
3821 (defun ange-ftp-real-file-readable-p (&rest args) | |
3822 (let (file-name-handler-alist) | |
3823 (apply 'file-readable-p args))) | |
3824 (defun ange-ftp-real-file-symlink-p (&rest args) | |
3825 (let (file-name-handler-alist) | |
3826 (apply 'file-symlink-p args))) | |
3827 (defun ange-ftp-real-delete-file (&rest args) | |
3828 (let (file-name-handler-alist) | |
3829 (apply 'delete-file args))) | |
3830 (defun ange-ftp-real-read-file-name-internal (&rest args) | |
3831 (let (file-name-handler-alist) | |
3832 (apply 'read-file-name-internal args))) | |
3833 (defun ange-ftp-real-verify-visited-file-modtime (&rest args) | |
3834 (let (file-name-handler-alist) | |
3835 (apply 'verify-visited-file-modtime args))) | |
3836 (defun ange-ftp-real-file-exists-p (&rest args) | |
3837 (let (file-name-handler-alist) | |
3838 (apply 'file-exists-p args))) | |
3839 (defun ange-ftp-real-write-region (&rest args) | |
3840 (let (file-name-handler-alist) | |
3841 (apply 'write-region args))) | |
3842 (defun ange-ftp-real-backup-buffer (&rest args) | |
3843 (let (file-name-handler-alist) | |
3844 (apply 'backup-buffer args))) | |
3845 (defun ange-ftp-real-copy-file (&rest args) | |
3846 (let (file-name-handler-alist) | |
3847 (apply 'copy-file args))) | |
3848 (defun ange-ftp-real-rename-file (&rest args) | |
3849 (let (file-name-handler-alist) | |
3850 (apply 'rename-file args))) | |
3851 (defun ange-ftp-real-file-attributes (&rest args) | |
3852 (let (file-name-handler-alist) | |
3853 (apply 'file-attributes args))) | |
3854 (defun ange-ftp-real-file-name-all-completions (&rest args) | |
3855 (let (file-name-handler-alist) | |
3856 (apply 'file-name-all-completions args))) | |
3857 (defun ange-ftp-real-file-name-completion (&rest args) | |
3858 (let (file-name-handler-alist) | |
3859 (apply 'file-name-completion args))) | |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3860 (defun ange-ftp-real-insert-directory (&rest args) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3861 (let (file-name-handler-alist) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3862 (apply 'insert-directory args))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3863 (defun ange-ftp-real-file-name-sans-versions (&rest args) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3864 (let (file-name-handler-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3865 (apply 'file-name-sans-versions args))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3866 (defun ange-ftp-real-shell-command (&rest args) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3867 (let (file-name-handler-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3868 (apply 'shell-command args))) |
1106 | 3869 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3870 ;; Here we support using dired on remote hosts. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3871 ;; I have turned off the support for using dired on foreign directory formats. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3872 ;; That involves too many unclean hooks. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3873 ;; It would be cleaner to support such operations by |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3874 ;; converting the foreign directory format to something dired can understand; |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3875 ;; something close to ls -l output. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3876 ;; The logical place to do this is in the functions ange-ftp-parse-...-listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3877 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3878 ;; Some of the old dired hooks would still be needed even if this is done. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3879 ;; I have preserved (and modernized) those hooks. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3880 ;; So the format conversion should be all that is needed. |
1106 | 3881 |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3882 (defun ange-ftp-insert-directory (file switches &optional wildcard full) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3883 (let ((short (ange-ftp-abbreviate-filename file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3884 (parsed (ange-ftp-ftp-name file))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3885 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3886 (insert |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3887 (if wildcard |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3888 (let ((default-directory (file-name-directory file))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3889 (ange-ftp-ls (file-name-nondirectory file) switches nil nil t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3890 (ange-ftp-ls file switches full))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3891 (ange-ftp-real-insert-directory file switches wildcard full)))) |
1106 | 3892 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3893 (defun ange-ftp-dired-uncache (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3894 (if (ange-ftp-ftp-name (expand-file-name dir))) |
1106 | 3895 (setq ange-ftp-ls-cache-file nil)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3896 |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3897 (defvar ange-ftp-sans-version-alist nil |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3898 "Alist of mapping host type into function to remove file version numbers.") |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3899 |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3900 (defun ange-ftp-file-name-sans-versions (file keep-backup-version) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3901 (setq file (ange-ftp-abbreviate-filename file)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3902 (let ((parsed (ange-ftp-ftp-name file)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3903 host-type func) |
1106 | 3904 (if parsed |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3905 (setq host-type (ange-ftp-host-type (car parsed)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3906 func (cdr (assq (ange-ftp-host-type (car parsed)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3907 ange-ftp-sans-version-alist)))) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3908 (if func (funcall func file keep-backup-version) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3909 (ange-ftp-real-file-name-sans-versions file keep-backup-version)))) |
1106 | 3910 |
3911 (defvar ange-ftp-remote-shell-file-name | |
3912 (if (memq system-type '(hpux usg-unix-v)) ; hope that's right | |
3913 "remsh" | |
3914 "rsh") | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3915 "Name of command to run a remote shell, for ange-ftp.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3916 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3917 ;;; This doesn't work yet; a new hook needs to be created. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3918 ;;; Maybe the new hook should be in call-process. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3919 (defun ange-ftp-shell-command (command) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3920 (let* ((parsed (ange-ftp-ftp-name default-directory)) |
1106 | 3921 (host (nth 0 parsed)) |
3922 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3923 (name (nth 2 parsed))) |
1106 | 3924 (if (not parsed) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3925 (ange-ftp-real-shell-command command) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3926 (if (> (length name) 0) ; else it's $HOME |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3927 (setq command (concat "cd " name "; " command))) |
1106 | 3928 (setq command |
3929 (format "%s %s \"%s\"" ; remsh -l USER does not work well | |
3930 ; on a hp-ux machine I tried | |
3931 ange-ftp-remote-shell-file-name host command)) | |
3932 (ange-ftp-message "Remote command '%s' ..." command) | |
3933 ;; Cannot call ange-ftp-real-dired-run-shell-command here as it | |
3934 ;; would prepend "cd default-directory" --- which bombs because | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3935 ;; default-directory is in ange-ftp syntax for remote file names. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3936 (ange-ftp-real-shell-command command)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3937 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3938 ;;; Thisis not hooked up yet. |
1106 | 3939 (defun ange-ftp-dired-call-process (program discard &rest arguments) |
3940 ;; PROGRAM is always one of those below in the cond in dired.el. | |
3941 ;; The ARGUMENTS are (nearly) always files. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3942 (if (ange-ftp-ftp-name default-directory) |
1106 | 3943 ;; Can't use ange-ftp-dired-host-type here because the current |
3944 ;; buffer is *dired-check-process output* | |
3945 (condition-case oops | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3946 (cond ((equal "chmod" program) |
1106 | 3947 (ange-ftp-call-chmod arguments)) |
3948 ;; ((equal "chgrp" program)) | |
3949 ;; ((equal dired-chown-program program)) | |
3950 (t (error "Unknown remote command: %s" program))) | |
3951 (ftp-error (insert (format "%s: %s, %s\n" | |
3952 (nth 1 oops) | |
3953 (nth 2 oops) | |
3954 (nth 3 oops)))) | |
3955 (error (insert (format "%s\n" (nth 1 oops))))) | |
3956 (apply 'call-process program nil (not discard) nil arguments))) | |
3957 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3958 ;;; This currently does not work; it is never called. |
1106 | 3959 (defun ange-ftp-call-chmod (args) |
3960 (if (< (length args) 2) | |
3961 (error "ange-ftp-call-chmod: missing mode and/or filename: %s" args)) | |
3962 (let ((mode (car args))) | |
3963 (mapcar | |
3964 (function | |
3965 (lambda (file) | |
3966 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3967 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 3968 (if parsed |
3969 (let* ((host (nth 0 parsed)) | |
3970 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3971 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 3972 (abbr (ange-ftp-abbreviate-filename file)) |
3973 (result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3974 (list 'chmod mode name) |
1106 | 3975 (format "doing chmod %s" |
3976 abbr)))) | |
3977 (or (car result) | |
3978 (ange-ftp-error host user | |
3979 (format "chmod: %s: \"%s\"" | |
3980 file | |
3981 (cdr result))))))))) | |
3982 (cdr args))) | |
3983 (setq ange-ftp-ls-cache-file nil)) ;stop confusing dired | |
3984 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3985 ;;; This is turned off because it has nothing properly to do |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3986 ;;; with dired. It could be reasonable to adapt this to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3987 ;;; replace ange-ftp-copy-file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3988 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3989 ;;;;; ------------------------------------------------------------ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3990 ;;;;; Noddy support for async copy-file within dired. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3991 ;;;;; ------------------------------------------------------------ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3992 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3993 ;;(defun ange-ftp-dired-copy-file (from to ok-flag &optional cont nowait) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3994 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3995 ;; (dired-handle-overwrite to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3996 ;; (ange-ftp-copy-file-internal from to ok-flag dired-copy-preserve-time nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3997 ;; cont nowait)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3998 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3999 ;;(defun ange-ftp-dired-do-create-files (op-symbol file-creator operation arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4000 ;; &optional marker-char op1 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4001 ;; how-to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4002 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4003 ;; ;; we need to let ange-ftp-dired-create-files know that we indirectly |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4004 ;; ;; called it rather than somebody else. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4005 ;; (let ((ange-ftp-dired-do-create-files t)) ; tell who caller is |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4006 ;; (ange-ftp-real-dired-do-create-files op-symbol file-creator operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4007 ;; arg marker-char op1 how-to))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4008 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4009 ;;(defun ange-ftp-dired-create-files (file-creator operation fn-list name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4010 ;; &optional marker-char) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4011 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4012 ;; (if (and (boundp 'ange-ftp-dired-do-create-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4013 ;; ;; called from ange-ftp-dired-do-create-files? |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4014 ;; ange-ftp-dired-do-create-files |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4015 ;; ;; any files worth copying? |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4016 ;; fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4017 ;; ;; we only support async copy-file at the mo. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4018 ;; (eq file-creator 'dired-copy-file) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4019 ;; ;; it is only worth calling the alternative function for remote files |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4020 ;; ;; as we tie ourself in recursive knots otherwise. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4021 ;; (or (ange-ftp-ftp-name (car fn-list)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4022 ;; ;; we can only call the name constructor for dired-do-create-files |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4023 ;; ;; since the one for regexps starts prompting here, there and |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4024 ;; ;; everywhere. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4025 ;; (ange-ftp-ftp-name (funcall name-constructor (car fn-list))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4026 ;; ;; use the process-filter driven routine rather than the iterative one. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4027 ;; (ange-ftp-dcf-1 file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4028 ;; operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4029 ;; fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4030 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4031 ;; (and (boundp 'target) target) ;dynamically bound |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4032 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4033 ;; (current-buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4034 ;; nil ;overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4035 ;; nil ;overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4036 ;; nil ;failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4037 ;; nil ;skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4038 ;; 0 ;success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4039 ;; (length fn-list) ;total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4040 ;; ) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4041 ;; ;; normal case... use the interative routine... much cheaper. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4042 ;; (ange-ftp-real-dired-create-files file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4043 ;; name-constructor marker-char))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4044 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4045 ;;(defun ange-ftp-dcf-1 (file-creator operation fn-list name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4046 ;; target marker-char buffer overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4047 ;; overwrite-backup-query failures skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4048 ;; success-count total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4049 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4050 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4051 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4052 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4053 ;; (if (null fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4054 ;; (ange-ftp-dcf-3 failures operation total skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4055 ;; success-count buffer) |
1106 | 4056 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4057 ;; (let* ((from (car fn-list)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4058 ;; (to (funcall name-constructor from))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4059 ;; (if (equal to from) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4060 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4061 ;; (setq to nil) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4062 ;; (dired-log "Cannot %s to same file: %s\n" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4063 ;; (downcase operation) from))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4064 ;; (if (not to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4065 ;; (ange-ftp-dcf-1 file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4066 ;; operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4067 ;; (cdr fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4068 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4069 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4070 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4071 ;; buffer |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4072 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4073 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4074 ;; failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4075 ;; (cons (dired-make-relative from) skipped) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4076 ;; success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4077 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4078 ;; (let* ((overwrite (file-exists-p to)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4079 ;; (overwrite-confirmed ; for dired-handle-overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4080 ;; (and overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4081 ;; (let ((help-form '(format "\ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4082 ;;Type SPC or `y' to overwrite file `%s', |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4083 ;;DEL or `n' to skip to next, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4084 ;;ESC or `q' to not overwrite any of the remaining files, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4085 ;;`!' to overwrite all remaining files with no more questions." to))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4086 ;; (dired-query 'overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4087 ;; "Overwrite `%s'?" to)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4088 ;; ;; must determine if FROM is marked before file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4089 ;; ;; gets a chance to delete it (in case of a move). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4090 ;; (actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4091 ;; (cond ((integerp marker-char) marker-char) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4092 ;; (marker-char (dired-file-marker from)) ; slow |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4093 ;; (t nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4094 ;; (condition-case err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4095 ;; (funcall file-creator from to overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4096 ;; (list (function ange-ftp-dcf-2) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4097 ;; nil ;err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4098 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4099 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4100 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4101 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4102 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4103 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4104 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4105 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4106 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4107 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4108 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4109 ;; t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4110 ;; (file-error ; FILE-CREATOR aborted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4111 ;; (ange-ftp-dcf-2 nil ;result |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4112 ;; nil ;line |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4113 ;; err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4114 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4115 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4116 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4117 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4118 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4119 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4120 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4121 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4122 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4123 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4124 ;; total)))))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4125 ;; (set-buffer old-buf)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4126 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4127 ;;(defun ange-ftp-dcf-2 (result line err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4128 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4129 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4130 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4131 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4132 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4133 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4134 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4135 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4136 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4137 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4138 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4139 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4140 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4141 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4142 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4143 ;; (if (or err (not result)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4144 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4145 ;; (setq failures (cons (dired-make-relative from) failures)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4146 ;; (dired-log "%s `%s' to `%s' failed:\n%s\n" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4147 ;; operation from to (or err line))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4148 ;; (if overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4149 ;; ;; If we get here, file-creator hasn't been aborted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4150 ;; ;; and the old entry (if any) has to be deleted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4151 ;; ;; before adding the new entry. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4152 ;; (dired-remove-file to)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4153 ;; (setq success-count (1+ success-count)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4154 ;; (message "%s: %d of %d" operation success-count total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4155 ;; (dired-add-file to actual-marker-char)) |
1106 | 4156 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4157 ;; (ange-ftp-dcf-1 file-creator operation (cdr fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4158 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4159 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4160 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4161 ;; buffer |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4162 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4163 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4164 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4165 ;; total)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4166 ;; (set-buffer old-buf)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4167 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4168 ;;(defun ange-ftp-dcf-3 (failures operation total skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4169 ;; buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4170 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4171 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4172 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4173 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4174 ;; (cond |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4175 ;; (failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4176 ;; (dired-log-summary |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4177 ;; (message "%s failed for %d of %d file%s %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4178 ;; operation (length failures) total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4179 ;; (dired-plural-s total) failures))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4180 ;; (skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4181 ;; (dired-log-summary |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4182 ;; (message "%s: %d of %d file%s skipped %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4183 ;; operation (length skipped) total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4184 ;; (dired-plural-s total) skipped))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4185 ;; (t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4186 ;; (message "%s: %s file%s." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4187 ;; operation success-count (dired-plural-s success-count)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4188 ;; (dired-move-to-filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4189 ;; (set-buffer old-buf)))) |
1106 | 4190 |
4191 ;;;; ----------------------------------------------- | |
4192 ;;;; Unix Descriptive Listing (dl) Support | |
4193 ;;;; ----------------------------------------------- | |
4194 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4195 ;; This is turned off because nothing uses it currently |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4196 ;; and because I don't understand what it's supposed to be for. --rms. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4197 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4198 ;;(defconst ange-ftp-dired-dl-re-dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4199 ;; "^. [^ /]+/[ \n]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4200 ;; "Regular expression to use to search for dl directories.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4201 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4202 ;;(or (assq 'unix:dl ange-ftp-dired-re-dir-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4203 ;; (setq ange-ftp-dired-re-dir-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4204 ;; (cons (cons 'unix:dl ange-ftp-dired-dl-re-dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4205 ;; ange-ftp-dired-re-dir-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4206 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4207 ;;(defun ange-ftp-dired-dl-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4208 ;; "In dired, move to the first character of the filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4209 ;; ;; This is the Unix dl version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4210 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4211 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4212 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4213 ;; (if (looking-at ". [^ ]+ +\\([0-9]+\\|-\\|=\\) ") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4214 ;; (goto-char (+ (point) 2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4215 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4216 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4217 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4218 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4219 ;;(or (assq 'unix:dl ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4220 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4221 ;; (cons '(unix:dl . ange-ftp-dired-dl-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4222 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4223 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4224 ;;(defun ange-ftp-dired-dl-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4225 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4226 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4227 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4228 ;; ;; This is the Unix dl version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4229 ;; (let ((opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4230 ;; case-fold-search hidden) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4231 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4232 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4233 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4234 ;; (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4235 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4236 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4237 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4238 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4239 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4240 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4241 ;; (skip-chars-forward "^ /" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4242 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4243 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4244 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4245 ;; (error "No file on this line")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4246 ;; (point))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4247 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4248 ;;(or (assq 'unix:dl ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4249 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4250 ;; (cons '(unix:dl . ange-ftp-dired-dl-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4251 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 4252 |
4253 ;;;; ------------------------------------------------------------ | |
4254 ;;;; VOS support (VOS support is probably broken, | |
4255 ;;;; but I don't know anything about VOS.) | |
4256 ;;;; ------------------------------------------------------------ | |
4257 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4258 ;(defun ange-ftp-fix-name-for-vos (name &optional reverse) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4259 ; (setq name (copy-sequence name)) |
1106 | 4260 ; (let ((from (if reverse ?\> ?\/)) |
4261 ; (to (if reverse ?\/ ?\>)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4262 ; (i (1- (length name)))) |
1106 | 4263 ; (while (>= i 0) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4264 ; (if (= (aref name i) from) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4265 ; (aset name i to)) |
1106 | 4266 ; (setq i (1- i))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4267 ; name)) |
1106 | 4268 ; |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4269 ;(or (assq 'vos ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4270 ; (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4271 ; (cons '(vos . ange-ftp-fix-name-for-vos) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4272 ; ange-ftp-fix-name-func-alist))) |
1106 | 4273 ; |
4274 ;(or (memq 'vos ange-ftp-dumb-host-types) | |
4275 ; (setq ange-ftp-dumb-host-types | |
4276 ; (cons 'vos ange-ftp-dumb-host-types))) | |
4277 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4278 ;(defun ange-ftp-fix-dir-name-for-vos (dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4279 ; (ange-ftp-fix-name-for-vos |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4280 ; (concat dir-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4281 ; (if (eq ?/ (aref dir-name (1- (length dir-name)))) |
1106 | 4282 ; "" "/") |
4283 ; "*"))) | |
4284 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4285 ;(or (assq 'vos ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4286 ; (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4287 ; (cons '(vos . ange-ftp-fix-dir-name-for-vos) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4288 ; ange-ftp-fix-dir-name-func-alist))) |
1106 | 4289 ; |
4290 ;(defvar ange-ftp-vos-host-regexp nil | |
4291 ; "If a host matches this regexp then it is assumed to be running VOS.") | |
4292 ; | |
4293 ;(defun ange-ftp-vos-host (host) | |
4294 ; (and ange-ftp-vos-host-regexp | |
4295 ; (ange-ftp-save-match-data | |
4296 ; (string-match ange-ftp-vos-host-regexp host)))) | |
4297 ; | |
4298 ;(defun ange-ftp-parse-vos-listing () | |
4299 ; "Parse the current buffer which is assumed to be in VOS list -all | |
4300 ;format, and return a hashtable as the result." | |
4301 ; (let ((tbl (ange-ftp-make-hashtable)) | |
4302 ; (type-list | |
4303 ; '(("^Files: [0-9]+ +Blocks: [0-9]+\n+" nil 40) | |
4304 ; ("^Dirs: [0-9]+\n+" t 30))) | |
4305 ; type-regexp type-is-dir type-col file) | |
4306 ; (goto-char (point-min)) | |
4307 ; (ange-ftp-save-match-data | |
4308 ; (while type-list | |
4309 ; (setq type-regexp (car (car type-list)) | |
4310 ; type-is-dir (nth 1 (car type-list)) | |
4311 ; type-col (nth 2 (car type-list)) | |
4312 ; type-list (cdr type-list)) | |
4313 ; (if (re-search-forward type-regexp nil t) | |
4314 ; (while (eq (char-after (point)) ? ) | |
4315 ; (move-to-column type-col) | |
4316 ; (setq file (buffer-substring (point) | |
4317 ; (progn | |
4318 ; (end-of-line 1) | |
4319 ; (point)))) | |
4320 ; (ange-ftp-put-hash-entry file type-is-dir tbl) | |
4321 ; (forward-line 1)))) | |
4322 ; (ange-ftp-put-hash-entry "." 'vosdir tbl) | |
4323 ; (ange-ftp-put-hash-entry ".." 'vosdir tbl)) | |
4324 ; tbl)) | |
4325 ; | |
4326 ;(or (assq 'vos ange-ftp-parse-list-func-alist) | |
4327 ; (setq ange-ftp-parse-list-func-alist | |
4328 ; (cons '(vos . ange-ftp-parse-vos-listing) | |
4329 ; ange-ftp-parse-list-func-alist))) | |
4330 | |
4331 ;;;; ------------------------------------------------------------ | |
4332 ;;;; VMS support. | |
4333 ;;;; ------------------------------------------------------------ | |
4334 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4335 ;; Convert NAME from UNIX-ish to VMS. If REVERSE given then convert from VMS |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4336 ;; to UNIX-ish. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4337 (defun ange-ftp-fix-name-for-vms (name &optional reverse) |
1106 | 4338 (ange-ftp-save-match-data |
4339 (if reverse | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4340 (if (string-match "^\\([^:]+:\\)?\\(\\[.*\\]\\)?\\([^][]*\\)$" name) |
1106 | 4341 (let (drive dir file) |
4342 (if (match-beginning 1) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4343 (setq drive (substring name |
1106 | 4344 (match-beginning 1) |
4345 (match-end 1)))) | |
4346 (if (match-beginning 2) | |
4347 (setq dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4348 (substring name (match-beginning 2) (match-end 2)))) |
1106 | 4349 (if (match-beginning 3) |
4350 (setq file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4351 (substring name (match-beginning 3) (match-end 3)))) |
1106 | 4352 (and dir |
4353 (setq dir (apply (function concat) | |
4354 (mapcar (function | |
4355 (lambda (char) | |
4356 (if (= char ?.) | |
4357 (vector ?/) | |
4358 (vector char)))) | |
4359 (substring dir 1 -1))))) | |
4360 (concat (and drive | |
4361 (concat "/" drive "/")) | |
4362 dir (and dir "/") | |
4363 file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4364 (error "name %s didn't match" name)) |
1106 | 4365 (let (drive dir file tmp) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4366 (if (string-match "^/[^:]+:/" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4367 (setq drive (substring name 1 |
1106 | 4368 (1- (match-end 0))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4369 name (substring name (match-end 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4370 (setq tmp (file-name-directory name)) |
1106 | 4371 (if tmp |
4372 (setq dir (apply (function concat) | |
4373 (mapcar (function | |
4374 (lambda (char) | |
4375 (if (= char ?/) | |
4376 (vector ?.) | |
4377 (vector char)))) | |
4378 (substring tmp 0 -1))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4379 (setq file (file-name-nondirectory name)) |
1106 | 4380 (concat drive |
4381 (and dir (concat "[" (if drive nil ".") dir "]")) | |
4382 file))))) | |
4383 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4384 ;; (ange-ftp-fix-name-for-vms "/PUB$:/ANONYMOUS/SDSCPUB/NEXT/Readme.txt;1") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4385 ;; (ange-ftp-fix-name-for-vms "/PUB$:[ANONYMOUS.SDSCPUB.NEXT]Readme.txt;1" t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4386 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4387 (or (assq 'vms ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4388 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4389 (cons '(vms . ange-ftp-fix-name-for-vms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4390 ange-ftp-fix-name-func-alist))) |
1106 | 4391 |
4392 (or (memq 'vms ange-ftp-dumb-host-types) | |
4393 (setq ange-ftp-dumb-host-types | |
4394 (cons 'vms ange-ftp-dumb-host-types))) | |
4395 | |
4396 ;; It is important that this function barf for directories for which we know | |
4397 ;; that we cannot possibly get a directory listing, such as "/" and "/DEV:/". | |
4398 ;; This is because it saves an unnecessary FTP error, or possibly the listing | |
4399 ;; might succeed, but give erroneous info. This last case is particularly | |
4400 ;; likely for OS's (like MTS) for which we need to use a wildcard in order | |
4401 ;; to list a directory. | |
4402 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4403 ;; Convert name from UNIX-ish to VMS ready for a DIRectory listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4404 (defun ange-ftp-fix-dir-name-for-vms (dir-name) |
1106 | 4405 ;; Should there be entries for .. -> [-] and . -> [] below. Don't |
4406 ;; think so, because expand-filename should have already short-circuited | |
4407 ;; them. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4408 (cond ((string-equal dir-name "/") |
1106 | 4409 (error "Cannot get listing for fictitious \"/\" directory.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4410 ((string-match "^/[-A-Z0-9_$]+:/$" dir-name) |
1106 | 4411 (error "Cannot get listing for device.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4412 ((ange-ftp-fix-name-for-vms dir-name)))) |
1106 | 4413 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4414 (or (assq 'vms ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4415 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4416 (cons '(vms . ange-ftp-fix-dir-name-for-vms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4417 ange-ftp-fix-dir-name-func-alist))) |
1106 | 4418 |
4419 (defvar ange-ftp-vms-host-regexp nil) | |
4420 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4421 ;; Return non-nil if HOST is running VMS. |
1106 | 4422 (defun ange-ftp-vms-host (host) |
4423 (and ange-ftp-vms-host-regexp | |
4424 (ange-ftp-save-match-data | |
4425 (string-match ange-ftp-vms-host-regexp host)))) | |
4426 | |
4427 ;; Because some VMS ftp servers convert filenames to lower case | |
4428 ;; we allow a-z in the filename regexp. I'm not too happy about this. | |
4429 | |
4430 (defconst ange-ftp-vms-filename-regexp | |
4431 (concat | |
4432 "\\(\\([_A-Za-z0-9$]?\\|[_A-Za-z0-9$][_A-Za-z0-9$---]*\\)\\." | |
4433 "[_A-Za-z0-9$---]*;+[0-9]*\\)") | |
4434 "Regular expression to match for a valid VMS file name in Dired buffer. | |
4435 Stupid freaking bug! Position of _ and $ shouldn't matter but they do. | |
4436 Having [A-Z0-9$_] bombs on filename _$$CHANGE_LOG$.TXT$ and $CHANGE_LOG$.TX | |
4437 Other orders of $ and _ seem to all work just fine.") | |
4438 | |
4439 ;; These parsing functions are as general as possible because the syntax | |
4440 ;; of ftp listings from VMS hosts is a bit erratic. What saves us is that | |
4441 ;; the VMS filename syntax is so rigid. If they bomb on a listing in the | |
4442 ;; standard VMS Multinet format, then this is a bug. If they bomb on a listing | |
4443 ;; from vms.weird.net, then too bad. | |
4444 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4445 ;; Extract the next filename from a VMS dired-like listing. |
1106 | 4446 (defun ange-ftp-parse-vms-filename () |
4447 (if (re-search-forward | |
4448 ange-ftp-vms-filename-regexp | |
4449 nil t) | |
4450 (buffer-substring (match-beginning 0) (match-end 0)))) | |
4451 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4452 ;; Parse the current buffer which is assumed to be in MultiNet FTP dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4453 ;; format, and return a hashtable as the result. |
1106 | 4454 (defun ange-ftp-parse-vms-listing () |
4455 (let ((tbl (ange-ftp-make-hashtable)) | |
4456 file) | |
4457 (goto-char (point-min)) | |
4458 (ange-ftp-save-match-data | |
4459 (while (setq file (ange-ftp-parse-vms-filename)) | |
4460 (if (string-match "\\.\\(DIR\\|dir\\);[0-9]+" file) | |
4461 ;; deal with directories | |
4462 (ange-ftp-put-hash-entry | |
4463 (substring file 0 (match-beginning 0)) t tbl) | |
4464 (ange-ftp-put-hash-entry file nil tbl) | |
4465 (if (string-match ";[0-9]+$" file) ; deal with extension | |
4466 ;; sans extension | |
4467 (ange-ftp-put-hash-entry | |
4468 (substring file 0 (match-beginning 0)) nil tbl))) | |
4469 (forward-line 1)) | |
4470 ;; Would like to look for a "Total" line, or a "Directory" line to | |
4471 ;; make sure that the listing isn't complete garbage before putting | |
4472 ;; in "." and "..", but we can't even count on all VAX's giving us | |
4473 ;; either of these. | |
4474 (ange-ftp-put-hash-entry "." t tbl) | |
4475 (ange-ftp-put-hash-entry ".." t tbl)) | |
4476 tbl)) | |
4477 | |
4478 (or (assq 'vms ange-ftp-parse-list-func-alist) | |
4479 (setq ange-ftp-parse-list-func-alist | |
4480 (cons '(vms . ange-ftp-parse-vms-listing) | |
4481 ange-ftp-parse-list-func-alist))) | |
4482 | |
4483 ;; This version only deletes file entries which have | |
4484 ;; explicit version numbers, because that is all VMS allows. | |
4485 | |
4486 ;; Can the following two functions be speeded up using file | |
4487 ;; completion functions? | |
4488 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4489 (defun ange-ftp-vms-delete-file-entry (name &optional dir-p) |
1106 | 4490 (if dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4491 (ange-ftp-internal-delete-file-entry name t) |
1106 | 4492 (ange-ftp-save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4493 (let ((file (ange-ftp-get-file-part name))) |
1106 | 4494 (if (string-match ";[0-9]+$" file) |
4495 ;; In VMS you can't delete a file without an explicit | |
4496 ;; version number, or wild-card (e.g. FOO;*) | |
4497 ;; For now, we give up on wildcards. | |
4498 (let ((files (ange-ftp-get-hash-entry | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4499 (file-name-directory name) |
1106 | 4500 ange-ftp-files-hashtable))) |
4501 (if files | |
4502 (let* ((root (substring file 0 | |
4503 (match-beginning 0))) | |
4504 (regexp (concat "^" | |
4505 (regexp-quote root) | |
4506 ";[0-9]+$")) | |
4507 versions) | |
4508 (ange-ftp-del-hash-entry file files) | |
4509 ;; Now we need to check if there are any | |
4510 ;; versions left. If not, then delete the | |
4511 ;; root entry. | |
4512 (mapatoms | |
4513 '(lambda (sym) | |
4514 (and (string-match regexp (get sym 'key)) | |
4515 (setq versions t))) | |
4516 files) | |
4517 (or versions | |
4518 (ange-ftp-del-hash-entry root files)))))))))) | |
4519 | |
4520 (or (assq 'vms ange-ftp-delete-file-entry-alist) | |
4521 (setq ange-ftp-delete-file-entry-alist | |
4522 (cons '(vms . ange-ftp-vms-delete-file-entry) | |
4523 ange-ftp-delete-file-entry-alist))) | |
4524 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4525 (defun ange-ftp-vms-add-file-entry (name &optional dir-p) |
1106 | 4526 (if dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4527 (ange-ftp-internal-add-file-entry name t) |
1106 | 4528 (let ((files (ange-ftp-get-hash-entry |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4529 (file-name-directory name) |
1106 | 4530 ange-ftp-files-hashtable))) |
4531 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4532 (let ((file (ange-ftp-get-file-part name))) |
1106 | 4533 (ange-ftp-save-match-data |
4534 (if (string-match ";[0-9]+$" file) | |
4535 (ange-ftp-put-hash-entry | |
4536 (substring file 0 (match-beginning 0)) | |
4537 nil files) | |
4538 ;; Need to figure out what version of the file | |
4539 ;; is being added. | |
4540 (let ((regexp (concat "^" | |
4541 (regexp-quote file) | |
4542 ";\\([0-9]+\\)$")) | |
4543 (version 0)) | |
4544 (mapatoms | |
4545 '(lambda (sym) | |
4546 (let ((name (get sym 'key))) | |
4547 (and (string-match regexp name) | |
4548 (setq version | |
4549 (max version | |
4550 (string-to-int | |
4551 (substring name | |
4552 (match-beginning 1) | |
4553 (match-end 1)))))))) | |
4554 files) | |
4555 (setq version (1+ version)) | |
4556 (ange-ftp-put-hash-entry | |
4557 (concat file ";" (int-to-string version)) | |
4558 nil files)))) | |
4559 (ange-ftp-put-hash-entry file nil files)))))) | |
4560 | |
4561 (or (assq 'vms ange-ftp-add-file-entry-alist) | |
4562 (setq ange-ftp-add-file-entry-alist | |
4563 (cons '(vms . ange-ftp-vms-add-file-entry) | |
4564 ange-ftp-add-file-entry-alist))) | |
4565 | |
4566 | |
4567 (defun ange-ftp-add-vms-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4568 "Mark HOST as the name of a machine running VMS." |
1106 | 4569 (interactive |
4570 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
4571 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4572 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 4573 (if (not (ange-ftp-vms-host host)) |
4574 (setq ange-ftp-vms-host-regexp | |
4575 (concat "^" (regexp-quote host) "$" | |
4576 (and ange-ftp-vms-host-regexp "\\|") | |
4577 ange-ftp-vms-host-regexp) | |
4578 ange-ftp-host-cache nil))) | |
4579 | |
4580 | |
4581 (defun ange-ftp-vms-file-name-as-directory (name) | |
4582 (ange-ftp-save-match-data | |
4583 (if (string-match "\\.\\(DIR\\|dir\\)\\(;[0-9]+\\)?$" name) | |
4584 (setq name (substring name 0 (match-beginning 0)))) | |
4585 (ange-ftp-real-file-name-as-directory name))) | |
4586 | |
4587 (or (assq 'vms ange-ftp-file-name-as-directory-alist) | |
4588 (setq ange-ftp-file-name-as-directory-alist | |
4589 (cons '(vms . ange-ftp-vms-file-name-as-directory) | |
4590 ange-ftp-file-name-as-directory-alist))) | |
4591 | |
4592 ;;; Tree dired support: | |
4593 | |
4594 ;; For this code I have borrowed liberally from Sebastian Kremer's | |
4595 ;; dired-vms.el | |
4596 | |
4597 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4598 ;;;; These regexps must be anchored to beginning of line. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4599 ;;;; Beware that the ftpd may put the device in front of the filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4600 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4601 ;;(defconst ange-ftp-dired-vms-re-exe "^. [^ \t.]+\\.\\(EXE\\|exe\\)[; ]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4602 ;; "Regular expression to use to search for VMS executable files.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4603 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4604 ;;(defconst ange-ftp-dired-vms-re-dir "^. [^ \t.]+\\.\\(DIR\\|dir\\)[; ]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4605 ;; "Regular expression to use to search for VMS directories.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4606 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4607 ;;(or (assq 'vms ange-ftp-dired-re-exe-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4608 ;; (setq ange-ftp-dired-re-exe-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4609 ;; (cons (cons 'vms ange-ftp-dired-vms-re-exe) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4610 ;; ange-ftp-dired-re-exe-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4611 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4612 ;;(or (assq 'vms ange-ftp-dired-re-dir-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4613 ;; (setq ange-ftp-dired-re-dir-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4614 ;; (cons (cons 'vms ange-ftp-dired-vms-re-dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4615 ;; ange-ftp-dired-re-dir-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4616 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4617 ;;(defun ange-ftp-dired-vms-insert-headerline (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4618 ;; ;; VMS inserts a headerline. I would prefer the headerline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4619 ;; ;; to be in ange-ftp format. This version tries to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4620 ;; ;; be careful, because we can't count on a headerline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4621 ;; ;; over ftp, and we wouldn't want to delete anything |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4622 ;; ;; important. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4623 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4624 ;; (if (looking-at "^ wildcard ") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4625 ;; (forward-line 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4626 ;; (if (looking-at "^[ \n\t]*[^\n]+\\][ \t]*\n") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4627 ;; (delete-region (point) (match-end 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4628 ;; (ange-ftp-real-dired-insert-headerline dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4629 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4630 ;;(or (assq 'vms ange-ftp-dired-insert-headerline-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4631 ;; (setq ange-ftp-dired-insert-headerline-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4632 ;; (cons '(vms . ange-ftp-dired-vms-insert-headerline) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4633 ;; ange-ftp-dired-insert-headerline-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4634 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4635 ;;(defun ange-ftp-dired-vms-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4636 ;; "In dired, move to first char of filename on this line. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4637 ;;Returns position (point) or nil if no filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4638 ;; ;; This is the VMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4639 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4640 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4641 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4642 ;; (if (re-search-forward ange-ftp-vms-filename-regexp eol t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4643 ;; (goto-char (match-beginning 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4644 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4645 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4646 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4647 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4648 ;;(or (assq 'vms ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4649 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4650 ;; (cons '(vms . ange-ftp-dired-vms-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4651 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4652 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4653 ;;(defun ange-ftp-dired-vms-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4654 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4655 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4656 ;; ;; case-fold-search must be nil, at least for VMS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4657 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4658 ;; ;; This is the VMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4659 ;; (let (opoint hidden case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4660 ;; (setq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4661 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4662 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4663 ;; (save-excursion (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4664 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4665 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4666 ;; (re-search-forward ange-ftp-vms-filename-regexp eol t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4667 ;; (or no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4668 ;; (not (eq opoint (point))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4669 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4670 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4671 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4672 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4673 ;; "No file on this line"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4674 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4675 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4676 ;; (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4677 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4678 ;;(or (assq 'vms ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4679 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4680 ;; (cons '(vms . ange-ftp-dired-vms-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4681 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4682 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4683 ;;(defun ange-ftp-dired-vms-between-files () |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4684 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4685 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4686 ;; (or (equal (following-char) 10) ; newline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4687 ;; (equal (following-char) 9) ; tab |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4688 ;; (progn (forward-char 2) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4689 ;; (or (looking-at "Total of") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4690 ;; (equal (following-char) 32)))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4691 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4692 ;;(or (assq 'vms ange-ftp-dired-between-files-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4693 ;; (setq ange-ftp-dired-between-files-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4694 ;; (cons '(vms . ange-ftp-dired-vms-between-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4695 ;; ange-ftp-dired-between-files-alist))) |
1106 | 4696 |
4697 ;; Beware! In VMS filenames must be of the form "FILE.TYPE". | |
4698 ;; Therefore, we cannot just append a ".Z" to filenames for | |
4699 ;; compressed files. Instead, we turn "FILE.TYPE" into | |
4700 ;; "FILE.TYPE-Z". Hope that this is a reasonable thing to do. | |
4701 | |
4702 (defun ange-ftp-vms-make-compressed-filename (name &optional reverse) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4703 (cond |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4704 ((string-match "-Z;[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4705 (list nil (substring name 0 (match-beginning 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4706 ((string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4707 (list nil (substring name 0 (match-beginning 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4708 ((string-match "-Z$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4709 (list nil (substring name 0 -2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4710 (t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4711 (list t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4712 (if (string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4713 (concat (substring name 0 (match-beginning 0)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4714 "-Z") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4715 (concat name "-Z")))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4716 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4717 (or (assq 'vms ange-ftp-make-compressed-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4718 (setq ange-ftp-make-compressed-filename-alist |
1106 | 4719 (cons '(vms . ange-ftp-vms-make-compressed-filename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4720 ange-ftp-make-compressed-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4721 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4722 ;;;; When the filename is too long, VMS will use two lines to list a file |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4723 ;;;; (damn them!) This will confuse dired. To solve this, need to convince |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4724 ;;;; Sebastian to use a function dired-go-to-end-of-file-line, instead of |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4725 ;;;; (forward-line 1). This would require a number of changes to dired.el. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4726 ;;;; If dired gets confused, revert-buffer will fix it. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4727 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4728 ;;(defun ange-ftp-dired-vms-ls-trim () |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4729 ;; (goto-char (point-min)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4730 ;; (let ((case-fold-search nil)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4731 ;; (re-search-forward ange-ftp-vms-filename-regexp)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4732 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4733 ;; (delete-region (point-min) (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4734 ;; (forward-line 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4735 ;; (delete-region (point) (point-max))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4736 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4737 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4738 ;;(or (assq 'vms ange-ftp-dired-ls-trim-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4739 ;; (setq ange-ftp-dired-ls-trim-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4740 ;; (cons '(vms . ange-ftp-dired-vms-ls-trim) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4741 ;; ange-ftp-dired-ls-trim-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4742 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4743 (defun ange-ftp-vms-sans-version (name) |
1106 | 4744 (ange-ftp-save-match-data |
4745 (if (string-match ";[0-9]+$" name) | |
4746 (substring name 0 (match-beginning 0)) | |
4747 name))) | |
4748 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4749 (or (assq 'vms ange-ftp-sans-version-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4750 (setq ange-ftp-sans-version-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4751 (cons '(vms . ange-ftp-vms-sans-version) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4752 ange-ftp-sans-version-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4753 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4754 ;;(defvar ange-ftp-file-version-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4755 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4756 ;;;;; The vms version of clean-directory has 2 more optional args |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4757 ;;;;; than the usual dired version. This is so that it can be used by |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4758 ;;;;; ange-ftp-dired-vms-flag-backup-files. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4759 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4760 ;;(defun ange-ftp-dired-vms-clean-directory (keep &optional marker msg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4761 ;; "Flag numerical backups for deletion. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4762 ;;Spares `dired-kept-versions' latest versions, and `kept-old-versions' oldest. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4763 ;;Positive prefix arg KEEP overrides `dired-kept-versions'; |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4764 ;;Negative prefix arg KEEP overrides `kept-old-versions' with KEEP made positive. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4765 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4766 ;;To clear the flags on these files, you can use \\[dired-flag-backup-files] |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4767 ;;with a prefix argument." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4768 ;;; (interactive "P") ; Never actually called interactively. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4769 ;; (setq keep (max 1 (if keep (prefix-numeric-value keep) dired-kept-versions))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4770 ;; (let ((early-retention (if (< keep 0) (- keep) kept-old-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4771 ;; ;; late-retention must NEVER be allowed to be less than 1 in VMS! |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4772 ;; ;; This could wipe ALL copies of the file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4773 ;; (late-retention (max 1 (if (<= keep 0) dired-kept-versions keep))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4774 ;; (action (or msg "Cleaning")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4775 ;; (ange-ftp-trample-marker (or marker dired-del-marker)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4776 ;; (ange-ftp-file-version-alist ())) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4777 ;; (message (concat action |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4778 ;; " numerical backups (keeping %d late, %d old)...") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4779 ;; late-retention early-retention) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4780 ;; ;; Look at each file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4781 ;; ;; If the file has numeric backup versions, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4782 ;; ;; put on ange-ftp-file-version-alist an element of the form |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4783 ;; ;; (FILENAME . VERSION-NUMBER-LIST) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4784 ;; (dired-map-dired-file-lines (function |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4785 ;; ange-ftp-dired-vms-collect-file-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4786 ;; ;; Sort each VERSION-NUMBER-LIST, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4787 ;; ;; and remove the versions not to be deleted. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4788 ;; (let ((fval ange-ftp-file-version-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4789 ;; (while fval |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4790 ;; (let* ((sorted-v-list (cons 'q (sort (cdr (car fval)) '<))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4791 ;; (v-count (length sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4792 ;; (if (> v-count (+ early-retention late-retention)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4793 ;; (rplacd (nthcdr early-retention sorted-v-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4794 ;; (nthcdr (- v-count late-retention) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4795 ;; sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4796 ;; (rplacd (car fval) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4797 ;; (cdr sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4798 ;; (setq fval (cdr fval)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4799 ;; ;; Look at each file. If it is a numeric backup file, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4800 ;; ;; find it in a VERSION-NUMBER-LIST and maybe flag it for deletion. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4801 ;; (dired-map-dired-file-lines |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4802 ;; (function |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4803 ;; ange-ftp-dired-vms-trample-file-versions mark)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4804 ;; (message (concat action " numerical backups...done")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4805 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4806 ;;(or (assq 'vms ange-ftp-dired-clean-directory-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4807 ;; (setq ange-ftp-dired-clean-directory-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4808 ;; (cons '(vms . ange-ftp-dired-vms-clean-directory) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4809 ;; ange-ftp-dired-clean-directory-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4810 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4811 ;;(defun ange-ftp-dired-vms-collect-file-versions (fn) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4812 ;; ;; "If it looks like file FN has versions, return a list of the versions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4813 ;; ;;That is a list of strings which are file names. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4814 ;; ;;The caller may want to flag some of these files for deletion." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4815 ;;(let ((name (nth 2 (ange-ftp-ftp-name fn)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4816 ;; (if (string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4817 ;; (let* ((name (substring name 0 (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4818 ;; (fn (ange-ftp-replace-name-component fn name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4819 ;; (if (not (assq fn ange-ftp-file-version-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4820 ;; (let* ((base-versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4821 ;; (concat (file-name-nondirectory name) ";")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4822 ;; (bv-length (length base-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4823 ;; (possibilities (file-name-all-completions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4824 ;; base-versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4825 ;; (file-name-directory fn))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4826 ;; (versions (mapcar |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4827 ;; '(lambda (arg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4828 ;; (if (and (string-match |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4829 ;; "[0-9]+$" arg bv-length) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4830 ;; (= (match-beginning 0) bv-length)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4831 ;; (string-to-int (substring arg bv-length)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4832 ;; 0)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4833 ;; possibilities))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4834 ;; (if versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4835 ;; (setq |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4836 ;; ange-ftp-file-version-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4837 ;; (cons (cons fn versions) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4838 ;; ange-ftp-file-version-alist))))))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4839 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4840 ;;(defun ange-ftp-dired-vms-trample-file-versions (fn) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4841 ;; (let* ((start-vn (string-match ";[0-9]+$" fn)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4842 ;; base-version-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4843 ;; (and start-vn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4844 ;; (setq base-version-list ; there was a base version to which |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4845 ;; (assoc (substring fn 0 start-vn) ; this looks like a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4846 ;; ange-ftp-file-version-alist)) ; subversion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4847 ;; (not (memq (string-to-int (substring fn (1+ start-vn))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4848 ;; base-version-list)) ; this one doesn't make the cut |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4849 ;; (progn (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4850 ;; (delete-char 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4851 ;; (insert ange-ftp-trample-marker))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4852 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4853 ;;(defun ange-ftp-dired-vms-flag-backup-files (&optional unflag-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4854 ;; (let ((dired-kept-versions 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4855 ;; (kept-old-versions 0) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4856 ;; marker msg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4857 ;; (if unflag-p |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4858 ;; (setq marker ?\040 msg "Unflagging") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4859 ;; (setq marker dired-del-marker msg "Cleaning")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4860 ;; (ange-ftp-dired-vms-clean-directory nil marker msg))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4861 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4862 ;;(or (assq 'vms ange-ftp-dired-flag-backup-files-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4863 ;; (setq ange-ftp-dired-flag-backup-files-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4864 ;; (cons '(vms . ange-ftp-dired-vms-flag-backup-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4865 ;; ange-ftp-dired-flag-backup-files-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4866 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4867 ;;(defun ange-ftp-dired-vms-backup-diff (&optional switches) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4868 ;; (let ((file (dired-get-filename 'no-dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4869 ;; bak) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4870 ;; (if (and (string-match ";[0-9]+$" file) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4871 ;; ;; Find most recent previous version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4872 ;; (let ((root (substring file 0 (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4873 ;; (ver |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4874 ;; (string-to-int (substring file (1+ (match-beginning 0))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4875 ;; found) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4876 ;; (setq ver (1- ver)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4877 ;; (while (and (> ver 0) (not found)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4878 ;; (setq bak (concat root ";" (int-to-string ver))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4879 ;; (and (file-exists-p bak) (setq found t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4880 ;; (setq ver (1- ver))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4881 ;; found)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4882 ;; (if switches |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4883 ;; (diff (expand-file-name bak) (expand-file-name file) switches) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4884 ;; (diff (expand-file-name bak) (expand-file-name file))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4885 ;; (error "No previous version found for %s" file)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4886 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4887 ;;(or (assq 'vms ange-ftp-dired-backup-diff-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4888 ;; (setq ange-ftp-dired-backup-diff-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4889 ;; (cons '(vms . ange-ftp-dired-vms-backup-diff) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4890 ;; ange-ftp-dired-backup-diff-alist))) |
1106 | 4891 |
4892 | |
4893 ;;;; ------------------------------------------------------------ | |
4894 ;;;; MTS support | |
4895 ;;;; ------------------------------------------------------------ | |
4896 | |
4897 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4898 ;; Convert NAME from UNIX-ish to MTS. If REVERSE given then convert from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4899 ;; MTS to UNIX-ish. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4900 (defun ange-ftp-fix-name-for-mts (name &optional reverse) |
1106 | 4901 (ange-ftp-save-match-data |
4902 (if reverse | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4903 (if (string-match "^\\([^:]+:\\)?\\(.*\\)$" name) |
1106 | 4904 (let (acct file) |
4905 (if (match-beginning 1) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4906 (setq acct (substring name 0 (match-end 1)))) |
1106 | 4907 (if (match-beginning 2) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4908 (setq file (substring name |
1106 | 4909 (match-beginning 2) (match-end 2)))) |
4910 (concat (and acct (concat "/" acct "/")) | |
4911 file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4912 (error "name %s didn't match" name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4913 (if (string-match "^/\\([^:]+:\\)/\\(.*\\)$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4914 (concat (substring name 1 (match-end 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4915 (substring name (match-beginning 2) (match-end 2))) |
1106 | 4916 ;; Let's hope that mts will recognize it anyway. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4917 name)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4918 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4919 (or (assq 'mts ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4920 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4921 (cons '(mts . ange-ftp-fix-name-for-mts) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4922 ange-ftp-fix-name-func-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4923 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4924 ;; Convert name from UNIX-ish to MTS ready for a DIRectory listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4925 ;; Remember that there are no directories in MTS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4926 (defun ange-ftp-fix-dir-name-for-mts (dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4927 (if (string-equal dir-name "/") |
1106 | 4928 (error "Cannot get listing for fictitious \"/\" directory.") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4929 (let ((dir-name (ange-ftp-fix-name-for-mts dir-name))) |
1106 | 4930 (cond |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4931 ((string-equal dir-name "") |
1106 | 4932 "?") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4933 ((string-match ":$" dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4934 (concat dir-name "?")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4935 (dir-name))))) ; It's just a single file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4936 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4937 (or (assq 'mts ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4938 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4939 (cons '(mts . ange-ftp-fix-dir-name-for-mts) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4940 ange-ftp-fix-dir-name-func-alist))) |
1106 | 4941 |
4942 (or (memq 'mts ange-ftp-dumb-host-types) | |
4943 (setq ange-ftp-dumb-host-types | |
4944 (cons 'mts ange-ftp-dumb-host-types))) | |
4945 | |
4946 (defvar ange-ftp-mts-host-regexp nil) | |
4947 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4948 ;; Return non-nil if HOST is running MTS. |
1106 | 4949 (defun ange-ftp-mts-host (host) |
4950 (and ange-ftp-mts-host-regexp | |
4951 (ange-ftp-save-match-data | |
4952 (string-match ange-ftp-mts-host-regexp host)))) | |
4953 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4954 ;; Parse the current buffer which is assumed to be in mts ftp dir format. |
1106 | 4955 (defun ange-ftp-parse-mts-listing () |
4956 (let ((tbl (ange-ftp-make-hashtable))) | |
4957 (goto-char (point-min)) | |
4958 (ange-ftp-save-match-data | |
4959 (while (re-search-forward ange-ftp-date-regexp nil t) | |
4960 (end-of-line) | |
4961 (skip-chars-backward " ") | |
4962 (let ((end (point))) | |
4963 (skip-chars-backward "-A-Z0-9_.!") | |
4964 (ange-ftp-put-hash-entry (buffer-substring (point) end) nil tbl)) | |
4965 (forward-line 1))) | |
4966 ;; Don't need to bother with .. | |
4967 (ange-ftp-put-hash-entry "." t tbl) | |
4968 tbl)) | |
4969 | |
4970 (or (assq 'mts ange-ftp-parse-list-func-alist) | |
4971 (setq ange-ftp-parse-list-func-alist | |
4972 (cons '(mts . ange-ftp-parse-mts-listing) | |
4973 ange-ftp-parse-list-func-alist))) | |
4974 | |
4975 (defun ange-ftp-add-mts-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4976 "Mark HOST as the name of a machine running MTS." |
1106 | 4977 (interactive |
4978 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
4979 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4980 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 4981 (if (not (ange-ftp-mts-host host)) |
4982 (setq ange-ftp-mts-host-regexp | |
4983 (concat "^" (regexp-quote host) "$" | |
4984 (and ange-ftp-mts-host-regexp "\\|") | |
4985 ange-ftp-mts-host-regexp) | |
4986 ange-ftp-host-cache nil))) | |
4987 | |
4988 ;;; Tree dired support: | |
4989 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4990 ;;;; There aren't too many systems left that use MTS. This dired support will |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4991 ;;;; work for the implementation of ftp on mtsg.ubc.ca. I hope other mts systems |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4992 ;;;; implement ftp in the same way. If not, it might be necessary to make the |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4993 ;;;; following more flexible. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4994 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4995 ;;(defun ange-ftp-dired-mts-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4996 ;; "In dired, move to first char of filename on this line. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4997 ;;Returns position (point) or nil if no filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4998 ;; ;; This is the MTS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4999 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5000 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5001 ;; (if (re-search-forward |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5002 ;; ange-ftp-date-regexp eol t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5003 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5004 ;; (skip-chars-forward " ") ; Eat blanks after date |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5005 ;; (skip-chars-forward "0-9:" eol) ; Eat time or year |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5006 ;; (skip-chars-forward " " eol) ; one space before filename |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5007 ;; ;; When listing an account other than the users own account it appends |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5008 ;; ;; ACCT: to the beginning of the filename. Skip over this. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5009 ;; (and (looking-at "[A-Z0-9_.]+:") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5010 ;; (goto-char (match-end 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5011 ;; (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5012 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5013 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5014 ;; nil))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5015 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5016 ;;(or (assq 'mts ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5017 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5018 ;; (cons '(mts . ange-ftp-dired-mts-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5019 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5020 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5021 ;;(defun ange-ftp-dired-mts-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5022 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5023 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5024 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5025 ;; ;; This is the MTS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5026 ;; (let (opoint hidden case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5027 ;; (setq opoint (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5028 ;; eol (save-excursion (end-of-line) (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5029 ;; hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5030 ;; (save-excursion (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5031 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5032 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5033 ;; (skip-chars-forward "-A-Z0-9._!" eol)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5034 ;; (or no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5035 ;; (not (eq opoint (point))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5036 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5037 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5038 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5039 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5040 ;; "No file on this line"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5041 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5042 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5043 ;; (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5044 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5045 ;;(or (assq 'mts ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5046 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5047 ;; (cons '(mts . ange-ftp-dired-mts-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5048 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 5049 |
5050 ;;;; ------------------------------------------------------------ | |
5051 ;;;; CMS support | |
5052 ;;;; ------------------------------------------------------------ | |
5053 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5054 ;; Since CMS doesn't have any full file name syntax, we have to fudge |
1106 | 5055 ;; things with cd's. We actually send too many cd's, but is dangerous |
5056 ;; to try to remember the current minidisk, because if the connection | |
5057 ;; is closed and needs to be reopened, we will find ourselves back in | |
5058 ;; the default minidisk. This is fairly likely since CMS ftp servers | |
5059 ;; usually close the connection after 5 minutes of inactivity. | |
5060 | |
5061 ;; Have I got the filename character set right? | |
5062 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5063 (defun ange-ftp-fix-name-for-cms (name &optional reverse) |
1106 | 5064 (ange-ftp-save-match-data |
5065 (if reverse | |
5066 ;; Since we only convert output from a pwd in this direction, | |
5067 ;; we'll assume that it's a minidisk, and make it into a | |
5068 ;; directory file name. Note that the expand-dir-hashtable | |
5069 ;; stores directories without the trailing /. Is this | |
5070 ;; consistent? | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5071 (concat "/" name) |
1106 | 5072 (if (string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5073 name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5074 (let ((minidisk (substring name 1 (match-end 1)))) |
1106 | 5075 (if (match-beginning 2) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5076 (let ((file (substring name (match-beginning 2) |
1106 | 5077 (match-end 2))) |
5078 (cmd (concat "cd " minidisk)) | |
5079 | |
5080 ;; Note that host and user are bound in the call | |
5081 ;; to ange-ftp-send-cmd | |
5082 (proc (ange-ftp-get-process ange-ftp-this-host | |
5083 ange-ftp-this-user))) | |
5084 | |
5085 ;; Must use ange-ftp-raw-send-cmd here to avoid | |
5086 ;; an infinite loop. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5087 (if (car (ange-ftp-raw-send-cmd proc cmd ange-ftp-this-msg)) |
1106 | 5088 file |
5089 ;; failed... try ONCE more. | |
5090 (setq proc (ange-ftp-get-process ange-ftp-this-host | |
5091 ange-ftp-this-user)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5092 (let ((result (ange-ftp-raw-send-cmd proc cmd |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5093 ange-ftp-this-msg))) |
1106 | 5094 (if (car result) |
5095 file | |
5096 ;; failed. give up. | |
5097 (ange-ftp-error ange-ftp-this-host ange-ftp-this-user | |
5098 (format "cd to minidisk %s failed: %s" | |
5099 minidisk (cdr result))))))) | |
5100 ;; return the minidisk | |
5101 minidisk)) | |
5102 (error "Invalid CMS filename"))))) | |
5103 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5104 (or (assq 'cms ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5105 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5106 (cons '(cms . ange-ftp-fix-name-for-cms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5107 ange-ftp-fix-name-func-alist))) |
1106 | 5108 |
5109 (or (memq 'cms ange-ftp-dumb-host-types) | |
5110 (setq ange-ftp-dumb-host-types | |
5111 (cons 'cms ange-ftp-dumb-host-types))) | |
5112 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5113 ;; Convert name from UNIX-ish to CMS ready for a DIRectory listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5114 (defun ange-ftp-fix-dir-name-for-cms (dir-name) |
1106 | 5115 (cond |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5116 ((string-equal "/" dir-name) |
1106 | 5117 (error "Cannot get listing for fictitious \"/\" directory.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5118 ((string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5119 (let* ((minidisk (substring dir-name (match-beginning 1) (match-end 1))) |
1106 | 5120 ;; host and user are bound in the call to ange-ftp-send-cmd |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5121 (proc (ange-ftp-get-process ange-ftp-this-host ange-ftp-this-user)) |
1106 | 5122 (cmd (concat "cd " minidisk)) |
5123 (file (if (match-beginning 2) | |
5124 ;; it's a single file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5125 (substring dir-name (match-beginning 2) |
1106 | 5126 (match-end 2)) |
5127 ;; use the wild-card | |
5128 "*"))) | |
5129 (if (car (ange-ftp-raw-send-cmd proc cmd)) | |
5130 file | |
5131 ;; try again... | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5132 (setq proc (ange-ftp-get-process ange-ftp-this-host |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5133 ange-ftp-this-user)) |
1106 | 5134 (let ((result (ange-ftp-raw-send-cmd proc cmd))) |
5135 (if (car result) | |
5136 file | |
5137 ;; give up | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5138 (ange-ftp-error ange-ftp-this-host ange-ftp-this-user |
1106 | 5139 (format "cd to minidisk %s failed: " |
5140 minidisk (cdr result)))))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5141 (t (error "Invalid CMS file name")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5142 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5143 (or (assq 'cms ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5144 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5145 (cons '(cms . ange-ftp-fix-dir-name-for-cms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5146 ange-ftp-fix-dir-name-func-alist))) |
1106 | 5147 |
5148 (defvar ange-ftp-cms-host-regexp nil | |
5149 "Regular expression to match hosts running the CMS operating system.") | |
5150 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5151 ;; Return non-nil if HOST is running CMS. |
1106 | 5152 (defun ange-ftp-cms-host (host) |
5153 (and ange-ftp-cms-host-regexp | |
5154 (ange-ftp-save-match-data | |
5155 (string-match ange-ftp-cms-host-regexp host)))) | |
5156 | |
5157 (defun ange-ftp-add-cms-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5158 "Mark HOST as the name of a CMS host." |
1106 | 5159 (interactive |
5160 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
5161 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5162 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 5163 (if (not (ange-ftp-cms-host host)) |
5164 (setq ange-ftp-cms-host-regexp | |
5165 (concat "^" (regexp-quote host) "$" | |
5166 (and ange-ftp-cms-host-regexp "\\|") | |
5167 ange-ftp-cms-host-regexp) | |
5168 ange-ftp-host-cache nil))) | |
5169 | |
5170 (defun ange-ftp-parse-cms-listing () | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5171 ;; Parse the current buffer which is assumed to be a CMS directory listing. |
1106 | 5172 ;; If we succeed in getting a listing, then we will assume that the minidisk |
5173 ;; exists. file is bound by the call to ange-ftp-ls. This doesn't work | |
5174 ;; because ange-ftp doesn't know that the root hashtable has only part of | |
5175 ;; the info. It will assume that if a minidisk isn't in it, then it doesn't | |
5176 ;; exist. It would be nice if completion worked for minidisks, as we | |
5177 ;; discover them. | |
5178 ; (let* ((dir-file (directory-file-name file)) | |
5179 ; (root (file-name-directory dir-file)) | |
5180 ; (minidisk (ange-ftp-get-file-part dir-file)) | |
5181 ; (root-tbl (ange-ftp-get-hash-entry root ange-ftp-files-hashtable))) | |
5182 ; (if root-tbl | |
5183 ; (ange-ftp-put-hash-entry minidisk t root-tbl) | |
5184 ; (setq root-tbl (ange-ftp-make-hashtable)) | |
5185 ; (ange-ftp-put-hash-entry minidisk t root-tbl) | |
5186 ; (ange-ftp-put-hash-entry "." t root-tbl) | |
5187 ; (ange-ftp-set-files root root-tbl))) | |
5188 ;; Now do the usual parsing | |
5189 (let ((tbl (ange-ftp-make-hashtable))) | |
5190 (goto-char (point-min)) | |
5191 (ange-ftp-save-match-data | |
5192 (while | |
5193 (re-search-forward | |
5194 "^\\([-A-Z0-9$_]+\\) +\\([-A-Z0-9$_]+\\) +[VF] +[0-9]+ " nil t) | |
5195 (ange-ftp-put-hash-entry | |
5196 (concat (buffer-substring (match-beginning 1) | |
5197 (match-end 1)) | |
5198 "." | |
5199 (buffer-substring (match-beginning 2) | |
5200 (match-end 2))) | |
5201 nil tbl) | |
5202 (forward-line 1)) | |
5203 (ange-ftp-put-hash-entry "." t tbl)) | |
5204 tbl)) | |
5205 | |
5206 (or (assq 'cms ange-ftp-parse-list-func-alist) | |
5207 (setq ange-ftp-parse-list-func-alist | |
5208 (cons '(cms . ange-ftp-parse-cms-listing) | |
5209 ange-ftp-parse-list-func-alist))) | |
5210 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5211 ;;;;; Tree dired support: |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5212 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5213 ;;(defconst ange-ftp-dired-cms-re-exe |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5214 ;; "^. [-A-Z0-9$_]+ +EXEC " |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5215 ;; "Regular expression to use to search for CMS executables.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5216 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5217 ;;(or (assq 'cms ange-ftp-dired-re-exe-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5218 ;; (setq ange-ftp-dired-re-exe-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5219 ;; (cons (cons 'cms ange-ftp-dired-cms-re-exe) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5220 ;; ange-ftp-dired-re-exe-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5221 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5222 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5223 ;;(defun ange-ftp-dired-cms-insert-headerline (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5224 ;; ;; CMS has no total line, so we insert a blank line for |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5225 ;; ;; aesthetics. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5226 ;; (insert "\n") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5227 ;; (forward-char -1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5228 ;; (ange-ftp-real-dired-insert-headerline dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5229 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5230 ;;(or (assq 'cms ange-ftp-dired-insert-headerline-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5231 ;; (setq ange-ftp-dired-insert-headerline-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5232 ;; (cons '(cms . ange-ftp-dired-cms-insert-headerline) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5233 ;; ange-ftp-dired-insert-headerline-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5234 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5235 ;;(defun ange-ftp-dired-cms-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5236 ;; "In dired, move to the first char of filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5237 ;; ;; This is the CMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5238 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5239 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5240 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5241 ;; (if (re-search-forward " [-A-Z0-9$_]+ +[-A-Z0-9$_]+ +[VF] +[0-9]+ " eol t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5242 ;; (goto-char (1+ (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5243 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5244 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5245 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5246 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5247 ;;(or (assq 'cms ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5248 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5249 ;; (cons '(cms . ange-ftp-dired-cms-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5250 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5251 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5252 ;;(defun ange-ftp-dired-cms-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5253 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5254 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5255 ;; ;; case-fold-search must be nil, at least for VMS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5256 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5257 ;; ;; This is the CMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5258 ;; (let ((opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5259 ;; case-fold-search hidden) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5260 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5261 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5262 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5263 ;; (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5264 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5265 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5266 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5267 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5268 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5269 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5270 ;; (skip-chars-forward "-A-Z0-9$_" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5271 ;; (skip-chars-forward " " eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5272 ;; (skip-chars-forward "-A-Z0-9$_" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5273 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5274 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5275 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5276 ;; (error "No file on this line")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5277 ;; (point))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5278 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5279 ;;(or (assq 'cms ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5280 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5281 ;; (cons '(cms . ange-ftp-dired-cms-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5282 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 5283 |
5284 (defun ange-ftp-cms-make-compressed-filename (name &optional reverse) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5285 (if (string-match "-Z$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5286 (list nil (substring name 0 -2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5287 (list t (concat name "-Z")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5288 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5289 (or (assq 'cms ange-ftp-make-compressed-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5290 (setq ange-ftp-make-compressed-filename-alist |
1106 | 5291 (cons '(cms . ange-ftp-cms-make-compressed-filename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5292 ange-ftp-make-compressed-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5293 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5294 ;;(defun ange-ftp-dired-cms-get-filename (&optional localp no-error-if-not-filep) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5295 ;; (let ((name (ange-ftp-real-dired-get-filename localp no-error-if-not-filep))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5296 ;; (and name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5297 ;; (if (string-match "^\\([^ ]+\\) +\\([^ ]+\\)$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5298 ;; (concat (substring name 0 (match-end 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5299 ;; "." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5300 ;; (substring name (match-beginning 2) (match-end 2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5301 ;; name)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5302 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5303 ;;(or (assq 'cms ange-ftp-dired-get-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5304 ;; (setq ange-ftp-dired-get-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5305 ;; (cons '(cms . ange-ftp-dired-cms-get-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5306 ;; ange-ftp-dired-get-filename-alist))) |
1106 | 5307 |
5308 ;;;; ------------------------------------------------------------ | |
5309 ;;;; Finally provide package. | |
5310 ;;;; ------------------------------------------------------------ | |
5311 | |
5312 (provide 'ange-ftp) |