Mercurial > emacs
annotate lisp/ange-ftp.el @ 14415:db084c0ae4bd
(ada-indent-region, ada-check-matching-start, ada-check-defun-name): Fix error
format string.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Mon, 29 Jan 1996 23:09:15 +0000 |
parents | 83f275dcd93a |
children | 97e0e30a6eaa |
rev | line source |
---|---|
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
1 ;;; ange-ftp.el --- transparent FTP support for GNU Emacs |
1106 | 2 |
14169 | 3 ;; Copyright (C) 1989,90,91,92,93,94,95 Free Software Foundation, Inc. |
4 | |
2258 | 5 ;; Author: Andy Norman (ange@hplb.hpl.hp.com) |
6 ;; Keywords: comm | |
14169 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
1106 | 24 |
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
25 ;;; Commentary: |
14169 | 26 |
27 ;; This package attempts to make accessing files and directories using FTP | |
28 ;; from within GNU Emacs as simple and transparent as possible. A subset of | |
29 ;; the common file-handling routines are extended to interact with FTP. | |
30 | |
31 ;; Usage: | |
32 ;; | |
33 ;; Some of the common GNU Emacs file-handling operations have been made | |
34 ;; FTP-smart. If one of these routines is given a filename that matches | |
35 ;; '/user@host:name' then it will spawn an FTP process connecting to machine | |
36 ;; 'host' as account 'user' and perform its operation on the file 'name'. | |
37 ;; | |
38 ;; For example: if find-file is given a filename of: | |
39 ;; | |
40 ;; /ange@anorman:/tmp/notes | |
41 ;; | |
42 ;; then ange-ftp spawns an FTP process, connect to the host 'anorman' as | |
43 ;; user 'ange', get the file '/tmp/notes' and pop up a buffer containing the | |
44 ;; contents of that file as if it were on the local filesystem. If ange-ftp | |
45 ;; needs a password to connect then it reads one in the echo area. | |
46 | |
47 ;; Extended filename syntax: | |
48 ;; | |
49 ;; The default extended filename syntax is '/user@host:name', where the | |
50 ;; 'user@' part may be omitted. This syntax can be customised to a certain | |
51 ;; extent by changing ange-ftp-name-format. There are limitations. | |
52 ;; | |
53 ;; If the user part is omitted then ange-ftp generates a default user | |
54 ;; instead whose value depends on the variable ange-ftp-default-user. | |
55 | |
56 ;; Passwords: | |
57 ;; | |
58 ;; A password is required for each host/user pair. Ange-ftp reads passwords | |
59 ;; as needed. You can also specify a password with ange-ftp-set-passwd, or | |
60 ;; in a *valid* ~/.netrc file. | |
61 | |
62 ;; Passwords for user "anonymous": | |
63 ;; | |
64 ;; Passwords for the user "anonymous" (or "ftp") are handled | |
65 ;; specially. The variable `ange-ftp-generate-anonymous-password' | |
66 ;; controls what happens: if the value of this variable is a string, | |
67 ;; then this is used as the password; if non-nil (the default), then | |
68 ;; the value of `user-mail-address' is used; if nil then the user | |
69 ;; is prompted for a password as normal. | |
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 ;; | |
97 ;; Killing the "*ftp user@host*" buffer also kills the ftp process. | |
98 ;; This should not cause ange-ftp any grief. | |
99 | |
100 ;; Binary file transfers: | |
101 ;; | |
102 ;; By default ange-ftp transfers files in ASCII mode. If a file being | |
103 ;; transferred matches the value of ange-ftp-binary-file-name-regexp then | |
104 ;; binary mode is used for that transfer. | |
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 necessary 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 necessary 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 ;; Otherwise, if there is an alternate ftp program that implements proxy in | |
220 ;; a transparent way (i.e. w/o specifying the proxy host), that will | |
221 ;; connect you directly to the desired destination host: | |
222 ;; Set ange-ftp-gateway-ftp-program-name to that program's name. | |
223 ;; Set ange-ftp-local-host-regexp to a value as stated earlier on. | |
224 ;; Leave ange-ftp-gateway-host set to nil. | |
225 ;; Set ange-ftp-smart-gateway to t. | |
226 | |
227 ;; Tips for using ange-ftp: | |
228 ;; | |
229 ;; 1. For dired to work on a host which marks symlinks with a trailing @ in | |
230 ;; an ls -alF listing, you need to (setq dired-ls-F-marks-symlinks t). | |
231 ;; Most UNIX systems do not do this, but ULTRIX does. If you think that | |
232 ;; there is a chance you might connect to an ULTRIX machine (such as | |
233 ;; prep.ai.mit.edu), then set this variable accordingly. This will have | |
234 ;; the side effect that dired will have problems with symlinks whose names | |
235 ;; end in an @. If you get yourself into this situation then editing | |
236 ;; dired's ls-switches to remove "F", will temporarily fix things. | |
237 ;; | |
238 ;; 2. If you know that you are connecting to a certain non-UNIX machine | |
239 ;; frequently, and ange-ftp seems to be unable to guess its host-type, | |
240 ;; then setting the appropriate host-type regexp | |
241 ;; (ange-ftp-vms-host-regexp, ange-ftp-mts-host-regexp, or | |
242 ;; ange-ftp-cms-host-regexp) accordingly should help. Also, please report | |
243 ;; ange-ftp's inability to recognize the host-type as a bug. | |
244 ;; | |
245 ;; 3. For slow connections, you might get "listing unreadable" error | |
246 ;; messages, or get an empty buffer for a file that you know has something | |
247 ;; in it. The solution is to increase the value of ange-ftp-retry-time. | |
248 ;; Its default value is 5 which is plenty for reasonable connections. | |
249 ;; However, for some transatlantic connections I set this to 20. | |
250 ;; | |
251 ;; 4. Beware of compressing files on non-UNIX hosts. Ange-ftp will do it by | |
252 ;; copying the file to the local machine, compressing it there, and then | |
253 ;; sending it back. Binary file transfers between machines of different | |
254 ;; architectures can be a risky business. Test things out first on some | |
255 ;; test files. See "Bugs" below. Also, note that ange-ftp copies files by | |
256 ;; moving them through the local machine. Again, be careful when doing | |
257 ;; this with binary files on non-Unix machines. | |
258 ;; | |
259 ;; 5. Beware that dired over ftp will use your setting of dired-no-confirm | |
260 ;; (list of dired commands for which confirmation is not asked). You | |
261 ;; might want to reconsider your setting of this variable, because you | |
262 ;; might want confirmation for more commands on remote direds than on | |
263 ;; local direds. For example, I strongly recommend that you not include | |
264 ;; compress and uncompress in this list. If there is enough demand it | |
265 ;; might be a good idea to have an alist ange-ftp-dired-no-confirm of | |
266 ;; pairs ( TYPE . LIST ), where TYPE is an operating system type and LIST | |
267 ;; is a list of commands for which confirmation would be suppressed. Then | |
268 ;; remote dired listings would take their (buffer-local) value of | |
269 ;; dired-no-confirm from this alist. Who votes for this? | |
270 | |
271 ;; --------------------------------------------------------------------- | |
272 ;; Non-UNIX support: | |
273 ;; --------------------------------------------------------------------- | |
274 | |
275 ;; VMS support: | |
276 ;; | |
277 ;; Ange-ftp has full support for VMS hosts. It | |
278 ;; should be able to automatically recognize any VMS machine. However, if it | |
279 ;; fails to do this, you can use the command ange-ftp-add-vms-host. As well, | |
280 ;; you can set the variable ange-ftp-vms-host-regexp in your .emacs file. We | |
281 ;; would be grateful if you would report any failures to automatically | |
282 ;; recognize a VMS host as a bug. | |
283 ;; | |
284 ;; Filename Syntax: | |
285 ;; | |
286 ;; For ease of *implementation*, the user enters the VMS filename syntax in a | |
287 ;; UNIX-y way. For example: | |
288 ;; PUB$:[ANONYMOUS.SDSCPUB.NEXT]README.TXT;1 | |
289 ;; would be entered as: | |
290 ;; /PUB$$:/ANONYMOUS/SDSCPUB/NEXT/README.TXT;1 | |
291 ;; i.e. to log in as anonymous on ymir.claremont.edu and grab the file: | |
292 ;; [.CSV.POLICY]RULES.MEM | |
293 ;; you would type: | |
294 ;; C-x C-f /anonymous@ymir.claremont.edu:CSV/POLICY/RULES.MEM | |
295 ;; | |
296 ;; A legal VMS filename is of the form: FILE.TYPE;## | |
297 ;; where FILE can be up to 39 characters | |
298 ;; TYPE can be up to 39 characters | |
299 ;; ## is a version number (an integer between 1 and 32,767) | |
300 ;; Valid characters in FILE and TYPE are A-Z 0-9 _ - $ | |
301 ;; $ cannot begin a filename, and - cannot be used as the first or last | |
302 ;; character. | |
303 ;; | |
304 ;; Tips: | |
305 ;; 1. Although VMS is not case sensitive, EMACS running under UNIX is. | |
306 ;; Therefore, to access a VMS file, you must enter the filename with upper | |
307 ;; case letters. | |
308 ;; 2. To access the latest version of file under VMS, you use the filename | |
309 ;; without the ";" and version number. You should always edit the latest | |
310 ;; version of a file. If you want to edit an earlier version, copy it to a | |
311 ;; new file first. This has nothing to do with ange-ftp, but is simply | |
312 ;; good VMS operating practice. Therefore, to edit FILE.TXT;3 (say 3 is | |
313 ;; latest version), do C-x C-f /ymir.claremont.edu:FILE.TXT. If you | |
314 ;; inadvertently do C-x C-f /ymir.claremont.edu:FILE.TXT;3, you will find | |
315 ;; that VMS will not allow you to save the file because it will refuse to | |
316 ;; overwrite FILE.TXT;3, but instead will want to create FILE.TXT;4, and | |
317 ;; attach the buffer to this file. To get out of this situation, M-x | |
318 ;; write-file /ymir.claremont.edu:FILE.TXT will attach the buffer to | |
319 ;; latest version of the file. For this reason, in dired "f" | |
320 ;; (dired-find-file), always loads the file sans version, whereas "v", | |
321 ;; (dired-view-file), always loads the explicit version number. The | |
322 ;; reasoning being that it reasonable to view old versions of a file, but | |
323 ;; not to edit them. | |
324 ;; 3. EMACS has a feature in which it does environment variable substitution | |
325 ;; in filenames. Therefore, to enter a $ in a filename, you must quote it | |
326 ;; by typing $$. | |
327 | |
328 ;; MTS support: | |
329 ;; | |
330 ;; Ange-ftp has full support for hosts running | |
331 ;; the Michigan terminal system. It should be able to automatically | |
332 ;; recognize any MTS machine. However, if it fails to do this, you can use | |
333 ;; the command ange-ftp-add-mts-host. As well, you can set the variable | |
334 ;; ange-ftp-mts-host-regexp in your .emacs file. We would be grateful if you | |
335 ;; would report any failures to automatically recognize a MTS host as a bug. | |
336 ;; | |
337 ;; Filename syntax: | |
338 ;; | |
339 ;; MTS filenames are entered in a UNIX-y way. For example, if your account | |
340 ;; was YYYY, the file FILE in the account XXXX: on mtsg.ubc.ca would be | |
341 ;; entered as | |
342 ;; /YYYY@mtsg.ubc.ca:/XXXX:/FILE | |
343 ;; In other words, MTS accounts are treated as UNIX directories. Of course, | |
344 ;; to access a file in another account, you must have access permission for | |
345 ;; it. If FILE were in your own account, then you could enter it in a | |
346 ;; relative name fashion as | |
347 ;; /YYYY@mtsg.ubc.ca:FILE | |
348 ;; MTS filenames can be up to 12 characters. Like UNIX, the structure of the | |
349 ;; filename does not contain a TYPE (i.e. it can have as many "."'s as you | |
350 ;; like.) MTS filenames are always in upper case, and hence be sure to enter | |
351 ;; them as such! MTS is not case sensitive, but an EMACS running under UNIX | |
352 ;; is. | |
353 | |
354 ;; CMS support: | |
355 ;; | |
356 ;; Ange-ftp has full support for hosts running | |
357 ;; CMS. It should be able to automatically recognize any CMS machine. | |
358 ;; However, if it fails to do this, you can use the command | |
359 ;; ange-ftp-add-cms-host. As well, you can set the variable | |
360 ;; ange-ftp-cms-host-regexp in your .emacs file. We would be grateful if you | |
361 ;; would report any failures to automatically recognize a CMS host as a bug. | |
362 ;; | |
363 ;; Filename syntax: | |
364 ;; | |
365 ;; CMS filenames are entered in a UNIX-y way. In otherwords, minidisks are | |
366 ;; treated as UNIX directories. For example to access the file READ.ME in | |
367 ;; minidisk *.311 on cuvmb.cc.columbia.edu, you would enter | |
368 ;; /anonymous@cuvmb.cc.columbia.edu:/*.311/READ.ME | |
369 ;; If *.301 is the default minidisk for this account, you could access | |
370 ;; FOO.BAR on this minidisk as | |
371 ;; /anonymous@cuvmb.cc.columbia.edu:FOO.BAR | |
372 ;; CMS filenames are of the form FILE.TYPE, where both FILE and TYPE can be | |
373 ;; up to 8 characters. Again, beware that CMS filenames are always upper | |
374 ;; case, and hence must be entered as such. | |
375 ;; | |
376 ;; Tips: | |
377 ;; 1. CMS machines, with the exception of anonymous accounts, nearly always | |
378 ;; need an account password. To have ange-ftp send an account password, | |
379 ;; you can either include it in your .netrc file, or use | |
380 ;; ange-ftp-set-account. | |
381 ;; 2. Ange-ftp cannot send "write passwords" for a minidisk. Hopefully, we | |
382 ;; can fix this. | |
383 ;; | |
384 ;; ------------------------------------------------------------------ | |
385 ;; Bugs: | |
386 ;; ------------------------------------------------------------------ | |
387 ;; | |
388 ;; 1. Umask problems: | |
389 ;; Be warned that files created by using ange-ftp will take account of the | |
390 ;; umask of the ftp daemon process rather than the umask of the creating | |
391 ;; user. This is particularly important when logging in as the root user. | |
392 ;; The way that I tighten up the ftp daemon's umask under HP-UX is to make | |
393 ;; sure that the umask is changed to 027 before I spawn /etc/inetd. I | |
394 ;; suspect that there is something similar on other systems. | |
395 ;; | |
396 ;; 2. Some combinations of FTP clients and servers break and get out of sync | |
397 ;; when asked to list a non-existent directory. Some of the ai.mit.edu | |
398 ;; machines cause this problem for some FTP clients. Using | |
399 ;; ange-ftp-kill-ftp-process can restart the ftp process, which | |
400 ;; should get things back in sync. | |
401 ;; | |
402 ;; 3. Ange-ftp does not check to make sure that when creating a new file, | |
403 ;; you provide a valid filename for the remote operating system. | |
404 ;; If you do not, then the remote FTP server will most likely | |
405 ;; translate your filename in some way. This may cause ange-ftp to | |
406 ;; get confused about what exactly is the name of the file. The | |
407 ;; most common causes of this are using lower case filenames on systems | |
408 ;; which support only upper case, and using filenames which are too | |
409 ;; long. | |
410 ;; | |
411 ;; 4. Null (blank) passwords confuse both ange-ftp and some FTP daemons. | |
412 ;; | |
413 ;; 5. Ange-ftp likes to use pty's to talk to its FTP processes. If GNU Emacs | |
414 ;; for some reason creates a FTP process that only talks via pipes then | |
415 ;; ange-ftp won't be getting the information it requires at the time that | |
416 ;; it wants it since pipes flush at different times to pty's. One | |
417 ;; disgusting way around this problem is to talk to the FTP process via | |
418 ;; rlogin which does the 'right' things with pty's. | |
419 ;; | |
420 ;; 6. For CMS support, we send too many cd's. Since cd's are cheap, I haven't | |
421 ;; worried about this too much. Eventually, we should have some caching | |
422 ;; of the current minidisk. | |
423 ;; | |
424 ;; 7. Some CMS machines do not assign a default minidisk when you ftp them as | |
425 ;; anonymous. It is then necessary to guess a valid minidisk name, and cd | |
426 ;; to it. This is (understandably) beyond ange-ftp. | |
427 ;; | |
428 ;; 8. Remote to remote copying of files on non-Unix machines can be risky. | |
429 ;; Depending on the variable ange-ftp-binary-file-name-regexp, ange-ftp | |
430 ;; will use binary mode for the copy. Between systems of different | |
431 ;; architecture, this still may not be enough to guarantee the integrity | |
432 ;; of binary files. Binary file transfers from VMS machines are | |
433 ;; particularly problematical. Should ange-ftp-binary-file-name-regexp be | |
434 ;; an alist of OS type, regexp pairs? | |
435 ;; | |
436 ;; 9. The code to do compression of files over ftp is not as careful as it | |
437 ;; should be. It deletes the old remote version of the file, before | |
438 ;; actually checking if the local to remote transfer of the compressed | |
439 ;; file succeeds. Of course to delete the original version of the file | |
440 ;; after transferring the compressed version back is also dangerous, | |
441 ;; because some OS's have severe restrictions on the length of filenames, | |
442 ;; and when the compressed version is copied back the "-Z" or ".Z" may be | |
443 ;; truncated. Then, ange-ftp would delete the only remaining version of | |
444 ;; the file. Maybe ange-ftp should make backups when it compresses files | |
445 ;; (of course, the backup "~" could also be truncated off, sigh...). | |
446 ;; Suggestions? | |
447 ;; | |
448 ;; 10. If a dir listing is attempted for an empty directory on (at least | |
449 ;; some) VMS hosts, an ftp error is given. This is really an ftp bug, and | |
450 ;; I don't know how to get ange-ftp work to around it. | |
451 ;; | |
452 ;; 11. Bombs on filenames that start with a space. Deals well with filenames | |
453 ;; containing spaces, but beware that the remote ftpd may not like them | |
454 ;; much. | |
455 ;; | |
456 ;; 12. The dired support for non-Unix-like systems does not currently work. | |
457 ;; It needs to be reimplemented by modifying the parse-...-listing | |
458 ;; functions to convert the directory listing to ls -l format. | |
459 ;; | |
460 ;; 13. The famous @ bug. As mentioned above in TIPS, ULTRIX marks symlinks | |
461 ;; with a trailing @ in a ls -alF listing. In order to account for this | |
462 ;; ange-ftp looks to chop trailing @'s off of symlink names when it is | |
463 ;; parsing a listing with the F switch. This will cause ange-ftp to | |
464 ;; incorrectly get the name of a symlink on a non-ULTRIX host if its name | |
465 ;; ends in an @. ange-ftp will correct itself if you take F out of the | |
466 ;; dired ls switches (C-u s will allow you to edit the switches). The | |
467 ;; dired buffer will be automatically reverted, which will allow ange-ftp | |
468 ;; to fix its files hashtable. A cookie to anyone who can think of a | |
469 ;; fast, sure-fire way to recognize ULTRIX over ftp. | |
470 | |
471 ;; If you find any bugs or problems with this package, PLEASE either e-mail | |
472 ;; the above author, or send a message to the ange-ftp-lovers mailing list | |
473 ;; below. Ideas and constructive comments are especially welcome. | |
474 | |
475 ;; ange-ftp-lovers: | |
476 ;; | |
477 ;; ange-ftp has its own mailing list modestly called ange-ftp-lovers. All | |
478 ;; users of ange-ftp are welcome to subscribe (see below) and to discuss | |
479 ;; aspects of ange-ftp. New versions of ange-ftp are posted periodically to | |
480 ;; the mailing list. | |
481 ;; | |
482 ;; To [un]subscribe to ange-ftp-lovers, or to report mailer problems with the | |
483 ;; list, please mail one of the following addresses: | |
484 ;; | |
485 ;; ange-ftp-lovers-request@anorman.hpl.hp.com | |
486 ;; or | |
487 ;; ange-ftp-lovers-request%anorman.hpl.hp.com@hplb.hpl.hp.com | |
488 ;; | |
489 ;; Please don't forget the -request part. | |
490 ;; | |
491 ;; For mail to be posted directly to ange-ftp-lovers, send to one of the | |
492 ;; following addresses: | |
493 ;; | |
494 ;; ange-ftp-lovers@anorman.hpl.hp.com | |
495 ;; or | |
496 ;; ange-ftp-lovers%anorman.hpl.hp.com@hplb.hpl.hp.com | |
497 ;; | |
498 ;; Alternatively, there is a mailing list that only gets announcements of new | |
499 ;; ange-ftp releases. This is called ange-ftp-lovers-announce, and can be | |
500 ;; subscribed to by e-mailing to the -request address as above. Please make | |
501 ;; it clear in the request which mailing list you wish to join. | |
502 | |
503 ;; The latest version of ange-ftp can usually be obtained via anonymous ftp | |
504 ;; from: | |
505 ;; alpha.gnu.ai.mit.edu:ange-ftp/ange-ftp.tar.Z | |
506 ;; or: | |
507 ;; ugle.unit.no:/pub/gnu/emacs-lisp/ange-ftp.tar.Z | |
508 ;; or: | |
509 ;; archive.cis.ohio-state.edu:pub/gnu/emacs/elisp-archive/packages/ange-ftp.tar.Z | |
510 | |
511 ;; The archives for ange-ftp-lovers can be found via anonymous ftp under: | |
512 ;; | |
513 ;; ftp.reed.edu:pub/mailing-lists/ange-ftp/ | |
1106 | 514 |
14169 | 515 ;; ----------------------------------------------------------- |
516 ;; Technical information on this package: | |
517 ;; ----------------------------------------------------------- | |
518 | |
519 ;; ange-ftp works by putting a handler on file-name-handler-alist | |
520 ;; which is called by many primitives, and a few non-primitives, | |
521 ;; whenever they see a file name of the appropriate sort. | |
522 | |
523 ;; Checklist for adding non-UNIX support for TYPE | |
524 ;; | |
525 ;; The following functions may need TYPE versions: | |
526 ;; (not all functions will be needed for every OS) | |
527 ;; | |
528 ;; ange-ftp-fix-name-for-TYPE | |
529 ;; ange-ftp-fix-dir-name-for-TYPE | |
530 ;; ange-ftp-TYPE-host | |
531 ;; ange-ftp-TYPE-add-host | |
532 ;; ange-ftp-parse-TYPE-listing | |
533 ;; ange-ftp-TYPE-delete-file-entry | |
534 ;; ange-ftp-TYPE-add-file-entry | |
535 ;; ange-ftp-TYPE-file-name-as-directory | |
536 ;; ange-ftp-TYPE-make-compressed-filename | |
537 ;; ange-ftp-TYPE-file-name-sans-versions | |
538 ;; | |
539 ;; Variables: | |
540 ;; | |
541 ;; ange-ftp-TYPE-host-regexp | |
542 ;; May need to add TYPE to ange-ftp-dumb-host-types | |
543 ;; | |
544 ;; Check the following functions for OS dependent coding: | |
545 ;; | |
546 ;; ange-ftp-host-type | |
547 ;; ange-ftp-guess-host-type | |
548 ;; ange-ftp-allow-child-lookup | |
549 | |
550 ;; Host type conventions: | |
551 ;; | |
552 ;; The function ange-ftp-host-type and the variable ange-ftp-dired-host-type | |
553 ;; (mostly) follow the following conventions for remote host types. At | |
554 ;; least, I think that future code should try to follow these conventions, | |
555 ;; and the current code should eventually be made compliant. | |
556 ;; | |
557 ;; nil = local host type, whatever that is (probably unix). | |
558 ;; Think nil as in "not a remote host". This value is used by | |
559 ;; ange-ftp-dired-host-type for local buffers. | |
560 ;; | |
561 ;; t = a remote host of unknown type. Think t is in true, it's remote. | |
562 ;; Currently, 'unix is used as the default remote host type. | |
563 ;; Maybe we should use t. | |
564 ;; | |
565 ;; 'type = a remote host of TYPE type. | |
566 ;; | |
567 ;; 'type:list = a remote host of TYPE type, using a specialized ftp listing | |
568 ;; program called list. This is currently only used for Unix | |
569 ;; dl (descriptive listings), when ange-ftp-dired-host-type | |
570 ;; is set to 'unix:dl. | |
571 | |
572 ;; Bug report codes: | |
573 ;; | |
574 ;; Because of their naive faith in this code, there are certain situations | |
575 ;; which the writers of this program believe could never happen. However, | |
576 ;; being realists they have put calls to `error' in the program at these | |
577 ;; points. These errors provide a code, which is an integer, greater than 1. | |
578 ;; To aid debugging. the error codes, and the functions in which they reside | |
579 ;; are listed below. | |
580 ;; | |
581 ;; 1: See ange-ftp-ls | |
582 ;; | |
1106 | 583 |
14169 | 584 ;; ----------------------------------------------------------- |
585 ;; Hall of fame: | |
586 ;; ----------------------------------------------------------- | |
587 ;; | |
588 ;; Thanks to Roland McGrath for improving the filename syntax handling, | |
589 ;; for suggesting many enhancements and for numerous cleanups to the code. | |
590 ;; | |
591 ;; Thanks to Jamie Zawinski for bugfixes and for ideas such as gateways. | |
592 ;; | |
593 ;; Thanks to Ken Laprade for improved .netrc parsing, password reading, and | |
594 ;; dired / shell auto-loading. | |
595 ;; | |
596 ;; Thanks to Sebastian Kremer for dired support and for many ideas and | |
597 ;; bugfixes. | |
598 ;; | |
599 ;; Thanks to Joe Wells for bugfixes, the original non-UNIX system support, | |
600 ;; VOS support, and hostname completion. | |
601 ;; | |
602 ;; Thanks to Nakagawa Takayuki for many good ideas, filename-completion, help | |
603 ;; with file-name expansion, efficiency worries, stylistic concerns and many | |
604 ;; bugfixes. | |
605 ;; | |
606 ;; Thanks to Sandy Rutherford who re-wrote most of ange-ftp to support VMS, | |
607 ;; MTS, CMS and UNIX-dls. Sandy also added dired-support for non-UNIX OS and | |
608 ;; auto-recognition of the host type. | |
609 ;; | |
610 ;; Thanks to Dave Smith who wrote the info file for ange-ftp. | |
611 ;; | |
612 ;; Finally, thanks to Keith Waclena, Mark D. Baushke, Terence Kelleher, Ping | |
613 ;; Zhou, Edward Vielmetti, Jack Repenning, Mike Balenger, Todd Kaufmann, | |
614 ;; Kjetil Svarstad, Tom Wurgler, Linus Tolke, Niko Makila, Carl Edman, Bill | |
615 ;; Trost, Dave Brennan, Dan Jacobson, Andy Scott, Steve Anderson, Sanjay | |
616 ;; Mathur, the folks on the ange-ftp-lovers mailing list and many others | |
617 ;; whose names I've forgotten who have helped to debug and fix problems with | |
618 ;; ange-ftp.el. | |
1106 | 619 |
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
620 ;;; Code: |
14169 | 621 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
622 (require 'comint) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
623 |
1106 | 624 ;;;; ------------------------------------------------------------ |
625 ;;;; User customization variables. | |
626 ;;;; ------------------------------------------------------------ | |
627 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
628 (defvar ange-ftp-name-format |
14138
9856174aa877
(ange-ftp-name-format): Don't match "/:" or "/.:".
Karl Heuer <kwzh@gnu.org>
parents:
14040
diff
changeset
|
629 '("^/\\(\\([^@/:]*\\)@\\)?\\([^@/:]*[^@/:.]\\):\\(.*\\)" . (3 2 4)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
630 "*Format of a fully expanded remote file name. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
631 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
|
632 where REGEXP is a regular expression matching |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
633 the full remote name, and HOST, USER, and NAME are the numbers of |
1106 | 634 parenthesized expressions in REGEXP for the components (in that order).") |
635 | |
636 ;; ange-ftp-multi-skip-msgs should only match ###-, where ### is one of | |
637 ;; the number codes corresponding to ange-ftp-good-msgs or ange-ftp-fatal-msgs. | |
638 ;; Otherwise, ange-ftp will go into multi-skip mode, and never come out. | |
639 | |
640 (defvar ange-ftp-multi-msgs | |
3620
219ff1cb76f4
(ange-ftp-multi-msgs): Add 331-.
Richard M. Stallman <rms@gnu.org>
parents:
3611
diff
changeset
|
641 "^220-\\|^230-\\|^226\\|^25.-\\|^221-\\|^200-\\|^331-\\|^4[25]1-\\|^530-" |
7042 | 642 "*Regular expression matching the start of a multiline ftp reply.") |
1106 | 643 |
644 (defvar ange-ftp-good-msgs | |
645 "^220 \\|^230 \\|^226 \\|^25. \\|^221 \\|^200 \\|^[Hh]ash mark" | |
7042 | 646 "*Regular expression matching ftp \"success\" messages.") |
1106 | 647 |
648 ;; CMS and the odd VMS machine say 200 Port rather than 200 PORT. | |
649 ;; Also CMS machines use a multiline 550- reply to say that you | |
650 ;; don't have write permission. ange-ftp gets into multi-line skip | |
651 ;; mode and hangs. Have it ignore 550- instead. It will then barf | |
652 ;; when it gets the 550 line, as it should. | |
653 | |
654 (defvar ange-ftp-skip-msgs | |
655 (concat "^200 \\(PORT\\|Port\\) \\|^331 \\|^150 \\|^350 \\|^[0-9]+ bytes \\|" | |
656 "^Connected \\|^$\\|^Remote system\\|^Using\\|^ \\|Password:\\|" | |
13089
c18fa2e296f9
(ange-ftp-dumb-unix-host): Avoid error if HOST is nil.
Richard M. Stallman <rms@gnu.org>
parents:
13005
diff
changeset
|
657 "^Data connection \\|" |
1106 | 658 "^local:\\|^Trying\\|^125 \\|^550-\\|^221 .*oodbye") |
7042 | 659 "*Regular expression matching ftp messages that can be ignored.") |
1106 | 660 |
661 (defvar ange-ftp-fatal-msgs | |
662 (concat "^ftp: \\|^Not connected\\|^530 \\|^4[25]1 \\|rcmd: \\|" | |
663 "^No control connection\\|unknown host\\|^lost connection") | |
7042 | 664 "*Regular expression matching ftp messages that indicate serious errors. |
665 These mean that the FTP process should (or already has) been killed.") | |
1106 | 666 |
667 (defvar ange-ftp-gateway-fatal-msgs | |
668 "No route to host\\|Connection closed\\|No such host\\|Login incorrect" | |
7042 | 669 "*Regular expression matching login failure messages from rlogin/telnet.") |
1106 | 670 |
671 (defvar ange-ftp-xfer-size-msgs | |
672 "^150 .* connection for .* (\\([0-9]+\\) bytes)" | |
673 "*Regular expression used to determine the number of bytes in a FTP transfer.") | |
674 | |
675 (defvar ange-ftp-tmp-name-template "/tmp/ange-ftp" | |
676 "*Template used to create temporary files.") | |
677 | |
678 (defvar ange-ftp-gateway-tmp-name-template "/tmp/ange-ftp" | |
679 "*Template used to create temporary files when ftp-ing through a gateway. | |
680 Files starting with this prefix need to be accessible from BOTH the local | |
681 machine and the gateway machine, and need to have the SAME name on both | |
682 machines, that is, /tmp is probably NOT what you want, since that is rarely | |
683 cross-mounted.") | |
684 | |
685 (defvar ange-ftp-netrc-filename "~/.netrc" | |
686 "*File in .netrc format to search for passwords.") | |
687 | |
688 (defvar ange-ftp-disable-netrc-security-check nil | |
689 "*If non-nil avoid checking permissions on the .netrc file.") | |
690 | |
691 (defvar ange-ftp-default-user nil | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
692 "*User name to use when none is specied in a file name. |
1106 | 693 If nil, then the name under which the user is logged in is used. |
694 If non-nil but not a string, the user is prompted for the name.") | |
695 | |
696 (defvar ange-ftp-default-password nil | |
697 "*Password to use when the user is the same as ange-ftp-default-user.") | |
698 | |
699 (defvar ange-ftp-default-account nil | |
700 "*Account password to use when the user is the same as ange-ftp-default-user.") | |
701 | |
1174 | 702 (defvar ange-ftp-generate-anonymous-password t |
9627
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
703 "*If t, use value of `user-mail-address' as password for anonymous ftp. |
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
704 If a string, then use that string as the password. |
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
705 If nil, prompt the user for a password.") |
1106 | 706 |
707 (defvar ange-ftp-dumb-unix-host-regexp nil | |
7042 | 708 "*If non-nil, regexp matching hosts on which `dir' command lists directory.") |
1106 | 709 |
710 (defvar ange-ftp-binary-file-name-regexp | |
2560
50d7841854b3
(ange-ftp-binary-file-name-regexp): Match .z and .z-part-?? files.
Roland McGrath <roland@gnu.org>
parents:
2258
diff
changeset
|
711 (concat "\\.[zZ]$\\|\\.lzh$\\|\\.arc$\\|\\.zip$\\|\\.zoo$\\|\\.tar$\\|" |
1106 | 712 "\\.dvi$\\|\\.ps$\\|\\.elc$\\|TAGS$\\|\\.gif$\\|" |
5171
85aadd2a80ba
(ange-ftp-binary-file-name-regexp): Accept .tgz and .taz files.
Richard M. Stallman <rms@gnu.org>
parents:
5067
diff
changeset
|
713 "\\.EXE\\(;[0-9]+\\)?$\\|\\.[zZ]-part-..$\\|\\.gz$\\|" |
85aadd2a80ba
(ange-ftp-binary-file-name-regexp): Accept .tgz and .taz files.
Richard M. Stallman <rms@gnu.org>
parents:
5067
diff
changeset
|
714 "\\.taz$\\|\\.tgz$") |
1106 | 715 "*If a file matches this regexp then it is transferred in binary mode.") |
716 | |
717 (defvar ange-ftp-gateway-host nil | |
718 "*Name of host to use as gateway machine when local FTP isn't possible.") | |
719 | |
720 (defvar ange-ftp-local-host-regexp ".*" | |
7042 | 721 "*Regexp selecting hosts which can be reached directly with ftp. |
722 For other hosts the FTP process is started on \`ange-ftp-gateway-host\' | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
723 instead, and/or reached via \`ange-ftp-gateway-ftp-program-name\'.") |
1106 | 724 |
725 (defvar ange-ftp-gateway-program-interactive nil | |
7042 | 726 "*If non-nil then the gateway program should give a shell prompt. |
727 Both telnet and rlogin do something like this.") | |
1106 | 728 |
10451
bc83756f19ad
(ange-ftp-gateway-program, ange-ftp-shell-command): Use new global
Karl Heuer <kwzh@gnu.org>
parents:
10407
diff
changeset
|
729 (defvar ange-ftp-gateway-program remote-shell-program |
7042 | 730 "*Name of program to spawn a shell on the gateway machine. |
10451
bc83756f19ad
(ange-ftp-gateway-program, ange-ftp-shell-command): Use new global
Karl Heuer <kwzh@gnu.org>
parents:
10407
diff
changeset
|
731 Valid candidates are rsh (remsh on some systems), telnet and rlogin. See |
7042 | 732 also the gateway variable above.") |
1106 | 733 |
5265
7305f7204c67
(ange-ftp-hash-mark-msgs): Make match more general.
Richard M. Stallman <rms@gnu.org>
parents:
5171
diff
changeset
|
734 (defvar ange-ftp-gateway-prompt-pattern "^[^#$%>;\n]*[#$%>;] *" |
7042 | 735 "*Regexp matching prompt after complete login sequence on gateway machine. |
736 A match for this means the shell is now awaiting input. Make this regexp as | |
1106 | 737 strict as possible; it shouldn't match *anything* at all except the user's |
738 initial prompt. The above string will fail under most SUN-3's since it | |
739 matches the login banner.") | |
740 | |
741 (defvar ange-ftp-gateway-setup-term-command | |
742 (if (eq system-type 'hpux) | |
743 "stty -onlcr -echo\n" | |
744 "stty -echo nl\n") | |
7042 | 745 "*Set up terminal after logging in to the gateway machine. |
746 This command should stop the terminal from echoing each command, and | |
747 arrange to strip out trailing ^M characters.") | |
1106 | 748 |
749 (defvar ange-ftp-smart-gateway nil | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
750 "*Non-nil means the ftp gateway and/or the gateway ftp program is smart. |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
751 Don't bother telnetting, etc., already connected to desired host transparently, |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
752 or just issue a user@host command in case \`ange-ftp-gateway-host\' is non-nil.") |
1106 | 753 |
754 (defvar ange-ftp-smart-gateway-port "21" | |
755 "*Port on gateway machine to use when smart gateway is in operation.") | |
756 | |
757 (defvar ange-ftp-send-hash t | |
758 "*If non-nil, send the HASH command to the FTP client.") | |
759 | |
760 (defvar ange-ftp-binary-hash-mark-size nil | |
761 "*Default size, in bytes, between hash-marks when transferring a binary file. | |
762 If NIL, this variable will be locally overridden if the FTP client outputs a | |
763 suitable response to the HASH command. If non-NIL then this value takes | |
764 precedence over the local value.") | |
765 | |
766 (defvar ange-ftp-ascii-hash-mark-size 1024 | |
767 "*Default size, in bytes, between hash-marks when transferring an ASCII file. | |
768 This variable is buffer-local and will be locally overridden if the FTP client | |
769 outputs a suitable response to the HASH command.") | |
770 | |
771 (defvar ange-ftp-process-verbose t | |
772 "*If non-NIL then be chatty about interaction with the FTP process.") | |
773 | |
774 (defvar ange-ftp-ftp-program-name "ftp" | |
775 "*Name of FTP program to run.") | |
776 | |
777 (defvar ange-ftp-gateway-ftp-program-name "ftp" | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
778 "*Name of FTP program to run when accessing non-local hosts. |
1106 | 779 Some AT&T folks claim to use something called `pftp' here.") |
780 | |
781 (defvar ange-ftp-ftp-program-args '("-i" "-n" "-g" "-v") | |
782 "*A list of arguments passed to the FTP program when started.") | |
783 | |
784 (defvar ange-ftp-nslookup-program nil | |
785 "*If non-NIL then a string naming nslookup program." ) | |
786 | |
787 (defvar ange-ftp-make-backup-files () | |
3416
5bd76dd4c6bd
(ange-ftp-make-backup-files): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
3394
diff
changeset
|
788 "*Non-nil means make backup files for \"magic\" remote files.") |
1106 | 789 |
790 (defvar ange-ftp-retry-time 5 | |
7042 | 791 "*Number of seconds to wait before retry if file or listing doesn't arrive. |
792 This might need to be increased for very slow connections.") | |
1106 | 793 |
794 (defvar ange-ftp-auto-save 0 | |
795 "If 1, allows ange-ftp files to be auto-saved. | |
796 If 0, suppresses auto-saving of ange-ftp files. | |
797 Don't use any other value.") | |
798 | |
799 ;;;; ------------------------------------------------------------ | |
800 ;;;; Hash table support. | |
801 ;;;; ------------------------------------------------------------ | |
802 | |
803 (require 'backquote) | |
804 | |
805 (defun ange-ftp-make-hashtable (&optional size) | |
806 "Make an obarray suitable for use as a hashtable. | |
807 SIZE, if supplied, should be a prime number." | |
808 (make-vector (or size 31) 0)) | |
809 | |
810 (defun ange-ftp-map-hashtable (fun tbl) | |
811 "Call FUNCTION on each key and value in HASHTABLE." | |
812 (mapatoms | |
813 (function | |
814 (lambda (sym) | |
815 (funcall fun (get sym 'key) (get sym 'val)))) | |
816 tbl)) | |
817 | |
818 (defmacro ange-ftp-make-hash-key (key) | |
819 "Convert KEY into a suitable key for a hashtable." | |
820 (` (if (stringp (, key)) | |
821 (, key) | |
822 (prin1-to-string (, key))))) | |
823 | |
824 (defun ange-ftp-get-hash-entry (key tbl) | |
825 "Return the value associated with KEY in HASHTABLE." | |
826 (let ((sym (intern-soft (ange-ftp-make-hash-key key) tbl))) | |
827 (and sym (get sym 'val)))) | |
828 | |
829 (defun ange-ftp-put-hash-entry (key val tbl) | |
830 "Record an association between KEY and VALUE in HASHTABLE." | |
831 (let ((sym (intern (ange-ftp-make-hash-key key) tbl))) | |
832 (put sym 'val val) | |
833 (put sym 'key key))) | |
834 | |
835 (defun ange-ftp-del-hash-entry (key tbl) | |
836 "Copy all symbols except KEY in HASHTABLE and return modified hashtable." | |
837 (let* ((len (length tbl)) | |
838 (new-tbl (ange-ftp-make-hashtable len)) | |
839 (i (1- len))) | |
840 (ange-ftp-map-hashtable | |
841 (function | |
842 (lambda (k v) | |
843 (or (equal k key) | |
844 (ange-ftp-put-hash-entry k v new-tbl)))) | |
845 tbl) | |
846 (while (>= i 0) | |
847 (aset tbl i (aref new-tbl i)) | |
848 (setq i (1- i))) | |
849 tbl)) | |
850 | |
851 (defun ange-ftp-hash-entry-exists-p (key tbl) | |
852 "Return whether there is an association for KEY in TABLE." | |
853 (intern-soft (ange-ftp-make-hash-key key) tbl)) | |
854 | |
855 (defun ange-ftp-hash-table-keys (tbl) | |
1233 | 856 "Return a sorted list of all the active keys in TABLE, as strings." |
1106 | 857 (sort (all-completions "" tbl) |
858 (function string-lessp))) | |
859 | |
860 ;;;; ------------------------------------------------------------ | |
861 ;;;; Internal variables. | |
862 ;;;; ------------------------------------------------------------ | |
863 | |
864 (defvar ange-ftp-data-buffer-name " *ftp data*" | |
865 "Buffer name to hold directory listing data received from ftp process.") | |
866 | |
867 (defvar ange-ftp-netrc-modtime nil | |
868 "Last modified time of the netrc file from file-attributes.") | |
869 | |
870 (defvar ange-ftp-user-hashtable (ange-ftp-make-hashtable) | |
871 "Hash table holding associations between HOST, USER pairs.") | |
872 | |
873 (defvar ange-ftp-passwd-hashtable (ange-ftp-make-hashtable) | |
874 "Mapping between a HOST, USER pair and a PASSWORD for them.") | |
875 | |
876 (defvar ange-ftp-account-hashtable (ange-ftp-make-hashtable) | |
877 "Mapping between a HOST, USER pair and a ACCOUNT password for them.") | |
878 | |
879 (defvar ange-ftp-files-hashtable (ange-ftp-make-hashtable 97) | |
880 "Hash table for storing directories and their respective files.") | |
881 | |
882 (defvar ange-ftp-ls-cache-lsargs nil | |
883 "Last set of args used by ange-ftp-ls.") | |
884 | |
885 (defvar ange-ftp-ls-cache-file nil | |
886 "Last file passed to ange-ftp-ls.") | |
887 | |
888 (defvar ange-ftp-ls-cache-res nil | |
889 "Last result returned from ange-ftp-ls.") | |
890 | |
891 (defconst ange-ftp-expand-dir-hashtable (ange-ftp-make-hashtable)) | |
892 | |
893 (defconst ange-ftp-expand-dir-regexp "^5.0 \\([^: ]+\\):") | |
894 | |
895 ;; These are local variables in each FTP process buffer. | |
896 (defvar ange-ftp-hash-mark-unit nil) | |
897 (defvar ange-ftp-hash-mark-count nil) | |
898 (defvar ange-ftp-xfer-size nil) | |
899 (defvar ange-ftp-process-string nil) | |
900 (defvar ange-ftp-process-result-line nil) | |
901 (defvar ange-ftp-process-busy nil) | |
902 (defvar ange-ftp-process-result nil) | |
903 (defvar ange-ftp-process-multi-skip nil) | |
904 (defvar ange-ftp-process-msg nil) | |
905 (defvar ange-ftp-process-continue nil) | |
906 (defvar ange-ftp-last-percent nil) | |
907 | |
908 ;; These variables are bound by one function and examined by another. | |
909 ;; Leave them void globally for error checking. | |
910 (defvar ange-ftp-this-file) | |
911 (defvar ange-ftp-this-dir) | |
912 (defvar ange-ftp-this-user) | |
913 (defvar ange-ftp-this-host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
914 (defvar ange-ftp-this-msg) |
1106 | 915 (defvar ange-ftp-completion-ignored-pattern) |
916 (defvar ange-ftp-trample-marker) | |
917 | |
918 ;; New error symbols. | |
919 (put 'ftp-error 'error-conditions '(ftp-error file-error error)) | |
920 ;; (put 'ftp-error 'error-message "FTP error") | |
921 | |
922 ;;; ------------------------------------------------------------ | |
923 ;;; Enhanced message support. | |
924 ;;; ------------------------------------------------------------ | |
925 | |
926 (defun ange-ftp-message (fmt &rest args) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
927 "Display message in echo area, but indicate if truncated. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
928 Args are as in `message': a format string, plus arguments to be formatted." |
1106 | 929 (let ((msg (apply (function format) fmt args)) |
930 (max (window-width (minibuffer-window)))) | |
11315
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
931 (if noninteractive |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
932 msg |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
933 (if (>= (length msg) max) |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
934 ;; Take just the last MAX - 3 chars of the string. |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
935 (setq msg (concat "> " (substring msg (- 3 max))))) |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
936 (message "%s" msg)))) |
1106 | 937 |
938 (defun ange-ftp-abbreviate-filename (file &optional new) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
939 "Abbreviate the file name FILE relative to the default-directory. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
940 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
|
941 only return the directory part of FILE." |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
942 (save-match-data |
1106 | 943 (if (and default-directory |
944 (string-match (concat "^" | |
945 (regexp-quote default-directory) | |
946 ".") file)) | |
947 (setq file (substring file (1- (match-end 0))))) | |
948 (if (and new | |
949 (string-equal (file-name-nondirectory file) | |
950 (file-name-nondirectory new))) | |
951 (setq file (file-name-directory file))) | |
952 (or file "./"))) | |
953 | |
954 ;;;; ------------------------------------------------------------ | |
955 ;;;; User / Host mapping support. | |
956 ;;;; ------------------------------------------------------------ | |
957 | |
958 (defun ange-ftp-set-user (host user) | |
959 "For a given HOST, set or change the default USER." | |
960 (interactive "sHost: \nsUser: ") | |
961 (ange-ftp-put-hash-entry host user ange-ftp-user-hashtable)) | |
962 | |
963 (defun ange-ftp-get-user (host) | |
964 "Given a HOST, return the default USER." | |
965 (ange-ftp-parse-netrc) | |
966 (let ((user (ange-ftp-get-hash-entry host ange-ftp-user-hashtable))) | |
967 (or user | |
968 (prog1 | |
969 (setq user | |
970 (cond ((stringp ange-ftp-default-user) | |
971 ;; We have a default name. Use it. | |
972 ange-ftp-default-user) | |
973 (ange-ftp-default-user | |
974 ;; Ask the user. | |
975 (let ((enable-recursive-minibuffers t)) | |
976 (read-string (format "User for %s: " host) | |
977 (user-login-name)))) | |
978 ;; Default to the user's login name. | |
979 (t | |
980 (user-login-name)))) | |
981 (ange-ftp-set-user host user))))) | |
982 | |
983 ;;;; ------------------------------------------------------------ | |
984 ;;;; Password support. | |
985 ;;;; ------------------------------------------------------------ | |
986 | |
987 (defun ange-ftp-read-passwd (prompt &optional default) | |
988 "Read a password, echoing `.' for each character typed. | |
989 End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. | |
990 Optional DEFAULT is password to start with." | |
991 (let ((pass (if default default "")) | |
992 (c 0) | |
993 (echo-keystrokes 0) | |
994 (cursor-in-echo-area t)) | |
995 (while (progn (message "%s%s" | |
996 prompt | |
997 (make-string (length pass) ?.)) | |
998 (setq c (read-char)) | |
999 (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) | |
1000 (if (= c ?\C-u) | |
1001 (setq pass "") | |
1002 (if (and (/= c ?\b) (/= c ?\177)) | |
1003 (setq pass (concat pass (char-to-string c))) | |
1004 (if (> (length pass) 0) | |
1005 (setq pass (substring pass 0 -1)))))) | |
1006 (message "") | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1007 (ange-ftp-repaint-minibuffer) |
1106 | 1008 pass)) |
1009 | |
1010 (defmacro ange-ftp-generate-passwd-key (host user) | |
1011 (` (concat (, host) "/" (, user)))) | |
1012 | |
1013 (defmacro ange-ftp-lookup-passwd (host user) | |
1014 (` (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key (, host) (, user)) | |
1015 ange-ftp-passwd-hashtable))) | |
1016 | |
1017 (defun ange-ftp-set-passwd (host user passwd) | |
1018 "For a given HOST and USER, set or change the associated PASSWORD." | |
1019 (interactive (list (read-string "Host: ") | |
1020 (read-string "User: ") | |
1021 (ange-ftp-read-passwd "Password: "))) | |
1022 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) | |
1023 passwd | |
1024 ange-ftp-passwd-hashtable)) | |
1025 | |
1026 (defun ange-ftp-get-host-with-passwd (user) | |
1027 "Given a USER, return a host we know the password for." | |
1028 (ange-ftp-parse-netrc) | |
1029 (catch 'found-one | |
1030 (ange-ftp-map-hashtable | |
1031 (function (lambda (host val) | |
1032 (if (ange-ftp-lookup-passwd host user) | |
1033 (throw 'found-one host)))) | |
1034 ange-ftp-user-hashtable) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1035 (save-match-data |
1106 | 1036 (ange-ftp-map-hashtable |
1037 (function | |
1038 (lambda (key value) | |
1039 (if (string-match "^[^/]*\\(/\\).*$" key) | |
1040 (let ((host (substring key 0 (match-beginning 1)))) | |
1041 (if (and (string-equal user (substring key (match-end 1))) | |
1042 value) | |
1043 (throw 'found-one host)))))) | |
1044 ange-ftp-passwd-hashtable)) | |
1045 nil)) | |
1046 | |
1047 (defun ange-ftp-get-passwd (host user) | |
1048 "Return the password for specified HOST and USER, asking user if necessary." | |
1049 (ange-ftp-parse-netrc) | |
1050 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
1051 ;; look up password in the hash table first; user might have overridden the |
1106 | 1052 ;; defaults. |
1053 (cond ((ange-ftp-lookup-passwd host user)) | |
1054 | |
1055 ;; see if default user and password set from the .netrc file. | |
1056 ((and (stringp ange-ftp-default-user) | |
1057 ange-ftp-default-password | |
1058 (string-equal user ange-ftp-default-user)) | |
1059 ange-ftp-default-password) | |
1060 | |
1061 ;; anonymous ftp password is handled specially since there is an | |
1062 ;; unwritten rule about how that is used on the Internet. | |
1063 ((and (or (string-equal user "anonymous") | |
1064 (string-equal user "ftp")) | |
1065 ange-ftp-generate-anonymous-password) | |
1066 (if (stringp ange-ftp-generate-anonymous-password) | |
1067 ange-ftp-generate-anonymous-password | |
9627
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
1068 user-mail-address)) |
1106 | 1069 |
1070 ;; see if same user has logged in to other hosts; if so then prompt | |
1071 ;; with the password that was used there. | |
1072 (t | |
1073 (let* ((other (ange-ftp-get-host-with-passwd user)) | |
1074 (passwd (if other | |
1075 | |
1076 ;; found another machine with the same user. | |
1077 ;; Try that account. | |
1078 (ange-ftp-read-passwd | |
1079 (format "passwd for %s@%s (same as %s@%s): " | |
1080 user host user other) | |
1081 (ange-ftp-lookup-passwd other user)) | |
1082 | |
1083 ;; I give up. Ask the user for the password. | |
1084 (ange-ftp-read-passwd | |
1085 (format "Password for %s@%s: " user host))))) | |
1086 (ange-ftp-set-passwd host user passwd) | |
1087 passwd)))) | |
1088 | |
1089 ;;;; ------------------------------------------------------------ | |
1090 ;;;; Account support | |
1091 ;;;; ------------------------------------------------------------ | |
1092 | |
1093 ;; Account passwords must be either specified in the .netrc file, or set | |
1094 ;; manually by calling ange-ftp-set-account. For the moment, ange-ftp doesn't | |
1095 ;; check to see whether the FTP process is actually prompting for an account | |
1096 ;; password. | |
1097 | |
1098 (defun ange-ftp-set-account (host user account) | |
1099 "For a given HOST and USER, set or change the associated ACCOUNT password." | |
1100 (interactive (list (read-string "Host: ") | |
1101 (read-string "User: ") | |
1102 (ange-ftp-read-passwd "Account password: "))) | |
1103 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) | |
1104 account | |
1105 ange-ftp-account-hashtable)) | |
1106 | |
1107 (defun ange-ftp-get-account (host user) | |
1108 "Given a HOST and USER, return the FTP account." | |
1109 (ange-ftp-parse-netrc) | |
1110 (or (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key host user) | |
1111 ange-ftp-account-hashtable) | |
1112 (and (stringp ange-ftp-default-user) | |
1113 (string-equal user ange-ftp-default-user) | |
1114 ange-ftp-default-account))) | |
1115 | |
1116 ;;;; ------------------------------------------------------------ | |
1117 ;;;; ~/.netrc support | |
1118 ;;;; ------------------------------------------------------------ | |
1119 | |
1120 (defun ange-ftp-chase-symlinks (file) | |
1233 | 1121 "Return the filename that FILE references, following all symbolic links." |
1106 | 1122 (let (temp) |
1123 (while (setq temp (ange-ftp-real-file-symlink-p file)) | |
1124 (setq file | |
1125 (if (file-name-absolute-p temp) | |
1126 temp | |
1127 (concat (file-name-directory file) temp))))) | |
1128 file) | |
1129 | |
7042 | 1130 ;; Move along current line looking for the value of the TOKEN. |
1131 ;; Valid separators between TOKEN and its value are commas and | |
1132 ;; whitespace. Second arg LIMIT is a limit for the search. | |
1133 | |
1106 | 1134 (defun ange-ftp-parse-netrc-token (token limit) |
1135 (if (search-forward token limit t) | |
1136 (let (beg) | |
1137 (skip-chars-forward ", \t\r\n" limit) | |
1138 (if (eq (following-char) ?\") ;quoted token value | |
1139 (progn (forward-char 1) | |
1140 (setq beg (point)) | |
1141 (skip-chars-forward "^\"" limit) | |
1142 (forward-char 1) | |
1143 (buffer-substring beg (1- (point)))) | |
1144 (setq beg (point)) | |
1145 (skip-chars-forward "^, \t\r\n" limit) | |
1146 (buffer-substring beg (point)))))) | |
1147 | |
7042 | 1148 ;; Extract the values for the tokens `machine', `login', |
1149 ;; `password' and `account' in the current buffer. If successful, | |
1150 ;; record the information found. | |
1151 | |
1106 | 1152 (defun ange-ftp-parse-netrc-group () |
1153 (let ((start (point)) | |
8397
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1154 (end (save-excursion |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1155 (if (looking-at "machine\\>") |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1156 ;; Skip `machine' and the machine name that follows. |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1157 (progn |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1158 (skip-chars-forward "^ \t\n") |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1159 (skip-chars-forward " \t\n") |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1160 (skip-chars-forward "^ \t\n")) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1161 ;; Skip `default'. |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1162 (skip-chars-forward "^ \t\n")) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1163 ;; Find start of the next `machine' or `default' |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1164 ;; or the end of the buffer. |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1165 (if (re-search-forward "machine\\>\\|default\\>" nil t) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1166 (match-beginning 0) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1167 (point-max)))) |
1106 | 1168 machine login password account) |
1169 (setq machine (ange-ftp-parse-netrc-token "machine" end) | |
1170 login (ange-ftp-parse-netrc-token "login" end) | |
1171 password (ange-ftp-parse-netrc-token "password" end) | |
1172 account (ange-ftp-parse-netrc-token "account" end)) | |
1173 (if (and machine login) | |
1174 ;; found a `machine` token. | |
1175 (progn | |
1176 (ange-ftp-set-user machine login) | |
1177 (ange-ftp-set-passwd machine login password) | |
1178 (and account | |
1179 (ange-ftp-set-account machine login account))) | |
1180 (goto-char start) | |
1181 (if (search-forward "default" end t) | |
1182 ;; found a `default' token | |
1183 (progn | |
1184 (setq login (ange-ftp-parse-netrc-token "login" end) | |
1185 password (ange-ftp-parse-netrc-token "password" end) | |
1186 account (ange-ftp-parse-netrc-token "account" end)) | |
1187 (and login | |
1188 (setq ange-ftp-default-user login)) | |
1189 (and password | |
1190 (setq ange-ftp-default-password password)) | |
1191 (and account | |
1192 (setq ange-ftp-default-account account))))) | |
1193 (goto-char end))) | |
1194 | |
7042 | 1195 ;; Read in ~/.netrc, if one exists. If ~/.netrc file exists and has |
1196 ;; the correct permissions then extract the \`machine\', \`login\', | |
1197 ;; \`password\' and \`account\' information from within. | |
1198 | |
1106 | 1199 (defun ange-ftp-parse-netrc () |
1200 ;; We set this before actually doing it to avoid the possibility | |
1201 ;; of an infinite loop if ange-ftp-netrc-filename is an FTP file. | |
1202 (interactive) | |
11315
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
1203 (let (file attr) |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
1204 (let ((default-directory "/")) |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
1205 (setq file (ange-ftp-chase-symlinks |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
1206 (ange-ftp-real-expand-file-name ange-ftp-netrc-filename))) |
c5f81d9d417c
(ange-ftp-parse-netrc): Bind `default-directory' to
Richard M. Stallman <rms@gnu.org>
parents:
11231
diff
changeset
|
1207 (setq attr (ange-ftp-real-file-attributes file))) |
1106 | 1208 (if (and attr ; file exists. |
1209 (not (equal (nth 5 attr) ange-ftp-netrc-modtime))) ; file changed | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1210 (save-match-data |
1106 | 1211 (if (or ange-ftp-disable-netrc-security-check |
1212 (and (eq (nth 2 attr) (user-uid)) ; Same uids. | |
1213 (string-match ".r..------" (nth 8 attr)))) | |
1214 (save-excursion | |
1215 ;; we are cheating a bit here. I'm trying to do the equivalent | |
1216 ;; of find-file on the .netrc file, but then nuke it afterwards. | |
1217 ;; with the bit of logic below we should be able to have | |
1218 ;; encrypted .netrc files. | |
1219 (set-buffer (generate-new-buffer "*ftp-.netrc*")) | |
1220 (ange-ftp-real-insert-file-contents file) | |
1221 (setq buffer-file-name file) | |
1222 (setq default-directory (file-name-directory file)) | |
1223 (normal-mode t) | |
1224 (mapcar 'funcall find-file-hooks) | |
1225 (setq buffer-file-name nil) | |
1226 (goto-char (point-min)) | |
8397
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1227 (skip-chars-forward " \t\n") |
1106 | 1228 (while (not (eobp)) |
1229 (ange-ftp-parse-netrc-group)) | |
1230 (kill-buffer (current-buffer))) | |
1231 (ange-ftp-message "%s either not owned by you or badly protected." | |
1232 ange-ftp-netrc-filename) | |
1233 (sit-for 1)) | |
1234 (setq ange-ftp-netrc-modtime (nth 5 attr)))))) | |
1235 | |
7042 | 1236 ;; Return a list of prefixes of the form 'user@host:' to be used when |
1237 ;; completion is done in the root directory. | |
1238 | |
1106 | 1239 (defun ange-ftp-generate-root-prefixes () |
1240 (ange-ftp-parse-netrc) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1241 (save-match-data |
1106 | 1242 (let (res) |
1243 (ange-ftp-map-hashtable | |
1244 (function | |
1245 (lambda (key value) | |
1246 (if (string-match "^[^/]*\\(/\\).*$" key) | |
1247 (let ((host (substring key 0 (match-beginning 1))) | |
1248 (user (substring key (match-end 1)))) | |
1249 (setq res (cons (list (concat user "@" host ":")) | |
1250 res)))))) | |
1251 ange-ftp-passwd-hashtable) | |
1252 (ange-ftp-map-hashtable | |
1253 (function (lambda (host user) | |
1254 (setq res (cons (list (concat host ":")) | |
1255 res)))) | |
1256 ange-ftp-user-hashtable) | |
1257 (or res (list nil))))) | |
1258 | |
1259 ;;;; ------------------------------------------------------------ | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1260 ;;;; Remote file name syntax support. |
1106 | 1261 ;;;; ------------------------------------------------------------ |
1262 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1263 (defmacro ange-ftp-ftp-name-component (n ns name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1264 "Extract the Nth ftp file name component from NS." |
1106 | 1265 (` (let ((elt (nth (, n) (, ns)))) |
1266 (if (match-beginning elt) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1267 (substring (, name) (match-beginning elt) (match-end elt)))))) |
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 (defvar ange-ftp-ftp-name-arg "") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1270 (defvar ange-ftp-ftp-name-res nil) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1271 |
7042 | 1272 ;; Parse NAME according to `ange-ftp-name-format' (which see). |
1273 ;; Returns a list (HOST USER NAME), or nil if NAME does not match the format. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1274 (defun ange-ftp-ftp-name (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1275 (if (string-equal name ange-ftp-ftp-name-arg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1276 ange-ftp-ftp-name-res |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1277 (setq ange-ftp-ftp-name-arg name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1278 ange-ftp-ftp-name-res |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1279 (save-match-data |
13311
f760b9b1cfc7
(ange-ftp-ftp-name,ange-ftp-replace-name-component): Use posix-string-match
Erik Naggum <erik@naggum.no>
parents:
13278
diff
changeset
|
1280 (if (posix-string-match (car ange-ftp-name-format) name) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1281 (let* ((ns (cdr ange-ftp-name-format)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1282 (host (ange-ftp-ftp-name-component 0 ns name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1283 (user (ange-ftp-ftp-name-component 1 ns name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1284 (name (ange-ftp-ftp-name-component 2 ns name))) |
1106 | 1285 (if (zerop (length user)) |
1286 (setq user (ange-ftp-get-user host))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1287 (list host user name)) |
1106 | 1288 nil))))) |
1289 | |
7042 | 1290 ;; Take a FULLNAME that matches according to ange-ftp-name-format and |
1291 ;; replace the name component with NAME. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1292 (defun ange-ftp-replace-name-component (fullname name) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1293 (save-match-data |
13311
f760b9b1cfc7
(ange-ftp-ftp-name,ange-ftp-replace-name-component): Use posix-string-match
Erik Naggum <erik@naggum.no>
parents:
13278
diff
changeset
|
1294 (if (posix-string-match (car ange-ftp-name-format) fullname) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1295 (let* ((ns (cdr ange-ftp-name-format)) |
1106 | 1296 (elt (nth 2 ns))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1297 (concat (substring fullname 0 (match-beginning elt)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1298 name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1299 (substring fullname (match-end elt))))))) |
1106 | 1300 |
1301 ;;;; ------------------------------------------------------------ | |
1302 ;;;; Miscellaneous utils. | |
1303 ;;;; ------------------------------------------------------------ | |
1304 | |
1305 ;; (setq ange-ftp-tmp-keymap (make-sparse-keymap)) | |
1306 ;; (define-key ange-ftp-tmp-keymap "\C-m" 'exit-minibuffer) | |
1307 | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1308 (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
|
1309 "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
|
1310 (message nil)) |
1106 | 1311 |
7042 | 1312 ;; Return the name of the buffer that collects output from the ftp process |
1313 ;; connected to the given HOST and USER pair. | |
1106 | 1314 (defun ange-ftp-ftp-process-buffer (host user) |
1315 (concat "*ftp " user "@" host "*")) | |
1316 | |
7042 | 1317 ;; Display the last chunk of output from the ftp process for the given HOST |
1318 ;; USER pair, and signal an error including MSG in the text. | |
1106 | 1319 (defun ange-ftp-error (host user msg) |
1320 (let ((cur (selected-window)) | |
1321 (pop-up-windows t)) | |
1322 (pop-to-buffer | |
1323 (get-buffer-create | |
1324 (ange-ftp-ftp-process-buffer host user))) | |
1325 (goto-char (point-max)) | |
1326 (select-window cur)) | |
1327 (signal 'ftp-error (list (format "FTP Error: %s" msg)))) | |
1328 | |
1329 (defun ange-ftp-set-buffer-mode () | |
3230
103f34320cb5
(ange-ftp-dired-compress-file):
Richard M. Stallman <rms@gnu.org>
parents:
3000
diff
changeset
|
1330 "Set correct modes for the current buffer if visiting a remote file." |
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)) |
10407
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
1333 (auto-save-mode ange-ftp-auto-save))) |
1106 | 1334 |
1335 (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
|
1336 "Kill the FTP process associated with BUFFER. |
1233 | 1337 If the BUFFER's visited filename or default-directory is an ftp filename |
1106 | 1338 then kill the related ftp process." |
1339 (interactive "bKill FTP process associated with buffer: ") | |
1340 (if (null buffer) | |
1341 (setq buffer (current-buffer))) | |
1342 (let ((file (or (buffer-file-name) default-directory))) | |
1343 (if file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1344 (let ((parsed (ange-ftp-ftp-name (expand-file-name file)))) |
1106 | 1345 (if parsed |
1346 (let ((host (nth 0 parsed)) | |
1347 (user (nth 1 parsed))) | |
1348 (kill-buffer (ange-ftp-ftp-process-buffer host user)))))))) | |
1349 | |
1350 (defun ange-ftp-quote-string (string) | |
1351 "Quote any characters in STRING that may confuse the ftp process." | |
1352 (apply (function concat) | |
1353 (mapcar (function | |
1354 (lambda (char) | |
1355 (if (or (<= char ? ) | |
1356 (> char ?\~) | |
1357 (= char ?\") | |
1358 (= char ?\\)) | |
1359 (vector ?\\ char) | |
1360 (vector char)))) | |
1361 string))) | |
1362 | |
1363 (defun ange-ftp-barf-if-not-directory (directory) | |
1364 (or (file-directory-p directory) | |
1365 (signal 'file-error | |
1366 (list "Opening directory" | |
1367 (if (file-exists-p directory) | |
1368 "not a directory" | |
1369 "no such file or directory") | |
1370 directory)))) | |
1371 | |
1372 ;;;; ------------------------------------------------------------ | |
1373 ;;;; FTP process filter support. | |
1374 ;;;; ------------------------------------------------------------ | |
1375 | |
1376 (defun ange-ftp-process-handle-line (line proc) | |
7042 | 1377 "Look at the given LINE from the ftp process PROC. |
1378 Try to categorize it into one of four categories: | |
1379 good, skip, fatal, or unknown." | |
1106 | 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)) | |
9664 | 1392 ;; Check this before checking for errors. |
1393 ;; Otherwise the last line of these three seems to be an error: | |
1394 ;; 230-see a significant impact from the move. For those of you who can't | |
1395 ;; 230-use DNS to resolve hostnames and get an error message like | |
1396 ;; 230-"ftp.stsci.edu: unknown host", the new IP address will be... | |
9662
ca4987708cc0
(ange-ftp-process-handle-line): Check for a
Richard M. Stallman <rms@gnu.org>
parents:
9627
diff
changeset
|
1397 ((string-match ange-ftp-multi-msgs line) |
ca4987708cc0
(ange-ftp-process-handle-line): Check for a
Richard M. Stallman <rms@gnu.org>
parents:
9627
diff
changeset
|
1398 (setq ange-ftp-process-multi-skip t)) |
1106 | 1399 ((string-match ange-ftp-fatal-msgs line) |
1400 (delete-process proc) | |
1401 (setq ange-ftp-process-busy nil | |
1402 ange-ftp-process-result-line line)) | |
1403 (ange-ftp-process-multi-skip | |
1404 t) | |
1405 (t | |
1406 (setq ange-ftp-process-busy nil | |
1407 ange-ftp-process-result-line line)))) | |
1408 | |
1409 (defun ange-ftp-set-xfer-size (host user bytes) | |
1410 "Set the size of the next FTP transfer in bytes." | |
1411 (let ((proc (ange-ftp-get-process host user))) | |
1412 (if proc | |
1413 (let ((buf (process-buffer proc))) | |
1414 (if buf | |
1415 (save-excursion | |
1416 (set-buffer buf) | |
1417 (setq ange-ftp-xfer-size (ash bytes -10)))))))) | |
1418 | |
1419 (defun ange-ftp-process-handle-hash (str) | |
1420 "Remove hash marks from STRING and display count so far." | |
1421 (setq str (concat (substring str 0 (match-beginning 0)) | |
1422 (substring str (match-end 0))) | |
1423 ange-ftp-hash-mark-count (+ (- (match-end 0) | |
1424 (match-beginning 0)) | |
1425 ange-ftp-hash-mark-count)) | |
13594
b7cb31d324cf
(ange-ftp-process-handle-hash): If
Richard M. Stallman <rms@gnu.org>
parents:
13311
diff
changeset
|
1426 (and ange-ftp-hash-mark-unit |
b7cb31d324cf
(ange-ftp-process-handle-hash): If
Richard M. Stallman <rms@gnu.org>
parents:
13311
diff
changeset
|
1427 ange-ftp-process-msg |
1106 | 1428 ange-ftp-process-verbose |
1429 (not (eq (selected-window) (minibuffer-window))) | |
1430 (not (boundp 'search-message)) ;screws up isearch otherwise | |
1431 (not cursor-in-echo-area) ;screws up y-or-n-p otherwise | |
1432 (let ((kbytes (ash (* ange-ftp-hash-mark-unit | |
1433 ange-ftp-hash-mark-count) | |
1434 -6))) | |
1435 (if (zerop ange-ftp-xfer-size) | |
1436 (ange-ftp-message "%s...%dk" ange-ftp-process-msg kbytes) | |
1437 (let ((percent (/ (* 100 kbytes) ange-ftp-xfer-size))) | |
1438 ;; cut out the redisplay of identical %-age messages. | |
1439 (if (not (eq percent ange-ftp-last-percent)) | |
1440 (progn | |
1441 (setq ange-ftp-last-percent percent) | |
1442 (ange-ftp-message "%s...%d%%" ange-ftp-process-msg percent))))))) | |
1443 str) | |
1444 | |
7042 | 1445 ;; Call the function specified by CONT. CONT can be either a function |
1446 ;; or a list of a function and some args. The first two parameters | |
1447 ;; passed to the function will be RESULT and LINE. The remaining args | |
1448 ;; will be taken from CONT if a list was passed. | |
1449 | |
1106 | 1450 (defun ange-ftp-call-cont (cont result line) |
1451 (if cont | |
1452 (if (and (listp cont) | |
1453 (not (eq (car cont) 'lambda))) | |
1454 (apply (car cont) result line (cdr cont)) | |
1455 (funcall cont result line)))) | |
1456 | |
7042 | 1457 ;; Build up a complete line of output from the ftp PROCESS and pass it |
1458 ;; on to ange-ftp-process-handle-line to deal with. | |
1459 | |
1106 | 1460 (defun ange-ftp-process-filter (proc str) |
1461 (let ((buffer (process-buffer proc)) | |
1462 (old-buffer (current-buffer))) | |
1463 | |
1464 ;; see if the buffer is still around... it could have been deleted. | |
1465 (if (buffer-name buffer) | |
1466 (unwind-protect | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1467 (progn |
1106 | 1468 (set-buffer (process-buffer proc)) |
1469 | |
1470 ;; handle hash mark printing | |
13594
b7cb31d324cf
(ange-ftp-process-handle-hash): If
Richard M. Stallman <rms@gnu.org>
parents:
13311
diff
changeset
|
1471 (and ange-ftp-process-busy |
1106 | 1472 (string-match "^#+$" str) |
1473 (setq str (ange-ftp-process-handle-hash str))) | |
6822
69c4ca88cf5e
(ange-ftp-process-filter, ange-ftp-gwp-filter): Call comint-output-filter.
Karl Heuer <kwzh@gnu.org>
parents:
6309
diff
changeset
|
1474 (comint-output-filter proc str) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1475 ;; Replace STR by the result of the comint processing. |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1476 (setq str (buffer-substring comint-last-output-start |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1477 (process-mark proc))) |
1106 | 1478 (if ange-ftp-process-busy |
1479 (progn | |
1480 (setq ange-ftp-process-string (concat ange-ftp-process-string | |
1481 str)) | |
1482 | |
1483 ;; if we gave an empty password to the USER command earlier | |
1484 ;; then we should send a null password now. | |
1485 (if (string-match "Password: *$" ange-ftp-process-string) | |
1486 (send-string proc "\n")))) | |
1487 (while (and ange-ftp-process-busy | |
1488 (string-match "\n" ange-ftp-process-string)) | |
1489 (let ((line (substring ange-ftp-process-string | |
1490 0 | |
1491 (match-beginning 0)))) | |
1492 (setq ange-ftp-process-string (substring ange-ftp-process-string | |
1493 (match-end 0))) | |
1494 (while (string-match "^ftp> *" line) | |
1495 (setq line (substring line (match-end 0)))) | |
1496 (ange-ftp-process-handle-line line proc))) | |
1497 | |
1498 ;; has the ftp client finished? if so then do some clean-up | |
1499 ;; actions. | |
1500 (if (not ange-ftp-process-busy) | |
1501 (progn | |
1502 ;; reset the xfer size | |
1503 (setq ange-ftp-xfer-size 0) | |
1504 | |
1505 ;; issue the "done" message since we've finished. | |
1506 (if (and ange-ftp-process-msg | |
1507 ange-ftp-process-verbose | |
1508 ange-ftp-process-result) | |
1509 (progn | |
1510 (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
|
1511 (ange-ftp-repaint-minibuffer) |
1106 | 1512 (setq ange-ftp-process-msg nil))) |
1513 | |
1514 ;; is there a continuation we should be calling? if so, | |
1515 ;; we'd better call it, making sure we only call it once. | |
1516 (if ange-ftp-process-continue | |
1517 (let ((cont ange-ftp-process-continue)) | |
1518 (setq ange-ftp-process-continue nil) | |
1519 (ange-ftp-call-cont cont | |
1520 ange-ftp-process-result | |
1521 ange-ftp-process-result-line)))))) | |
1522 (set-buffer old-buffer))))) | |
1523 | |
1524 (defun ange-ftp-process-sentinel (proc str) | |
1525 "When ftp process changes state, nuke all file-entries in cache." | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1526 (let ((name (process-name proc))) |
13311
f760b9b1cfc7
(ange-ftp-ftp-name,ange-ftp-replace-name-component): Use posix-string-match
Erik Naggum <erik@naggum.no>
parents:
13278
diff
changeset
|
1527 (if (string-match "\\*ftp \\([^@]+\\)@\\([^*]+\\)\\*" name) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1528 (let ((user (substring name (match-beginning 1) (match-end 1))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1529 (host (substring name (match-beginning 2) (match-end 2)))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1530 (ange-ftp-wipe-file-entries host user)))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1531 (setq ange-ftp-ls-cache-file nil)) |
1106 | 1532 |
1533 ;;;; ------------------------------------------------------------ | |
1534 ;;;; Gateway support. | |
1535 ;;;; ------------------------------------------------------------ | |
1536 | |
1537 (defun ange-ftp-use-gateway-p (host) | |
1538 "Returns whether to access this host via a normal (non-smart) gateway." | |
1539 ;; yes, I know that I could simplify the following expression, but it is | |
1540 ;; clearer (to me at least) this way. | |
1541 (and (not ange-ftp-smart-gateway) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1542 (save-match-data |
1106 | 1543 (not (string-match ange-ftp-local-host-regexp host))))) |
1544 | |
1545 (defun ange-ftp-use-smart-gateway-p (host) | |
1546 "Returns whether to access this host via a smart gateway." | |
1547 (and ange-ftp-smart-gateway | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1548 (save-match-data |
1106 | 1549 (not (string-match ange-ftp-local-host-regexp host))))) |
1550 | |
1551 | |
1552 ;;; ------------------------------------------------------------ | |
1553 ;;; Temporary file location and deletion... | |
1554 ;;; ------------------------------------------------------------ | |
1555 | |
1556 (defvar ange-ftp-tmp-name-files ()) | |
1557 (defvar ange-ftp-tmp-name-hashtable (ange-ftp-make-hashtable 10)) | |
1558 (defvar ange-ftp-pid nil) | |
1559 | |
1560 (defun ange-ftp-get-pid () | |
1561 "Half-hearted attempt to get the current process's id." | |
1562 (setq ange-ftp-pid (substring (make-temp-name "") 1))) | |
1563 | |
1564 (defun ange-ftp-make-tmp-name (host) | |
1565 "This routine will return the name of a new file." | |
1566 (let* ((template (if (ange-ftp-use-gateway-p host) | |
1567 ange-ftp-gateway-tmp-name-template | |
1568 ange-ftp-tmp-name-template)) | |
1569 (pid (or ange-ftp-pid (ange-ftp-get-pid))) | |
1570 (start ?a) | |
1571 file entry) | |
1572 (while | |
1573 (progn | |
1574 (setq file (format "%s%c%s" template start pid)) | |
1575 (setq entry (intern file ange-ftp-tmp-name-hashtable)) | |
1576 (or (memq entry ange-ftp-tmp-name-files) | |
1577 (ange-ftp-real-file-exists-p file))) | |
1578 (if (> (setq start (1+ start)) ?z) | |
1579 (progn | |
1580 (setq template (concat template "X")) | |
1581 (setq start ?a)))) | |
1582 (setq ange-ftp-tmp-name-files | |
1583 (cons entry ange-ftp-tmp-name-files)) | |
1584 file)) | |
1585 | |
1586 (defun ange-ftp-del-tmp-name (temp) | |
1587 (setq ange-ftp-tmp-name-files | |
1588 (delq (intern temp ange-ftp-tmp-name-hashtable) | |
1589 ange-ftp-tmp-name-files)) | |
1590 (condition-case () | |
1591 (ange-ftp-real-delete-file temp) | |
1592 (error nil))) | |
1593 | |
1594 ;;;; ------------------------------------------------------------ | |
1595 ;;;; Interactive gateway program support. | |
1596 ;;;; ------------------------------------------------------------ | |
1597 | |
1598 (defvar ange-ftp-gwp-running t) | |
1599 (defvar ange-ftp-gwp-status nil) | |
1600 | |
1601 (defun ange-ftp-gwp-sentinel (proc str) | |
1602 (setq ange-ftp-gwp-running nil)) | |
1603 | |
1604 (defun ange-ftp-gwp-filter (proc str) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1605 (comint-output-filter proc str) |
13005
35c7fa318961
(ange-ftp-gwp-filter): Go to process buffer before getting text from it.
Richard M. Stallman <rms@gnu.org>
parents:
12977
diff
changeset
|
1606 (save-excursion |
35c7fa318961
(ange-ftp-gwp-filter): Go to process buffer before getting text from it.
Richard M. Stallman <rms@gnu.org>
parents:
12977
diff
changeset
|
1607 (set-buffer (process-buffer proc)) |
35c7fa318961
(ange-ftp-gwp-filter): Go to process buffer before getting text from it.
Richard M. Stallman <rms@gnu.org>
parents:
12977
diff
changeset
|
1608 ;; Replace STR by the result of the comint processing. |
35c7fa318961
(ange-ftp-gwp-filter): Go to process buffer before getting text from it.
Richard M. Stallman <rms@gnu.org>
parents:
12977
diff
changeset
|
1609 (setq str (buffer-substring comint-last-output-start (process-mark proc)))) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1610 (cond ((string-match "login: *$" str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1611 (send-string proc |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1612 (concat |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1613 (let ((ange-ftp-default-user t)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1614 (ange-ftp-get-user ange-ftp-gateway-host)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1615 "\n"))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1616 ((string-match "Password: *$" str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1617 (send-string proc |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1618 (concat |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1619 (ange-ftp-get-passwd ange-ftp-gateway-host |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1620 (ange-ftp-get-user |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1621 ange-ftp-gateway-host)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1622 "\n"))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1623 ((string-match ange-ftp-gateway-fatal-msgs str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1624 (delete-process proc) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1625 (setq ange-ftp-gwp-running nil)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1626 ((string-match ange-ftp-gateway-prompt-pattern str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1627 (setq ange-ftp-gwp-running nil |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1628 ange-ftp-gwp-status t)))) |
1106 | 1629 |
1630 (defun ange-ftp-gwp-start (host user name args) | |
1631 "Login to the gateway machine and fire up an ftp process." | |
1632 (let* ((gw-user (ange-ftp-get-user ange-ftp-gateway-host)) | |
7042 | 1633 ;; It would be nice to make process-connection-type nil, |
1634 ;; but that doesn't work: ftp never responds. | |
1635 ;; Can anyone find a fix for that? | |
1636 (proc (let ((process-connection-type t)) | |
7664
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1637 (start-process name name |
7042 | 1638 ange-ftp-gateway-program |
1639 ange-ftp-gateway-host))) | |
1106 | 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)) | |
7664
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1644 (save-excursion |
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1645 (set-buffer (process-buffer proc)) |
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1646 (internal-ange-ftp-mode) |
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1647 (set-marker (process-mark proc) (point))) |
1106 | 1648 (setq ange-ftp-gwp-running t |
1649 ange-ftp-gwp-status nil) | |
1650 (ange-ftp-message "Connecting to gateway %s..." ange-ftp-gateway-host) | |
1651 (while ange-ftp-gwp-running ;perform login sequence | |
1652 (accept-process-output proc)) | |
1653 (if (not ange-ftp-gwp-status) | |
1654 (ange-ftp-error host user "unable to login to gateway")) | |
1655 (ange-ftp-message "Connecting to gateway %s...done" ange-ftp-gateway-host) | |
1656 (setq ange-ftp-gwp-running t | |
1657 ange-ftp-gwp-status nil) | |
1658 (process-send-string proc ange-ftp-gateway-setup-term-command) | |
1659 (while ange-ftp-gwp-running ;zap ^M's and double echoing. | |
1660 (accept-process-output proc)) | |
1661 (if (not ange-ftp-gwp-status) | |
1662 (ange-ftp-error host user "unable to set terminal modes on gateway")) | |
1663 (setq ange-ftp-gwp-running t | |
1664 ange-ftp-gwp-status nil) | |
1665 (process-send-string proc (concat "exec " ftp "\n")) ;spawn ftp process | |
1666 proc)) | |
1667 | |
1668 ;;;; ------------------------------------------------------------ | |
1669 ;;;; Support for sending commands to the ftp process. | |
1670 ;;;; ------------------------------------------------------------ | |
1671 | |
1672 (defun ange-ftp-raw-send-cmd (proc cmd &optional msg cont nowait) | |
1673 "Low-level routine to send the given ftp CMD to the ftp PROCESS. | |
1674 MSG is an optional message to output before and after the command. | |
1675 If CONT is non-NIL then it is either a function or a list of function and | |
1676 some arguments. The function will be called when the ftp command has completed. | |
1677 If CONT is NIL then this routine will return \( RESULT . LINE \) where RESULT | |
1678 is whether the command was successful, and LINE is the line from the FTP | |
1679 process that caused the command to complete. | |
1680 If NOWAIT is given then the routine will return immediately the command has | |
1681 been queued with no result. CONT will still be called, however." | |
1682 (if (memq (process-status proc) '(run open)) | |
1683 (save-excursion | |
1684 (set-buffer (process-buffer proc)) | |
1685 (while ange-ftp-process-busy | |
3000
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1686 ;; This is a kludge to let user quit in case ftp gets hung. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1687 ;; It matters because this function can be called from the filter. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1688 ;; It is bad to allow quitting in a filter, but getting hung |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1689 ;; is worse. By binding quit-flag to nil, we might avoid |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1690 ;; most of the probability of getting screwed because the user |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1691 ;; wants to quit some command. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1692 (let ((quit-flag nil) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1693 (inhibit-quit nil)) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1694 (accept-process-output))) |
1106 | 1695 (setq ange-ftp-process-string "" |
1696 ange-ftp-process-result-line "" | |
1697 ange-ftp-process-busy t | |
1698 ange-ftp-process-result nil | |
1699 ange-ftp-process-multi-skip nil | |
1700 ange-ftp-process-msg msg | |
1701 ange-ftp-process-continue cont | |
1702 ange-ftp-hash-mark-count 0 | |
1703 ange-ftp-last-percent -1 | |
1704 cmd (concat cmd "\n")) | |
1705 (and msg ange-ftp-process-verbose (ange-ftp-message "%s..." msg)) | |
1706 (goto-char (point-max)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1707 (move-marker comint-last-input-start (point)) |
1106 | 1708 ;; don't insert the password into the buffer on the USER command. |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1709 (save-match-data |
1106 | 1710 (if (string-match "^user \"[^\"]*\"" cmd) |
1711 (insert (substring cmd 0 (match-end 0)) " Turtle Power!\n") | |
1712 (insert cmd))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1713 (move-marker comint-last-input-end (point)) |
1106 | 1714 (send-string proc cmd) |
1715 (set-marker (process-mark proc) (point)) | |
1716 (if nowait | |
1717 nil | |
1718 ;; hang around for command to complete | |
1719 (while ange-ftp-process-busy | |
3000
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1720 ;; This is a kludge to let user quit in case ftp gets hung. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1721 ;; It matters because this function can be called from the filter. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1722 (let ((quit-flag nil) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1723 (inhibit-quit nil)) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1724 (accept-process-output proc))) |
1106 | 1725 (if cont |
1726 nil ;cont has already been called | |
1727 (cons ange-ftp-process-result ange-ftp-process-result-line)))))) | |
1728 | |
1729 (defun ange-ftp-nslookup-host (host) | |
1730 "Attempt to resolve the given HOSTNAME using nslookup if possible." | |
1731 (interactive "sHost: ") | |
1732 (if ange-ftp-nslookup-program | |
6192
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1733 (let ((default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1734 (if (file-accessible-directory-p default-directory) |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1735 default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1736 exec-directory)) |
7042 | 1737 ;; It would be nice to make process-connection-type nil, |
1738 ;; but that doesn't work: ftp never responds. | |
1739 ;; Can anyone find a fix for that? | |
1740 (proc (let ((process-connection-type t)) | |
1741 (start-process " *nslookup*" " *nslookup*" | |
1742 ange-ftp-nslookup-program host))) | |
1106 | 1743 (res host)) |
1744 (process-kill-without-query proc) | |
1745 (save-excursion | |
1746 (set-buffer (process-buffer proc)) | |
1747 (while (memq (process-status proc) '(run open)) | |
1748 (accept-process-output proc)) | |
1749 (goto-char (point-min)) | |
1750 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t) | |
1751 (setq res (buffer-substring (match-beginning 1) | |
1752 (match-end 1)))) | |
1753 (kill-buffer (current-buffer))) | |
1754 res) | |
1755 host)) | |
1756 | |
1757 (defun ange-ftp-start-process (host user name) | |
1758 "Spawn a new ftp process ready to connect to machine HOST and give it NAME. | |
1759 If HOST is only ftp-able through a gateway machine then spawn a shell | |
1760 on the gateway machine to do the ftp instead." | |
1761 (let* ((use-gateway (ange-ftp-use-gateway-p host)) | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1762 (use-smart-ftp (and (not ange-ftp-gateway-host) |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1763 (ange-ftp-use-smart-gateway-p host))) |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1764 (ftp-prog (if (or use-gateway |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1765 use-smart-ftp) |
1106 | 1766 ange-ftp-gateway-ftp-program-name |
1767 ange-ftp-ftp-program-name)) | |
1768 (args (append (list ftp-prog) ange-ftp-ftp-program-args)) | |
7418
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1769 ;; Without the following binding, ange-ftp-start-process |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1770 ;; recurses on file-accessible-directory-p, since it needs to |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1771 ;; restart its process in order to determine anything about |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1772 ;; default-directory. |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1773 (file-name-handler-alist) |
6192
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1774 (default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1775 (if (file-accessible-directory-p default-directory) |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1776 default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1777 exec-directory)) |
1106 | 1778 proc) |
7042 | 1779 ;; It would be nice to make process-connection-type nil, |
1780 ;; but that doesn't work: ftp never responds. | |
1781 ;; Can anyone find a fix for that? | |
13789
7ccb22bca972
(ange-ftp-load): Added missing form to `cdr' down
Karl Heuer <kwzh@gnu.org>
parents:
13594
diff
changeset
|
1782 (let ((process-connection-type t) |
7ccb22bca972
(ange-ftp-load): Added missing form to `cdr' down
Karl Heuer <kwzh@gnu.org>
parents:
13594
diff
changeset
|
1783 (process-environment process-environment)) |
7ccb22bca972
(ange-ftp-load): Added missing form to `cdr' down
Karl Heuer <kwzh@gnu.org>
parents:
13594
diff
changeset
|
1784 ;; This tells GNU ftp not to output any fancy escape sequences. |
7ccb22bca972
(ange-ftp-load): Added missing form to `cdr' down
Karl Heuer <kwzh@gnu.org>
parents:
13594
diff
changeset
|
1785 (setenv "TERM" "dumb") |
7042 | 1786 (if use-gateway |
1787 (if ange-ftp-gateway-program-interactive | |
1788 (setq proc (ange-ftp-gwp-start host user name args)) | |
1789 (setq proc (apply 'start-process name name | |
1790 (append (list ange-ftp-gateway-program | |
1791 ange-ftp-gateway-host) | |
1792 args)))) | |
1793 (setq proc (apply 'start-process name name args)))) | |
1106 | 1794 (process-kill-without-query proc) |
1795 (save-excursion | |
1796 (set-buffer (process-buffer proc)) | |
3502
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1797 (internal-ange-ftp-mode)) |
1106 | 1798 (set-process-sentinel proc (function ange-ftp-process-sentinel)) |
1799 (set-process-filter proc (function ange-ftp-process-filter)) | |
1800 (accept-process-output proc) ;wait for ftp startup message | |
1801 proc)) | |
1802 | |
3502
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1803 (defun internal-ange-ftp-mode () |
7113
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1804 "Major mode for interacting with the FTP process. |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1805 |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1806 \\{comint-mode-map}" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1807 (interactive) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1808 (comint-mode) |
3502
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1809 (setq major-mode 'internal-ange-ftp-mode) |
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1810 (setq mode-name "Internal Ange-ftp") |
1106 | 1811 (let ((proc (get-buffer-process (current-buffer)))) |
1812 (goto-char (point-max)) | |
1813 (set-marker (process-mark proc) (point)) | |
1814 (make-local-variable 'ange-ftp-process-string) | |
1815 (setq ange-ftp-process-string "") | |
1816 (make-local-variable 'ange-ftp-process-busy) | |
1817 (make-local-variable 'ange-ftp-process-result) | |
1818 (make-local-variable 'ange-ftp-process-msg) | |
1819 (make-local-variable 'ange-ftp-process-multi-skip) | |
1820 (make-local-variable 'ange-ftp-process-result-line) | |
1821 (make-local-variable 'ange-ftp-process-continue) | |
1822 (make-local-variable 'ange-ftp-hash-mark-count) | |
1823 (make-local-variable 'ange-ftp-binary-hash-mark-size) | |
1824 (make-local-variable 'ange-ftp-ascii-hash-mark-size) | |
1825 (make-local-variable 'ange-ftp-hash-mark-unit) | |
1826 (make-local-variable 'ange-ftp-xfer-size) | |
1827 (make-local-variable 'ange-ftp-last-percent) | |
1828 (setq ange-ftp-hash-mark-count 0) | |
1829 (setq ange-ftp-xfer-size 0) | |
7113
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1830 (setq ange-ftp-process-result-line "") |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1831 |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1832 (setq comint-prompt-regexp "^ftp> ") |
13278
9493a12ca8a5
(internal-ange-ftp-mode):
Richard M. Stallman <rms@gnu.org>
parents:
13089
diff
changeset
|
1833 (make-local-variable 'comint-password-prompt-regexp) |
9493a12ca8a5
(internal-ange-ftp-mode):
Richard M. Stallman <rms@gnu.org>
parents:
13089
diff
changeset
|
1834 ;; This is a regexp that can't match anything. |
9493a12ca8a5
(internal-ange-ftp-mode):
Richard M. Stallman <rms@gnu.org>
parents:
13089
diff
changeset
|
1835 ;; ange-ftp has its own ways of handling passwords. |
9493a12ca8a5
(internal-ange-ftp-mode):
Richard M. Stallman <rms@gnu.org>
parents:
13089
diff
changeset
|
1836 (setq comint-password-prompt-regexp "^a\\'z") |
7113
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1837 (make-local-variable 'paragraph-start) |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1838 (setq paragraph-start comint-prompt-regexp))) |
1106 | 1839 |
1840 (defun ange-ftp-smart-login (host user pass account proc) | |
1841 "Connect to the FTP-server on HOST as USER using PASSWORD and ACCOUNT. | |
1842 PROC is the FTP-client's process. This routine uses the smart-gateway | |
1843 host specified in ``ange-ftp-gateway-host''." | |
1844 (let ((result (ange-ftp-raw-send-cmd | |
1845 proc | |
1846 (format "open %s %s" | |
1847 (ange-ftp-nslookup-host ange-ftp-gateway-host) | |
1848 ange-ftp-smart-gateway-port) | |
1849 (format "Opening FTP connection to %s via %s" | |
1850 host | |
1851 ange-ftp-gateway-host)))) | |
1852 (or (car result) | |
1853 (ange-ftp-error host user | |
1854 (concat "OPEN request failed: " | |
1855 (cdr result)))) | |
1856 (setq result (ange-ftp-raw-send-cmd | |
1857 proc (format "user \"%s\"@%s %s %s" | |
1858 user | |
1859 (ange-ftp-nslookup-host host) | |
1860 pass | |
1861 account) | |
1862 (format "Logging in as user %s@%s" | |
1863 user host))) | |
1864 (or (car result) | |
1865 (progn | |
1866 (ange-ftp-set-passwd host user nil) ; reset password | |
1867 (ange-ftp-set-account host user nil) ; reset account | |
1868 (ange-ftp-error host user | |
1869 (concat "USER request failed: " | |
1870 (cdr result))))))) | |
1871 | |
1872 (defun ange-ftp-normal-login (host user pass account proc) | |
1873 "Connect to the FTP-server on HOST as USER using PASSWORD and ACCOUNT. | |
1874 PROC is the process to the FTP-client." | |
12441
597f9723ddf6
(ange-ftp-normal-login): if ange-ftp-smart-gateway
Richard M. Stallman <rms@gnu.org>
parents:
11315
diff
changeset
|
1875 (let* ((nshost (ange-ftp-nslookup-host host)) |
597f9723ddf6
(ange-ftp-normal-login): if ange-ftp-smart-gateway
Richard M. Stallman <rms@gnu.org>
parents:
11315
diff
changeset
|
1876 (result (ange-ftp-raw-send-cmd |
1106 | 1877 proc |
12441
597f9723ddf6
(ange-ftp-normal-login): if ange-ftp-smart-gateway
Richard M. Stallman <rms@gnu.org>
parents:
11315
diff
changeset
|
1878 (format "open %s" nshost) |
1106 | 1879 (format "Opening FTP connection to %s" host)))) |
1880 (or (car result) | |
1881 (ange-ftp-error host user | |
1882 (concat "OPEN request failed: " | |
1883 (cdr result)))) | |
1884 (setq result (ange-ftp-raw-send-cmd | |
1885 proc | |
12441
597f9723ddf6
(ange-ftp-normal-login): if ange-ftp-smart-gateway
Richard M. Stallman <rms@gnu.org>
parents:
11315
diff
changeset
|
1886 (if (ange-ftp-use-smart-gateway-p host) |
597f9723ddf6
(ange-ftp-normal-login): if ange-ftp-smart-gateway
Richard M. Stallman <rms@gnu.org>
parents:
11315
diff
changeset
|
1887 (format "user \"%s\"@%s %s %s" user nshost pass account) |
597f9723ddf6
(ange-ftp-normal-login): if ange-ftp-smart-gateway
Richard M. Stallman <rms@gnu.org>
parents:
11315
diff
changeset
|
1888 (format "user \"%s\" %s %s" user pass account)) |
1106 | 1889 (format "Logging in as user %s@%s" user host))) |
1890 (or (car result) | |
1891 (progn | |
1892 (ange-ftp-set-passwd host user nil) ;reset password. | |
1893 (ange-ftp-set-account host user nil) ;reset account. | |
1894 (ange-ftp-error host user | |
1895 (concat "USER request failed: " | |
1896 (cdr result))))))) | |
1897 | |
5480
f193f880c524
(ange-ftp-hash-mark-msgs): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5350
diff
changeset
|
1898 ;; ange@hplb.hpl.hp.com says this should not be changed. |
1106 | 1899 (defvar ange-ftp-hash-mark-msgs |
5480
f193f880c524
(ange-ftp-hash-mark-msgs): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5350
diff
changeset
|
1900 "[hH]ash mark [^0-9]*\\([0-9]+\\)" |
1106 | 1901 "*Regexp matching the FTP client's output upon doing a HASH command.") |
1902 | |
1903 (defun ange-ftp-guess-hash-mark-size (proc) | |
1904 (if ange-ftp-send-hash | |
1905 (save-excursion | |
1906 (set-buffer (process-buffer proc)) | |
1907 (let* ((status (ange-ftp-raw-send-cmd proc "hash")) | |
1908 (result (car status)) | |
1909 (line (cdr status))) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1910 (save-match-data |
1106 | 1911 (if (string-match ange-ftp-hash-mark-msgs line) |
1912 (let ((size (string-to-int | |
1913 (substring line | |
1914 (match-beginning 1) | |
1915 (match-end 1))))) | |
1916 (setq ange-ftp-ascii-hash-mark-size size | |
1917 ange-ftp-hash-mark-unit (ash size -4)) | |
1918 | |
1919 ;; if a default value for this is set, use that value. | |
1920 (or ange-ftp-binary-hash-mark-size | |
1921 (setq ange-ftp-binary-hash-mark-size size))))))))) | |
1922 | |
1923 (defun ange-ftp-get-process (host user) | |
7042 | 1924 "Return an FTP subprocess connected to HOST and logged in as USER. |
1925 Create a new process if needed." | |
1106 | 1926 (let* ((name (ange-ftp-ftp-process-buffer host user)) |
1927 (proc (get-process name))) | |
1928 (if (and proc (memq (process-status proc) '(run open))) | |
1929 proc | |
1930 (let ((pass (ange-ftp-quote-string | |
1931 (ange-ftp-get-passwd host user))) | |
1932 (account (ange-ftp-quote-string | |
1933 (ange-ftp-get-account host user)))) | |
1934 ;; grab a suitable process. | |
1935 (setq proc (ange-ftp-start-process host user name)) | |
1936 | |
1937 ;; login to FTP server. | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1938 (if (and (ange-ftp-use-smart-gateway-p host) |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1939 ange-ftp-gateway-host) |
1106 | 1940 (ange-ftp-smart-login host user pass account proc) |
1941 (ange-ftp-normal-login host user pass account proc)) | |
1942 | |
1943 ;; Tell client to send back hash-marks as progress. It isn't usually | |
1944 ;; fatal if this command fails. | |
1945 (ange-ftp-guess-hash-mark-size proc) | |
1946 | |
1947 ;; Guess at the host type. | |
1948 (ange-ftp-guess-host-type host user) | |
1949 | |
1950 ;; Run any user-specified hooks. Note that proc, host and user are | |
1951 ;; dynamically bound at this point. | |
1952 (run-hooks 'ange-ftp-process-startup-hook)) | |
1953 proc))) | |
1954 | |
1955 ;; Variables for caching host and host-type | |
1956 (defvar ange-ftp-host-cache nil) | |
1957 (defvar ange-ftp-host-type-cache nil) | |
1958 | |
1959 ;; If ange-ftp-host-type is called with the optional user | |
1960 ;; argument, it will attempt to guess the host type by connecting | |
1961 ;; as user, if necessary. For efficiency, I have tried to give this | |
1962 ;; optional second argument only when necessary. Have I missed any calls | |
1963 ;; to ange-ftp-host-type where it should have been supplied? | |
1964 | |
1965 (defun ange-ftp-host-type (host &optional user) | |
1966 "Return a symbol which represents the type of the HOST given. | |
1967 If the optional argument USER is given, attempts to guess the | |
1968 host-type by logging in as USER." | |
1969 (if (eq host ange-ftp-host-cache) | |
1970 ange-ftp-host-type-cache | |
1971 ;; Trigger an ftp connection, in case we need to guess at the host type. | |
1972 (if (and user (ange-ftp-get-process host user) (eq host ange-ftp-host-cache)) | |
1973 ange-ftp-host-type-cache | |
1974 (setq ange-ftp-host-cache host | |
1975 ange-ftp-host-type-cache | |
1976 (cond ((ange-ftp-dumb-unix-host host) | |
1977 'dumb-unix) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1978 ;; ((and (fboundp 'ange-ftp-vos-host) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1979 ;; (ange-ftp-vos-host host)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1980 ;; 'vos) |
1106 | 1981 ((and (fboundp 'ange-ftp-vms-host) |
1982 (ange-ftp-vms-host host)) | |
1983 'vms) | |
1984 ((and (fboundp 'ange-ftp-mts-host) | |
1985 (ange-ftp-mts-host host)) | |
1986 'mts) | |
1987 ((and (fboundp 'ange-ftp-cms-host) | |
1988 (ange-ftp-cms-host host)) | |
1989 'cms) | |
1990 (t | |
1991 'unix)))))) | |
1992 | |
1993 ;; It would be nice to abstract the functions ange-ftp-TYPE-host and | |
1994 ;; ange-ftp-add-TYPE-host. The trick is to abstract these functions | |
1995 ;; without sacrificing speed. Also, having separate variables | |
1996 ;; ange-ftp-TYPE-regexp is more user friendly then requiring the user to | |
1997 ;; set an alist to indicate that a host is of a given type. Even with | |
1998 ;; automatic host type recognition, setting a regexp is still a good idea | |
1999 ;; (for efficiency) if you log into a particular non-UNIX host frequently. | |
2000 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2001 (defvar ange-ftp-fix-name-func-alist nil |
7042 | 2002 "Alist saying how to convert file name to the host's syntax. |
2003 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
|
2004 which can change a UNIX file name into a name more suitable for a host of type |
1106 | 2005 TYPE.") |
2006 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2007 (defvar ange-ftp-fix-dir-name-func-alist nil |
7042 | 2008 "Alist saying how to convert directory name to the host's syntax. |
2009 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
|
2010 which can change UNIX directory name into a directory name more suitable |
1106 | 2011 for a host of type TYPE.") |
2012 | |
2013 ;; *** Perhaps the sense of this variable should be inverted, since there | |
2014 ;; *** is only 1 host type that can take ls-style listing options. | |
2015 (defvar ange-ftp-dumb-host-types '(dumb-unix) | |
2016 "List of host types that can't take UNIX ls-style listing options.") | |
2017 | |
2018 (defun ange-ftp-send-cmd (host user cmd &optional msg cont nowait) | |
2019 "Find an ftp process connected to HOST logged in as USER and send it CMD. | |
2020 MSG is an optional status message to be output before and after issuing the | |
2021 command. | |
2022 See the documentation for ange-ftp-raw-send-cmd for a description of CONT | |
2023 and NOWAIT." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2024 ;; Handle conversion to remote file name syntax and remote ls option |
1106 | 2025 ;; capability. |
2026 (let ((cmd0 (car cmd)) | |
2027 (cmd1 (nth 1 cmd)) | |
4498
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2028 (ange-ftp-this-user user) |
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2029 (ange-ftp-this-host host) |
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2030 (ange-ftp-this-msg msg) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2031 cmd2 cmd3 host-type fix-name-func) |
1106 | 2032 |
2033 (cond | |
2034 | |
2035 ;; pwd case (We don't care what host-type.) | |
2036 ((null cmd1)) | |
2037 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2038 ;; cmd == 'dir "remote-name" "local-name" "ls-switches" |
1106 | 2039 ((progn |
2040 (setq cmd2 (nth 2 cmd) | |
2041 host-type (ange-ftp-host-type host user)) | |
2042 ;; This will trigger an FTP login, if one doesn't exist | |
2043 (eq cmd0 'dir)) | |
2044 (setq cmd1 (funcall | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2045 (or (cdr (assq host-type ange-ftp-fix-dir-name-func-alist)) |
1106 | 2046 'identity) |
2047 cmd1) | |
2048 cmd3 (nth 3 cmd)) | |
2049 ;; Need to deal with the HP-UX ftp bug. This should also allow | |
2050 ;; us to resolve symlinks to directories on SysV machines. (Sebastian will | |
2051 ;; be happy.) | |
2052 (and (eq host-type 'unix) | |
2053 (string-match "/$" cmd1) | |
2054 (not (string-match "R" cmd3)) | |
2055 (setq cmd1 (concat cmd1 "."))) | |
2056 ;; If the remote ls can take switches, put them in | |
2057 (or (memq host-type ange-ftp-dumb-host-types) | |
2058 (setq cmd0 'ls | |
2059 cmd1 (format "\"%s %s\"" cmd3 cmd1)))) | |
2060 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2061 ;; First argument is the remote name |
4498
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2062 ((progn |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2063 (setq fix-name-func (or (cdr (assq host-type |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2064 ange-ftp-fix-name-func-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2065 'identity)) |
1106 | 2066 (memq cmd0 '(get delete mkdir rmdir cd))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2067 (setq cmd1 (funcall fix-name-func cmd1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2068 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2069 ;; Second argument is the remote name |
1106 | 2070 ((memq cmd0 '(append put chmod)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2071 (setq cmd2 (funcall fix-name-func cmd2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2072 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2073 ;; Both arguments are remote names |
1106 | 2074 ((eq cmd0 'rename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2075 (setq cmd1 (funcall fix-name-func cmd1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2076 cmd2 (funcall fix-name-func cmd2)))) |
1106 | 2077 |
2078 ;; Turn the command into one long string | |
2079 (setq cmd0 (symbol-name cmd0)) | |
2080 (setq cmd (concat cmd0 | |
2081 (and cmd1 (concat " " cmd1)) | |
2082 (and cmd2 (concat " " cmd2)))) | |
2083 | |
2084 ;; Actually send the resulting command. | |
2085 (let (afsc-result | |
2086 afsc-line) | |
2087 (ange-ftp-raw-send-cmd | |
2088 (ange-ftp-get-process host user) | |
2089 cmd | |
2090 msg | |
2091 (list | |
2092 (function (lambda (result line host user | |
2093 cmd msg cont nowait) | |
2094 (or cont | |
2095 (setq afsc-result result | |
2096 afsc-line line)) | |
2097 (if result | |
2098 (ange-ftp-call-cont cont result line) | |
2099 (ange-ftp-raw-send-cmd | |
2100 (ange-ftp-get-process host user) | |
2101 cmd | |
2102 msg | |
2103 (list | |
2104 (function (lambda (result line cont) | |
2105 (or cont | |
2106 (setq afsc-result result | |
2107 afsc-line line)) | |
2108 (ange-ftp-call-cont cont result line))) | |
2109 cont) | |
2110 nowait)))) | |
2111 host user cmd msg cont nowait) | |
2112 nowait) | |
2113 | |
2114 (if nowait | |
2115 nil | |
2116 (if cont | |
2117 nil | |
2118 (cons afsc-result afsc-line)))))) | |
2119 | |
2120 ;; It might be nice to message users about the host type identified, | |
2121 ;; but there is so much other messaging going on, it would not be | |
2122 ;; seen. No point in slowing things down just so users can read | |
2123 ;; a host type message. | |
2124 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2125 (defconst ange-ftp-cms-name-template |
1106 | 2126 (concat |
2127 "^[-A-Z0-9$*][-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?" | |
2128 "[-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
|
2129 (defconst ange-ftp-vms-name-template |
1106 | 2130 "^[-A-Z0-9_$]+:\\[[-A-Z0-9_$]+\\(\\.[-A-Z0-9_$]+\\)*\\]$") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2131 (defconst ange-ftp-mts-name-template |
1106 | 2132 "^[A-Z0-9._][A-Z0-9._][A-Z0-9._][A-Z0-9._]:$") |
2133 | |
2134 (defun ange-ftp-guess-host-type (host user) | |
7042 | 2135 "Guess at the the host type of HOST. |
2136 Works by doing a pwd and examining the directory syntax." | |
1106 | 2137 (let ((host-type (ange-ftp-host-type host)) |
2138 (key (concat host "/" user "/~"))) | |
2139 (if (eq host-type 'unix) | |
2140 ;; Note that ange-ftp-host-type returns unix as the default value. | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2141 (save-match-data |
1106 | 2142 (let* ((result (ange-ftp-get-pwd host user)) |
2143 (dir (car result)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2144 fix-name-func) |
1106 | 2145 (cond ((null dir) |
2146 (message "Warning! Unable to get home directory") | |
2147 (sit-for 1) | |
2148 (if (string-match | |
2149 "^450 No current working directory defined$" | |
2150 (cdr result)) | |
2151 | |
2152 ;; We'll assume that if pwd bombs with this | |
2153 ;; error message, then it's CMS. | |
2154 (progn | |
2155 (ange-ftp-add-cms-host host) | |
2156 (setq ange-ftp-host-cache host | |
2157 ange-ftp-host-type-cache 'cms)))) | |
2158 | |
2159 ;; try for VMS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2160 ((string-match ange-ftp-vms-name-template dir) |
1106 | 2161 (ange-ftp-add-vms-host host) |
2162 ;; The add-host functions clear the host type cache. | |
2163 ;; Therefore, need to set the cache afterwards. | |
2164 (setq ange-ftp-host-cache host | |
2165 ange-ftp-host-type-cache 'vms)) | |
2166 | |
2167 ;; try for MTS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2168 ((string-match ange-ftp-mts-name-template dir) |
1106 | 2169 (ange-ftp-add-mts-host host) |
2170 (setq ange-ftp-host-cache host | |
2171 ange-ftp-host-type-cache 'mts)) | |
2172 | |
2173 ;; try for CMS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2174 ((string-match ange-ftp-cms-name-template dir) |
1106 | 2175 (ange-ftp-add-cms-host host) |
2176 (setq ange-ftp-host-cache host | |
2177 ange-ftp-host-type-cache 'cms)) | |
2178 | |
2179 ;; assume UN*X | |
2180 (t | |
2181 (setq ange-ftp-host-cache host | |
2182 ange-ftp-host-type-cache 'unix))) | |
2183 | |
2184 ;; Now that we have done a pwd, might as well put it in | |
2185 ;; the expand-dir hashtable. | |
2186 (let ((ange-ftp-this-user user) | |
2187 (ange-ftp-this-host host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2188 (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
|
2189 ange-ftp-fix-name-func-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2190 (if fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2191 (setq dir (funcall fix-name-func dir 'reverse)))) |
1106 | 2192 (ange-ftp-put-hash-entry key dir |
2193 ange-ftp-expand-dir-hashtable)))) | |
2194 | |
2195 ;; In the special case of CMS make sure that know the | |
2196 ;; expansion of the home minidisk now, because we will | |
2197 ;; be doing a lot of cd's. | |
2198 (if (and (eq host-type 'cms) | |
2199 (not (ange-ftp-hash-entry-exists-p | |
2200 key ange-ftp-expand-dir-hashtable))) | |
2201 (let ((dir (car (ange-ftp-get-pwd host user)))) | |
2202 (if dir | |
2203 (ange-ftp-put-hash-entry key (concat "/" dir) | |
2204 ange-ftp-expand-dir-hashtable) | |
2205 (message "Warning! Unable to get home directory") | |
2206 (sit-for 1)))))) | |
2207 | |
2208 | |
2209 ;;;; ------------------------------------------------------------ | |
2210 ;;;; Remote file and directory listing support. | |
2211 ;;;; ------------------------------------------------------------ | |
2212 | |
7042 | 2213 ;; Returns whether HOST's FTP server doesn't like \'ls\' or \'dir\' commands |
2214 ;; to take switch arguments. | |
1106 | 2215 (defun ange-ftp-dumb-unix-host (host) |
13089
c18fa2e296f9
(ange-ftp-dumb-unix-host): Avoid error if HOST is nil.
Richard M. Stallman <rms@gnu.org>
parents:
13005
diff
changeset
|
2216 (and host ange-ftp-dumb-unix-host-regexp |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2217 (save-match-data |
1106 | 2218 (string-match ange-ftp-dumb-unix-host-regexp host)))) |
2219 | |
2220 (defun ange-ftp-add-dumb-unix-host (host) | |
2221 "Interactively adds a given HOST to ange-ftp-dumb-unix-host-regexp." | |
2222 (interactive | |
2223 (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
|
2224 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2225 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 2226 (if (not (ange-ftp-dumb-unix-host host)) |
2227 (setq ange-ftp-dumb-unix-host-regexp | |
2228 (concat "^" (regexp-quote host) "$" | |
2229 (and ange-ftp-dumb-unix-host-regexp "\\|") | |
2230 ange-ftp-dumb-unix-host-regexp) | |
2231 ange-ftp-host-cache nil))) | |
2232 | |
2233 (defvar ange-ftp-parse-list-func-alist nil | |
7042 | 2234 "Alist saying how to parse directory listings for certain OS types. |
2235 Association list of \( TYPE \. FUNC \) pairs. The FUNC is a routine | |
1106 | 2236 which can parse the output from a DIR listing for a host of type TYPE.") |
2237 | |
2238 ;; With no-error nil, this function returns: | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2239 ;; an error if file is not an ange-ftp-name |
1106 | 2240 ;; (This should never happen.) |
2241 ;; an error if either the listing is unreadable or there is an ftp error. | |
2242 ;; the listing (a string), if everything works. | |
2243 ;; | |
2244 ;; With no-error t, it returns: | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2245 ;; an error if not an ange-ftp-name |
14040 | 2246 ;; error if listing is unreadable (most likely caused by a slow connection) |
1106 | 2247 ;; nil if ftp error (this is because although asking to list a nonexistent |
2248 ;; directory on a remote unix machine usually (except | |
2249 ;; maybe for dumb hosts) returns an ls error, but no | |
2250 ;; ftp error, if the same is done on a VMS machine, | |
2251 ;; an ftp error is returned. Need to trap the error | |
2252 ;; so we can go on and try to list the parent.) | |
2253 ;; the listing, if everything works. | |
2254 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2255 ;; 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
|
2256 ;; 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
|
2257 ;; of FILE within the directory specified by `default-directory'. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2258 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2259 (defun ange-ftp-ls (file lsargs parse &optional no-error wildcard) |
1106 | 2260 "Return the output of an `DIR' or `ls' command done over ftp. |
2261 FILE is the full name of the remote file, LSARGS is any args to pass to the | |
2262 `ls' command, and PARSE specifies that the output should be parsed and stored | |
2263 away in the internal cache." | |
2264 ;; If parse is t, we assume that file is a directory. i.e. we only parse | |
2265 ;; full directory listings. | |
2266 (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
|
2267 (parsed (ange-ftp-ftp-name ange-ftp-this-file))) |
1106 | 2268 (if parsed |
2269 (let* ((host (nth 0 parsed)) | |
2270 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2271 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2272 (key (directory-file-name ange-ftp-this-file)) |
2273 (host-type (ange-ftp-host-type host user)) | |
2274 (dumb (memq host-type ange-ftp-dumb-host-types)) | |
2275 result | |
2276 temp | |
2277 lscmd parse-func) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2278 (if (string-equal name "") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2279 (setq name |
1106 | 2280 (ange-ftp-real-file-name-as-directory |
2281 (ange-ftp-expand-dir host user "~")))) | |
2282 (if (and ange-ftp-ls-cache-file | |
2283 (string-equal key ange-ftp-ls-cache-file) | |
2284 ;; Don't care about lsargs for dumb hosts. | |
2285 (or dumb (string-equal lsargs ange-ftp-ls-cache-lsargs))) | |
2286 ange-ftp-ls-cache-res | |
2287 (setq temp (ange-ftp-make-tmp-name host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2288 (if wildcard |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2289 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2290 (ange-ftp-cd host user (file-name-directory name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2291 (setq lscmd (list 'dir file temp lsargs))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2292 (setq lscmd (list 'dir name temp lsargs))) |
1106 | 2293 (unwind-protect |
2294 (if (car (setq result (ange-ftp-send-cmd | |
2295 host | |
2296 user | |
2297 lscmd | |
2298 (format "Listing %s" | |
2299 (ange-ftp-abbreviate-filename | |
2300 ange-ftp-this-file))))) | |
2301 (save-excursion | |
2302 (set-buffer (get-buffer-create | |
2303 ange-ftp-data-buffer-name)) | |
2304 (erase-buffer) | |
2305 (if (ange-ftp-real-file-readable-p temp) | |
2306 (ange-ftp-real-insert-file-contents temp) | |
2307 (sleep-for ange-ftp-retry-time) | |
2308 ;wait for file to possibly appear | |
2309 (if (ange-ftp-real-file-readable-p temp) | |
2310 ;; Try again. | |
2311 (ange-ftp-real-insert-file-contents temp) | |
2312 (ange-ftp-error host user | |
2313 (format | |
2314 "list data file %s not readable" | |
2315 temp)))) | |
2316 (if parse | |
2317 (ange-ftp-set-files | |
2318 ange-ftp-this-file | |
2319 (if (setq | |
2320 parse-func | |
2321 (cdr (assq host-type | |
2322 ange-ftp-parse-list-func-alist))) | |
2323 (funcall parse-func) | |
2324 (ange-ftp-parse-dired-listing lsargs)))) | |
2325 (setq ange-ftp-ls-cache-file key | |
2326 ange-ftp-ls-cache-lsargs lsargs | |
2327 ; For dumb hosts-types this is | |
2328 ; meaningless but harmless. | |
2329 ange-ftp-ls-cache-res (buffer-string)) | |
2330 ;; (kill-buffer (current-buffer)) | |
2331 ange-ftp-ls-cache-res) | |
2332 (if no-error | |
2333 nil | |
2334 (ange-ftp-error host user | |
2335 (concat "DIR failed: " (cdr result))))) | |
2336 (ange-ftp-del-tmp-name temp)))) | |
2337 (error "Should never happen. Please report. Bug ref. no.: 1")))) | |
2338 | |
2339 ;;;; ------------------------------------------------------------ | |
2340 ;;;; Directory information caching support. | |
2341 ;;;; ------------------------------------------------------------ | |
2342 | |
2343 (defconst ange-ftp-date-regexp | |
2344 (concat | |
2345 " \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct" | |
2346 "\\|Nov\\|Dec\\) +[0-3]?[0-9] ")) | |
2347 | |
2348 (defvar ange-ftp-add-file-entry-alist nil | |
7043
acf840ff5c1c
(ange-ftp-add-file-entry-alist): Fix typo in prev change.
Richard M. Stallman <rms@gnu.org>
parents:
7042
diff
changeset
|
2349 "Alist saying how to add file entries on certain OS types. |
7042 | 2350 Association list of pairs \( TYPE \. FUNC \), where FUNC |
1106 | 2351 is a function to be used to add a file entry for the OS TYPE. The |
2352 main reason for this alist is to deal with file versions in VMS.") | |
2353 | |
2354 (defvar ange-ftp-delete-file-entry-alist nil | |
7042 | 2355 "Alist saying how to delete files on certain OS types. |
2356 Association list of pairs \( TYPE \. FUNC \), where FUNC | |
1106 | 2357 is a function to be used to delete a file entry for the OS TYPE. |
7042 | 2358 The main reason for this alist is to deal with file versions in VMS.") |
1106 | 2359 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2360 (defun ange-ftp-add-file-entry (name &optional dir-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2361 "Add a file entry for file NAME, if its directory info exists." |
1106 | 2362 (funcall (or (cdr (assq (ange-ftp-host-type |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2363 (car (ange-ftp-ftp-name name))) |
1106 | 2364 ange-ftp-add-file-entry-alist)) |
2365 'ange-ftp-internal-add-file-entry) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2366 name dir-p) |
1106 | 2367 (setq ange-ftp-ls-cache-file nil)) |
2368 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2369 (defun ange-ftp-delete-file-entry (name &optional dir-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2370 "Delete the file entry for file NAME, if its directory info exists." |
1106 | 2371 (funcall (or (cdr (assq (ange-ftp-host-type |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2372 (car (ange-ftp-ftp-name name))) |
1106 | 2373 ange-ftp-delete-file-entry-alist)) |
2374 'ange-ftp-internal-delete-file-entry) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2375 name dir-p) |
1106 | 2376 (setq ange-ftp-ls-cache-file nil)) |
2377 | |
2378 (defmacro ange-ftp-parse-filename () | |
2379 ;;Extract the filename from the current line of a dired-like listing. | |
2380 (` (let ((eol (progn (end-of-line) (point)))) | |
2381 (beginning-of-line) | |
2382 (if (re-search-forward ange-ftp-date-regexp eol t) | |
2383 (progn | |
2384 (skip-chars-forward " ") | |
2385 (skip-chars-forward "^ " eol) | |
2386 (skip-chars-forward " " eol) | |
2387 ;; We bomb on filenames starting with a space. | |
2388 (buffer-substring (point) eol)))))) | |
2389 | |
2390 ;; This deals with the F switch. Should also do something about | |
2391 ;; unquoting names obtained with the SysV b switch and the GNU Q | |
2392 ;; switch. See Sebastian's dired-get-filename. | |
2393 | |
2394 (defmacro ange-ftp-ls-parser () | |
2395 ;; Note that switches is dynamically bound. | |
2396 ;; Meant to be called by ange-ftp-parse-dired-listing | |
2397 (` (let ((tbl (ange-ftp-make-hashtable)) | |
2398 (used-F (and (stringp switches) | |
2399 (string-match "F" switches))) | |
2400 file-type symlink directory file) | |
2401 (while (setq file (ange-ftp-parse-filename)) | |
2402 (beginning-of-line) | |
2403 (skip-chars-forward "\t 0-9") | |
2404 (setq file-type (following-char) | |
2405 directory (eq file-type ?d)) | |
2406 (if (eq file-type ?l) | |
2407 (if (string-match " -> " file) | |
2408 (setq symlink (substring file (match-end 0)) | |
2409 file (substring file 0 (match-beginning 0))) | |
2410 ;; Shouldn't happen | |
2411 (setq symlink "")) | |
2412 (setq symlink nil)) | |
2413 ;; Only do a costly regexp search if the F switch was used. | |
2414 (if (and used-F | |
2415 (not (string-equal file "")) | |
2416 (looking-at | |
2417 ".[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)")) | |
2418 (let ((socket (eq file-type ?s)) | |
2419 (executable | |
2420 (and (not symlink) ; x bits don't mean a thing for symlinks | |
2421 (string-match "[xst]" | |
2422 (concat | |
2423 (buffer-substring | |
2424 (match-beginning 1) | |
2425 (match-end 1)) | |
2426 (buffer-substring | |
2427 (match-beginning 2) | |
2428 (match-end 2)) | |
2429 (buffer-substring | |
2430 (match-beginning 3) | |
2431 (match-end 3))))))) | |
2432 ;; Some ls's with the F switch mark symlinks with an @ (ULTRIX) | |
2433 ;; and others don't. (sigh...) Beware, that some Unix's don't | |
2434 ;; seem to believe in the F-switch | |
2435 (if (or (and symlink (string-match "@$" file)) | |
2436 (and directory (string-match "/$" file)) | |
2437 (and executable (string-match "*$" file)) | |
2438 (and socket (string-match "=$" file))) | |
2439 (setq file (substring file 0 -1))))) | |
2440 (ange-ftp-put-hash-entry file (or symlink directory) tbl) | |
2441 (forward-line 1)) | |
2442 (ange-ftp-put-hash-entry "." t tbl) | |
2443 (ange-ftp-put-hash-entry ".." t tbl) | |
2444 tbl))) | |
2445 | |
2446 ;;; The dl stuff for descriptive listings | |
2447 | |
2448 (defvar ange-ftp-dl-dir-regexp nil | |
7042 | 2449 "Regexp matching directories which are listed in dl format. |
2450 This regexp should not be anchored with a trailing `$', because it should | |
2451 match subdirectories as well.") | |
1106 | 2452 |
2453 (defun ange-ftp-add-dl-dir (dir) | |
1233 | 2454 "Interactively adds a DIR to ange-ftp-dl-dir-regexp." |
1106 | 2455 (interactive |
2456 (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
|
2457 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2458 (and name (ange-ftp-ftp-name name) |
1106 | 2459 (file-name-directory name)))))) |
2460 (if (not (and ange-ftp-dl-dir-regexp | |
2461 (string-match ange-ftp-dl-dir-regexp dir))) | |
2462 (setq ange-ftp-dl-dir-regexp | |
2463 (concat "^" (regexp-quote dir) | |
2464 (and ange-ftp-dl-dir-regexp "\\|") | |
2465 ange-ftp-dl-dir-regexp)))) | |
2466 | |
2467 (defmacro ange-ftp-dl-parser () | |
2468 ;; Parse the current buffer, which is assumed to be a descriptive | |
2469 ;; listing, and return a hashtable. | |
2470 (` (let ((tbl (ange-ftp-make-hashtable))) | |
2471 (while (not (eobp)) | |
2472 (ange-ftp-put-hash-entry | |
2473 (buffer-substring (point) | |
2474 (progn | |
2475 (skip-chars-forward "^ /\n") | |
2476 (point))) | |
2477 (eq (following-char) ?/) | |
2478 tbl) | |
2479 (forward-line 1)) | |
2480 (ange-ftp-put-hash-entry "." t tbl) | |
2481 (ange-ftp-put-hash-entry ".." t tbl) | |
2482 tbl))) | |
2483 | |
7042 | 2484 ;; Parse the current buffer which is assumed to be in a dired-like listing |
2485 ;; format, and return a hashtable as the result. If the listing is not really | |
2486 ;; a listing, then return nil. | |
2487 | |
1106 | 2488 (defun ange-ftp-parse-dired-listing (&optional switches) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2489 (save-match-data |
1106 | 2490 (cond |
2491 ((looking-at "^total [0-9]+$") | |
2492 (forward-line 1) | |
5067
4854aff5c5b3
(ange-ftp-parse-dired-listing): Skip extra blank line
Richard M. Stallman <rms@gnu.org>
parents:
4912
diff
changeset
|
2493 ;; Some systems put in a blank line here. |
4854aff5c5b3
(ange-ftp-parse-dired-listing): Skip extra blank line
Richard M. Stallman <rms@gnu.org>
parents:
4912
diff
changeset
|
2494 (if (eolp) (forward-line 1)) |
1106 | 2495 (ange-ftp-ls-parser)) |
2496 ((looking-at "[^\n]+\\( not found\\|: Not a directory\\)\n\\'") | |
2497 ;; It's an ls error message. | |
2498 nil) | |
2499 ((eobp) ; i.e. (zerop (buffer-size)) | |
2500 ;; This could be one of: | |
2501 ;; (1) An Ultrix ls error message | |
2502 ;; (2) A listing with the A switch of an empty directory | |
2503 ;; on a machine which doesn't give a total line. | |
2504 ;; (3) The twilight zone. | |
2505 ;; We'll assume (1) for now. | |
2506 nil) | |
2507 ((re-search-forward ange-ftp-date-regexp nil t) | |
2508 (beginning-of-line) | |
2509 (ange-ftp-ls-parser)) | |
2510 ((re-search-forward "^[^ \n\t]+ +\\([0-9]+\\|-\\|=\\) " nil t) | |
2511 ;; It's a dl listing (I hope). | |
2512 ;; file is bound by the call to ange-ftp-ls | |
2513 (ange-ftp-add-dl-dir ange-ftp-this-file) | |
2514 (beginning-of-line) | |
2515 (ange-ftp-dl-parser)) | |
2516 (t nil)))) | |
2517 | |
2518 (defun ange-ftp-set-files (directory files) | |
2519 "For a given DIRECTORY, set or change the associated FILES hashtable." | |
2520 (and files (ange-ftp-put-hash-entry (file-name-as-directory directory) | |
2521 files ange-ftp-files-hashtable))) | |
2522 | |
2523 (defun ange-ftp-get-files (directory &optional no-error) | |
2524 "Given a given DIRECTORY, return a hashtable of file entries. | |
2525 This will give an error or return nil, depending on the value of | |
2526 NO-ERROR, if a listing for DIRECTORY cannot be obtained." | |
2527 (setq directory (file-name-as-directory directory)) ;normalize | |
2528 (or (ange-ftp-get-hash-entry directory ange-ftp-files-hashtable) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2529 (save-match-data |
1106 | 2530 (and (ange-ftp-ls directory |
2531 ;; This is an efficiency hack. We try to | |
2532 ;; anticipate what sort of listing dired | |
2533 ;; might want, and cache just such a listing. | |
2534 (if (and (boundp 'dired-actual-switches) | |
2535 (stringp dired-actual-switches) | |
2536 ;; We allow the A switch, which lists | |
2537 ;; all files except "." and "..". | |
2538 ;; This is OK because we manually | |
2539 ;; insert these entries | |
2540 ;; in the hash table. | |
2541 (string-match | |
2542 "[aA]" dired-actual-switches) | |
2543 (string-match | |
2544 "l" dired-actual-switches) | |
2545 (not (string-match | |
2546 "R" dired-actual-switches))) | |
2547 dired-actual-switches | |
2548 (if (and (boundp 'dired-listing-switches) | |
2549 (stringp dired-listing-switches) | |
2550 (string-match | |
2551 "[aA]" dired-listing-switches) | |
2552 (string-match | |
2553 "l" dired-listing-switches) | |
2554 (not (string-match | |
2555 "R" dired-listing-switches))) | |
2556 dired-listing-switches | |
2557 "-al")) | |
2558 t no-error) | |
2559 (ange-ftp-get-hash-entry | |
2560 directory ange-ftp-files-hashtable))))) | |
2561 | |
7042 | 2562 ;; Given NAME, return the file part that can be used for looking up the |
2563 ;; file's entry in a hashtable. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2564 (defmacro ange-ftp-get-file-part (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2565 (` (let ((file (file-name-nondirectory (, name)))) |
1106 | 2566 (if (string-equal file "") |
2567 "." | |
2568 file)))) | |
2569 | |
7042 | 2570 ;; Return whether ange-ftp-file-entry-p and ange-ftp-get-file-entry are |
2571 ;; allowed to determine if NAME is a sub-directory by listing it directly, | |
2572 ;; rather than listing its parent directory. This is used for efficiency so | |
2573 ;; that a wasted listing is not done: | |
2574 ;; 1. When looking for a .dired file in dired-x.el. | |
2575 ;; 2. The syntax of FILE and DIR make it impossible that FILE could be a valid | |
2576 ;; subdirectory. This is of course an OS dependent judgement. | |
2577 | |
1106 | 2578 (defmacro ange-ftp-allow-child-lookup (dir file) |
2579 (` (not | |
2580 (let* ((efile (, file)) ; expand once. | |
2581 (edir (, dir)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2582 (parsed (ange-ftp-ftp-name edir)) |
1106 | 2583 (host-type (ange-ftp-host-type |
2584 (car parsed)))) | |
2585 (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
|
2586 ;;; 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
|
2587 ;;; ;; 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
|
2588 ;;; (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
|
2589 ;;; (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
|
2590 ;;; (string-equal dired-local-variables-file efile)) |
1106 | 2591 ;; No dots in dir names in vms. |
2592 (and (eq host-type 'vms) | |
2593 (string-match "\\." efile)) | |
2594 ;; No subdirs in mts of cms. | |
2595 (and (memq host-type '(mts cms)) | |
2596 (not (string-equal "/" (nth 2 parsed))))))))) | |
2597 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2598 (defun ange-ftp-file-entry-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2599 "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
|
2600 (let* ((name (directory-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2601 (dir (file-name-directory name)) |
1106 | 2602 (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
|
2603 (file (ange-ftp-get-file-part name))) |
1106 | 2604 (if ent |
2605 (ange-ftp-hash-entry-exists-p file ent) | |
2606 (or (and (ange-ftp-allow-child-lookup dir file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2607 (setq ent (ange-ftp-get-files name t)) |
1106 | 2608 ;; Try a child lookup. i.e. try to list file as a |
2609 ;; subdirectory of dir. This is a good idea because | |
2610 ;; we may not have read permission for file's parent. Also, | |
2611 ;; people tend to work down directory trees anyway. We use | |
2612 ;; no-error ;; because if file does not exist as a subdir., | |
2613 ;; then dumb hosts will give an ftp error. Smart unix hosts | |
2614 ;; will simply send back the ls | |
2615 ;; error message. | |
2616 (ange-ftp-get-hash-entry "." ent)) | |
2617 ;; Child lookup failed. Try the parent. If this bombs, | |
2618 ;; we are at wits end -- signal an error. | |
2619 ;; Problem: If this signals an error, the error message | |
2620 ;; may not have a lot to do with what went wrong. | |
2621 (ange-ftp-hash-entry-exists-p file | |
2622 (ange-ftp-get-files dir)))))) | |
2623 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2624 (defun ange-ftp-get-file-entry (name) |
1233 | 2625 "Given NAME, return the given file entry. |
2626 The entry will be either t for a directory, nil for a normal file, | |
2627 or a string for a symlink. If the file isn't in the hashtable, | |
2628 this also returns nil." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2629 (let* ((name (directory-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2630 (dir (file-name-directory name)) |
1106 | 2631 (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
|
2632 (file (ange-ftp-get-file-part name))) |
1106 | 2633 (if ent |
2634 (ange-ftp-get-hash-entry file ent) | |
2635 (or (and (ange-ftp-allow-child-lookup dir file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2636 (setq ent (ange-ftp-get-files name t)) |
1106 | 2637 (ange-ftp-get-hash-entry "." ent)) |
2638 ;; i.e. it's a directory by child lookup | |
2639 (ange-ftp-get-hash-entry file | |
2640 (ange-ftp-get-files dir)))))) | |
2641 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2642 (defun ange-ftp-internal-delete-file-entry (name &optional dir-p) |
1106 | 2643 (if dir-p |
2644 (progn | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2645 (setq name (file-name-as-directory name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2646 (ange-ftp-del-hash-entry name ange-ftp-files-hashtable) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2647 (setq name (directory-file-name name)))) |
1106 | 2648 ;; Note that file-name-as-directory followed by directory-file-name |
2649 ;; serves to canonicalize directory file names to their unix form. | |
2650 ;; i.e. in VMS, FOO.DIR -> FOO/ -> FOO | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2651 (let ((files (ange-ftp-get-hash-entry (file-name-directory name) |
1106 | 2652 ange-ftp-files-hashtable))) |
2653 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2654 (ange-ftp-del-hash-entry (ange-ftp-get-file-part name) |
1106 | 2655 files)))) |
2656 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2657 (defun ange-ftp-internal-add-file-entry (name &optional dir-p) |
1106 | 2658 (and dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2659 (setq name (directory-file-name name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2660 (let ((files (ange-ftp-get-hash-entry (file-name-directory name) |
1106 | 2661 ange-ftp-files-hashtable))) |
2662 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2663 (ange-ftp-put-hash-entry (ange-ftp-get-file-part name) |
1106 | 2664 dir-p |
2665 files)))) | |
2666 | |
2667 (defun ange-ftp-wipe-file-entries (host user) | |
7042 | 2668 "Get rid of entry for HOST, USER pair from file entry information hashtable." |
1106 | 2669 (let ((new-tbl (ange-ftp-make-hashtable (length ange-ftp-files-hashtable)))) |
2670 (ange-ftp-map-hashtable | |
2671 (function | |
2672 (lambda (key val) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2673 (let ((parsed (ange-ftp-ftp-name key))) |
1106 | 2674 (if parsed |
2675 (let ((h (nth 0 parsed)) | |
2676 (u (nth 1 parsed))) | |
2677 (or (and (equal host h) (equal user u)) | |
2678 (ange-ftp-put-hash-entry key val new-tbl))))))) | |
2679 ange-ftp-files-hashtable) | |
2680 (setq ange-ftp-files-hashtable new-tbl))) | |
2681 | |
2682 ;;;; ------------------------------------------------------------ | |
2683 ;;;; File transfer mode support. | |
2684 ;;;; ------------------------------------------------------------ | |
2685 | |
2686 (defun ange-ftp-set-binary-mode (host user) | |
2687 "Tell the ftp process for the given HOST & USER to switch to binary mode." | |
2688 (let ((result (ange-ftp-send-cmd host user '(type "binary")))) | |
2689 (if (not (car result)) | |
2690 (ange-ftp-error host user (concat "BINARY failed: " (cdr result))) | |
2691 (save-excursion | |
2692 (set-buffer (process-buffer (ange-ftp-get-process host user))) | |
10118
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2693 (and ange-ftp-binary-hash-mark-size |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2694 (setq ange-ftp-hash-mark-unit |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2695 (ash ange-ftp-binary-hash-mark-size -4))))))) |
1106 | 2696 |
2697 (defun ange-ftp-set-ascii-mode (host user) | |
2698 "Tell the ftp process for the given HOST & USER to switch to ascii mode." | |
2699 (let ((result (ange-ftp-send-cmd host user '(type "ascii")))) | |
2700 (if (not (car result)) | |
2701 (ange-ftp-error host user (concat "ASCII failed: " (cdr result))) | |
2702 (save-excursion | |
2703 (set-buffer (process-buffer (ange-ftp-get-process host user))) | |
10118
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2704 (and ange-ftp-ascii-hash-mark-size |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2705 (setq ange-ftp-hash-mark-unit |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2706 (ash ange-ftp-ascii-hash-mark-size -4))))))) |
1106 | 2707 |
2708 (defun ange-ftp-cd (host user dir) | |
2709 (let ((result (ange-ftp-send-cmd host user (list 'cd dir) "Doing CD"))) | |
2710 (or (car result) | |
2711 (ange-ftp-error host user (concat "CD failed: " (cdr result)))))) | |
2712 | |
2713 (defun ange-ftp-get-pwd (host user) | |
2714 "Attempts to get the current working directory for the given HOST/USER pair. | |
2715 Returns \( DIR . LINE \) where DIR is either the directory or NIL if not found, | |
2716 and LINE is the relevant success or fail line from the FTP-client." | |
2717 (let* ((result (ange-ftp-send-cmd host user '(pwd) "Getting PWD")) | |
2718 (line (cdr result)) | |
2719 dir) | |
2720 (if (car result) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2721 (save-match-data |
1106 | 2722 (and (or (string-match "\"\\([^\"]*\\)\"" line) |
2723 (string-match " \\([^ ]+\\) " line)) ; stone-age VMS servers! | |
2724 (setq dir (substring line | |
2725 (match-beginning 1) | |
2726 (match-end 1)))))) | |
2727 (cons dir line))) | |
2728 | |
2729 ;;; ------------------------------------------------------------ | |
2730 ;;; expand-file-name and friends...which currently don't work | |
2731 ;;; ------------------------------------------------------------ | |
2732 | |
2733 (defun ange-ftp-expand-dir (host user dir) | |
7042 | 2734 "Return the result of doing a PWD in the current FTP session. |
2735 Use the connection to machine HOST | |
1106 | 2736 logged in as user USER and cd'd to directory DIR." |
2737 (let* ((host-type (ange-ftp-host-type host user)) | |
2738 ;; It is more efficient to call ange-ftp-host-type | |
2739 ;; before binding res, because ange-ftp-host-type sometimes | |
2740 ;; adds to the info in the expand-dir-hashtable. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2741 (fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2742 (cdr (assq host-type ange-ftp-fix-name-func-alist))) |
1106 | 2743 (key (concat host "/" user "/" dir)) |
2744 (res (ange-ftp-get-hash-entry key ange-ftp-expand-dir-hashtable))) | |
2745 (or res | |
2746 (progn | |
2747 (or | |
2748 (string-equal user "anonymous") | |
2749 (string-equal user "ftp") | |
2750 (not (eq host-type 'unix)) | |
2751 (let* ((ange-ftp-good-msgs (concat ange-ftp-expand-dir-regexp | |
2752 "\\|" | |
2753 ange-ftp-good-msgs)) | |
2754 (result (ange-ftp-send-cmd host user | |
2755 (list 'get dir "/dev/null") | |
2756 (format "expanding %s" dir))) | |
2757 (line (cdr result))) | |
2758 (setq res | |
2759 (if (string-match ange-ftp-expand-dir-regexp line) | |
2760 (substring line | |
2761 (match-beginning 1) | |
2762 (match-end 1)))))) | |
2763 (or res | |
2764 (if (string-equal dir "~") | |
2765 (setq res (car (ange-ftp-get-pwd host user))) | |
2766 (let ((home (ange-ftp-expand-dir host user "~"))) | |
2767 (unwind-protect | |
2768 (and (ange-ftp-cd host user dir) | |
2769 (setq res (car (ange-ftp-get-pwd host user)))) | |
2770 (ange-ftp-cd host user home))))) | |
2771 (if res | |
2772 (let ((ange-ftp-this-user user) | |
2773 (ange-ftp-this-host host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2774 (if fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2775 (setq res (funcall fix-name-func res 'reverse))) |
1106 | 2776 (ange-ftp-put-hash-entry |
2777 key res ange-ftp-expand-dir-hashtable))) | |
2778 res)))) | |
2779 | |
2780 (defun ange-ftp-canonize-filename (n) | |
2781 "Take a string and short-circuit //, /. and /.." | |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2782 (if (string-match "[^:]+//" n) ;don't upset Apollo users |
1106 | 2783 (setq n (substring n (1- (match-end 0))))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2784 (let ((parsed (ange-ftp-ftp-name n))) |
1106 | 2785 (if parsed |
2786 (let ((host (car parsed)) | |
2787 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2788 (name (nth 2 parsed))) |
1106 | 2789 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2790 ;; 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
|
2791 ;; replace the name component of the overall name. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2792 (cond ((string-match "^/" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2793 name) |
1106 | 2794 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2795 ;; Name starts with ~ or ~user. Resolve that part of the name |
1106 | 2796 ;; making it absolute then re-expand it. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2797 ((string-match "^~[^/]*" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2798 (let* ((tilda (substring name |
1106 | 2799 (match-beginning 0) |
2800 (match-end 0))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2801 (rest (substring name (match-end 0))) |
1106 | 2802 (dir (ange-ftp-expand-dir host user tilda))) |
2803 (if dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2804 (setq name (concat dir rest)) |
1106 | 2805 (error "User \"%s\" is not known" |
2806 (substring tilda 1))))) | |
2807 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2808 ;; relative name. Tack on homedir and re-expand. |
1106 | 2809 (t |
2810 (let ((dir (ange-ftp-expand-dir host user "~"))) | |
2811 (if dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2812 (setq name (concat |
1106 | 2813 (ange-ftp-real-file-name-as-directory dir) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2814 name)) |
1106 | 2815 (error "Unable to obtain CWD"))))) |
2816 | |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2817 ;; If name starts with //, preserve that, for apollo system. |
7923
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2818 (if (not (string-match "^//" name)) |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2819 (progn |
7923
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2820 (setq name (ange-ftp-real-expand-file-name name)) |
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2821 |
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2822 (if (string-match "^//" name) |
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2823 (setq name (substring name 1))))) |
1106 | 2824 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2825 ;; Now substitute the expanded name back into the overall filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2826 (ange-ftp-replace-name-component n name)) |
1106 | 2827 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2828 ;; non-ange-ftp name. Just expand normally. |
1106 | 2829 (if (eq (string-to-char n) ?/) |
2830 (ange-ftp-real-expand-file-name n) | |
2831 (ange-ftp-real-expand-file-name | |
2832 (ange-ftp-real-file-name-nondirectory n) | |
2833 (ange-ftp-real-file-name-directory n)))))) | |
2834 | |
2835 (defun ange-ftp-expand-file-name (name &optional default) | |
2836 "Documented as original." | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2837 (save-match-data |
1106 | 2838 (if (eq (string-to-char name) ?/) |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2839 (while (cond ((string-match "[^:]+//" name) ;don't upset Apollo users |
1106 | 2840 (setq name (substring name (1- (match-end 0))))) |
2841 ((string-match "/~" name) | |
2842 (setq name (substring name (1- (match-end 0)))))))) | |
2843 (cond ((eq (string-to-char name) ?~) | |
2844 (ange-ftp-real-expand-file-name name)) | |
2845 ((eq (string-to-char name) ?/) | |
2846 (ange-ftp-canonize-filename name)) | |
2847 ((zerop (length name)) | |
2848 (ange-ftp-canonize-filename (or default default-directory))) | |
2849 ((ange-ftp-canonize-filename | |
2850 (concat (file-name-as-directory (or default default-directory)) | |
2851 name)))))) | |
2852 | |
2853 ;;; These are problems--they are currently not enabled. | |
2854 | |
2855 (defvar ange-ftp-file-name-as-directory-alist nil | |
7042 | 2856 "Association list of \( TYPE \. FUNC \) pairs. |
1106 | 2857 FUNC converts a filename to a directory name for the operating |
2858 system TYPE.") | |
2859 | |
2860 (defun ange-ftp-file-name-as-directory (name) | |
2861 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2862 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2863 (if parsed |
2864 (if (string-equal (nth 2 parsed) "") | |
2865 name | |
2866 (funcall (or (cdr (assq | |
2867 (ange-ftp-host-type (car parsed)) | |
2868 ange-ftp-file-name-as-directory-alist)) | |
2869 'ange-ftp-real-file-name-as-directory) | |
2870 name)) | |
2871 (ange-ftp-real-file-name-as-directory name)))) | |
2872 | |
2873 (defun ange-ftp-file-name-directory (name) | |
2874 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2875 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2876 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2877 (let ((filename (nth 2 parsed))) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2878 (if (save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2879 (string-match "^~[^/]*$" filename)) |
1106 | 2880 name |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2881 (ange-ftp-replace-name-component |
1106 | 2882 name |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2883 (ange-ftp-real-file-name-directory filename)))) |
1106 | 2884 (ange-ftp-real-file-name-directory name)))) |
2885 | |
2886 (defun ange-ftp-file-name-nondirectory (name) | |
2887 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2888 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2889 (if parsed |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
2890 (let ((filename (nth 2 parsed))) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2891 (if (save-match-data |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
2892 (string-match "^~[^/]*$" filename)) |
1106 | 2893 "" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2894 (ange-ftp-real-file-name-nondirectory name))) |
1106 | 2895 (ange-ftp-real-file-name-nondirectory name)))) |
2896 | |
2897 (defun ange-ftp-directory-file-name (dir) | |
2898 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2899 (let ((parsed (ange-ftp-ftp-name dir))) |
1106 | 2900 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2901 (ange-ftp-replace-name-component |
1106 | 2902 dir |
2903 (ange-ftp-real-directory-file-name (nth 2 parsed))) | |
2904 (ange-ftp-real-directory-file-name dir)))) | |
2905 | |
2906 | |
2907 ;;; Hooks that handle Emacs primitives. | |
2908 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2909 ;; Returns non-nil if should transfer FILE in binary mode. |
1106 | 2910 (defun ange-ftp-binary-file (file) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2911 (save-match-data |
1106 | 2912 (string-match ange-ftp-binary-file-name-regexp file))) |
2913 | |
2914 (defun ange-ftp-write-region (start end filename &optional append visit) | |
2915 (setq filename (expand-file-name filename)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2916 (let ((parsed (ange-ftp-ftp-name filename))) |
1106 | 2917 (if parsed |
2918 (let* ((host (nth 0 parsed)) | |
2919 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2920 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2921 (temp (ange-ftp-make-tmp-name host)) |
10748
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
2922 (binary (or (ange-ftp-binary-file filename) |
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
2923 (eq (ange-ftp-host-type host user) 'unix))) |
1106 | 2924 (cmd (if append 'append 'put)) |
2925 (abbr (ange-ftp-abbreviate-filename filename))) | |
2926 (unwind-protect | |
2927 (progn | |
2928 (let ((executing-macro t) | |
2929 (filename (buffer-file-name)) | |
2930 (mod-p (buffer-modified-p))) | |
2931 (unwind-protect | |
2932 (ange-ftp-real-write-region start end temp nil visit) | |
2933 ;; cleanup forms | |
2934 (setq buffer-file-name filename) | |
2935 (set-buffer-modified-p mod-p))) | |
2936 (if binary | |
2937 (ange-ftp-set-binary-mode host user)) | |
2938 | |
2939 ;; tell the process filter what size the transfer will be. | |
2940 (let ((attr (file-attributes temp))) | |
2941 (if attr | |
2942 (ange-ftp-set-xfer-size host user (nth 7 attr)))) | |
2943 | |
2944 ;; put or append the file. | |
2945 (let ((result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2946 (list cmd temp name) |
1106 | 2947 (format "Writing %s" abbr)))) |
2948 (or (car result) | |
2949 (signal 'ftp-error | |
2950 (list | |
2951 "Opening output file" | |
2952 (format "FTP Error: \"%s\"" (cdr result)) | |
2953 filename))))) | |
2954 (ange-ftp-del-tmp-name temp) | |
2955 (if binary | |
2956 (ange-ftp-set-ascii-mode host user))) | |
2957 (if (eq visit t) | |
2958 (progn | |
5350
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
2959 (set-visited-file-modtime '(0 0)) |
1106 | 2960 (ange-ftp-set-buffer-mode) |
2961 (setq buffer-file-name filename) | |
2962 (set-buffer-modified-p nil))) | |
2963 (ange-ftp-message "Wrote %s" abbr) | |
2964 (ange-ftp-add-file-entry filename)) | |
2965 (ange-ftp-real-write-region start end filename append visit)))) | |
2966 | |
5984
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
2967 (defun ange-ftp-insert-file-contents (filename &optional visit beg end replace) |
1106 | 2968 (barf-if-buffer-read-only) |
2969 (setq filename (expand-file-name filename)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2970 (let ((parsed (ange-ftp-ftp-name filename))) |
1106 | 2971 (if parsed |
2972 (progn | |
2973 (if visit | |
2974 (setq buffer-file-name filename)) | |
2975 (if (or (file-exists-p filename) | |
2976 (progn | |
2977 (setq ange-ftp-ls-cache-file nil) | |
2978 (ange-ftp-del-hash-entry (file-name-directory filename) | |
2979 ange-ftp-files-hashtable) | |
2980 (file-exists-p filename))) | |
2981 (let* ((host (nth 0 parsed)) | |
2982 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2983 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2984 (temp (ange-ftp-make-tmp-name host)) |
10748
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
2985 (binary (or (ange-ftp-binary-file filename) |
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
2986 (eq (ange-ftp-host-type host user) 'unix))) |
1106 | 2987 (abbr (ange-ftp-abbreviate-filename filename)) |
2988 size) | |
2989 (unwind-protect | |
2990 (progn | |
2991 (if binary | |
2992 (ange-ftp-set-binary-mode host user)) | |
2993 (let ((result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2994 (list 'get name temp) |
1106 | 2995 (format "Retrieving %s" abbr)))) |
2996 (or (car result) | |
2997 (signal 'ftp-error | |
2998 (list | |
2999 "Opening input file" | |
3000 (format "FTP Error: \"%s\"" (cdr result)) | |
3001 filename)))) | |
3002 (if (or (ange-ftp-real-file-readable-p temp) | |
3003 (sleep-for ange-ftp-retry-time) | |
3004 ;; Wait for file to hopefully appear. | |
3005 (ange-ftp-real-file-readable-p temp)) | |
3006 (setq | |
3007 size | |
5984
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
3008 (nth 1 (ange-ftp-real-insert-file-contents |
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
3009 temp visit beg end replace))) |
1106 | 3010 (signal 'ftp-error |
3011 (list | |
3012 "Opening input file:" | |
3013 (format | |
3014 "FTP Error: %s not arrived or readable" | |
3015 filename))))) | |
3016 (if binary | |
3017 (ange-ftp-set-ascii-mode host user)) | |
3018 (ange-ftp-del-tmp-name temp)) | |
3019 (if visit | |
5350
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
3020 (progn |
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
3021 (set-visited-file-modtime '(0 0)) |
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
3022 (setq buffer-file-name filename))) |
1106 | 3023 (list filename size)) |
3024 (signal 'file-error | |
3025 (list | |
3026 "Opening input file" | |
3027 filename)))) | |
5984
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
3028 (ange-ftp-real-insert-file-contents filename visit beg end replace)))) |
1106 | 3029 |
3030 (defun ange-ftp-expand-symlink (file dir) | |
3031 (if (file-name-absolute-p file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3032 (ange-ftp-replace-name-component dir file) |
1106 | 3033 (expand-file-name file dir))) |
3034 | |
3035 (defun ange-ftp-file-symlink-p (file) | |
3036 ;; call ange-ftp-expand-file-name rather than the normal | |
3037 ;; expand-file-name to stop loops when using a package that | |
3038 ;; redefines both file-symlink-p and expand-file-name. | |
3039 (setq file (ange-ftp-expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3040 (if (ange-ftp-ftp-name file) |
1106 | 3041 (let ((file-ent |
3042 (ange-ftp-get-hash-entry | |
3043 (ange-ftp-get-file-part file) | |
3044 (ange-ftp-get-files (file-name-directory file))))) | |
3045 (if (stringp file-ent) | |
3046 (if (file-name-absolute-p file-ent) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3047 (ange-ftp-replace-name-component |
1106 | 3048 (file-name-directory file) file-ent) |
3049 file-ent))) | |
3050 (ange-ftp-real-file-symlink-p file))) | |
3051 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3052 (defun ange-ftp-file-exists-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3053 (setq name (expand-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3054 (if (ange-ftp-ftp-name name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3055 (if (ange-ftp-file-entry-p name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3056 (let ((file-ent (ange-ftp-get-file-entry name))) |
1106 | 3057 (if (stringp file-ent) |
3058 (file-exists-p | |
3059 (ange-ftp-expand-symlink file-ent | |
3060 (file-name-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3061 (directory-file-name name)))) |
1106 | 3062 t))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3063 (ange-ftp-real-file-exists-p name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3064 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3065 (defun ange-ftp-file-directory-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3066 (setq name (expand-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3067 (if (ange-ftp-ftp-name name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3068 ;; We do a file-name-as-directory on name here because some |
1106 | 3069 ;; machines (VMS) use a .DIR to indicate the filename associated |
3070 ;; with a directory. This needs to be canonicalized. | |
3071 (let ((file-ent (ange-ftp-get-file-entry | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3072 (ange-ftp-file-name-as-directory name)))) |
1106 | 3073 (if (stringp file-ent) |
3074 (file-directory-p | |
3075 (ange-ftp-expand-symlink file-ent | |
3076 (file-name-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3077 (directory-file-name name)))) |
1106 | 3078 file-ent)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3079 (ange-ftp-real-file-directory-p name))) |
1106 | 3080 |
3081 (defun ange-ftp-directory-files (directory &optional full match | |
3082 &rest v19-args) | |
3083 (setq directory (expand-file-name directory)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3084 (if (ange-ftp-ftp-name directory) |
1106 | 3085 (progn |
3086 (ange-ftp-barf-if-not-directory directory) | |
3087 (let ((tail (ange-ftp-hash-table-keys | |
3088 (ange-ftp-get-files directory))) | |
3089 files f) | |
3090 (setq directory (file-name-as-directory directory)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
3091 (save-match-data |
1106 | 3092 (while tail |
3093 (setq f (car tail) | |
3094 tail (cdr tail)) | |
3095 (if (or (not match) (string-match match f)) | |
3096 (setq files | |
3097 (cons (if full (concat directory f) f) files))))) | |
3098 (nreverse files))) | |
3099 (apply 'ange-ftp-real-directory-files directory full match v19-args))) | |
3100 | |
3101 (defun ange-ftp-file-attributes (file) | |
3102 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3103 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 3104 (if parsed |
3105 (let ((part (ange-ftp-get-file-part file)) | |
3106 (files (ange-ftp-get-files (file-name-directory file)))) | |
3107 (if (ange-ftp-hash-entry-exists-p part files) | |
3108 (let ((host (nth 0 parsed)) | |
3109 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3110 (name (nth 2 parsed)) |
1106 | 3111 (dirp (ange-ftp-get-hash-entry part files))) |
3112 (list (if (and (stringp dirp) (file-name-absolute-p dirp)) | |
3113 (ange-ftp-expand-symlink dirp | |
3114 (file-name-directory file)) | |
3115 dirp) ;0 file type | |
3116 -1 ;1 link count | |
3117 -1 ;2 uid | |
3118 -1 ;3 gid | |
3119 '(0 0) ;4 atime | |
3120 '(0 0) ;5 mtime | |
3121 '(0 0) ;6 ctime | |
3122 -1 ;7 size | |
3123 (concat (if (stringp dirp) "l" (if dirp "d" "-")) | |
3124 "?????????") ;8 mode | |
3125 nil ;9 gid weird | |
3126 ;; Hack to give remote files a unique "inode number". | |
3127 ;; It's actually the sum of the characters in its name. | |
3128 (apply '+ (nconc (mapcar 'identity host) | |
3129 (mapcar 'identity user) | |
3130 (mapcar 'identity | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3131 (directory-file-name name)))) |
1106 | 3132 -1 ;11 device number [v19 only] |
3133 )))) | |
3134 (ange-ftp-real-file-attributes file)))) | |
3135 | |
3136 (defun ange-ftp-file-writable-p (file) | |
3137 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3138 (if (ange-ftp-ftp-name file) |
1106 | 3139 (or (file-exists-p file) ;guess here for speed |
3140 (file-directory-p (file-name-directory file))) | |
3141 (ange-ftp-real-file-writable-p file))) | |
3142 | |
3143 (defun ange-ftp-file-readable-p (file) | |
3144 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3145 (if (ange-ftp-ftp-name file) |
1106 | 3146 (file-exists-p file) |
3147 (ange-ftp-real-file-readable-p file))) | |
3148 | |
4674
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3149 (defun ange-ftp-file-executable-p (file) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3150 (setq file (expand-file-name file)) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3151 (if (ange-ftp-ftp-name file) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3152 (file-exists-p file) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3153 (ange-ftp-real-file-executable-p file))) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3154 |
1106 | 3155 (defun ange-ftp-delete-file (file) |
3156 (interactive "fDelete file: ") | |
3157 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3158 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 3159 (if parsed |
3160 (let* ((host (nth 0 parsed)) | |
3161 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3162 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 3163 (abbr (ange-ftp-abbreviate-filename file)) |
3164 (result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3165 (list 'delete name) |
1106 | 3166 (format "Deleting %s" abbr)))) |
3167 (or (car result) | |
3168 (signal 'ftp-error | |
3169 (list | |
3170 "Removing old name" | |
3171 (format "FTP Error: \"%s\"" (cdr result)) | |
3172 file))) | |
3173 (ange-ftp-delete-file-entry file)) | |
3174 (ange-ftp-real-delete-file file)))) | |
3175 | |
3176 (defun ange-ftp-verify-visited-file-modtime (buf) | |
3177 (let ((name (buffer-file-name buf))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3178 (if (and (stringp name) (ange-ftp-ftp-name name)) |
1106 | 3179 t |
3180 (ange-ftp-real-verify-visited-file-modtime buf)))) | |
3181 | |
3182 ;;;; ------------------------------------------------------------ | |
3183 ;;;; File copying support... totally re-written 6/24/92. | |
3184 ;;;; ------------------------------------------------------------ | |
3185 | |
3186 (defun ange-ftp-barf-or-query-if-file-exists (absname querystring interactive) | |
3187 (if (file-exists-p absname) | |
3188 (if (not interactive) | |
3189 (signal 'file-already-exists (list absname)) | |
3190 (if (not (yes-or-no-p (format "File %s already exists; %s anyway? " | |
3191 absname querystring))) | |
3192 (signal 'file-already-exists (list absname)))))) | |
3193 | |
3194 ;; async local copy commented out for now since I don't seem to get | |
3195 ;; the process sentinel called for some processes. | |
3196 ;; | |
3197 ;; (defun ange-ftp-copy-file-locally (filename newname ok-if-already-exists | |
3198 ;; keep-date cont) | |
3199 ;; "Kludge to copy a local file and call a continuation when the copy | |
3200 ;; finishes." | |
3201 ;; ;; check to see if we can overwrite | |
3202 ;; (if (or (not ok-if-already-exists) | |
3203 ;; (numberp ok-if-already-exists)) | |
3204 ;; (ange-ftp-barf-or-query-if-file-exists newname "copy to it" | |
3205 ;; (numberp ok-if-already-exists))) | |
3206 ;; (let ((proc (start-process " *copy*" | |
3207 ;; (generate-new-buffer "*copy*") | |
3208 ;; "cp" | |
3209 ;; filename | |
3210 ;; newname)) | |
3211 ;; res) | |
3212 ;; (set-process-sentinel proc (function ange-ftp-copy-file-locally-sentinel)) | |
3213 ;; (process-kill-without-query proc) | |
3214 ;; (save-excursion | |
3215 ;; (set-buffer (process-buffer proc)) | |
3216 ;; (make-variable-buffer-local 'copy-cont) | |
3217 ;; (setq copy-cont cont)))) | |
3218 ;; | |
3219 ;; (defun ange-ftp-copy-file-locally-sentinel (proc status) | |
3220 ;; (save-excursion | |
3221 ;; (set-buffer (process-buffer proc)) | |
3222 ;; (let ((cont copy-cont) | |
3223 ;; (result (buffer-string))) | |
3224 ;; (unwind-protect | |
3225 ;; (if (and (string-equal status "finished\n") | |
3226 ;; (zerop (length result))) | |
3227 ;; (ange-ftp-call-cont cont t nil) | |
3228 ;; (ange-ftp-call-cont cont | |
3229 ;; nil | |
3230 ;; (if (zerop (length result)) | |
3231 ;; (substring status 0 -1) | |
3232 ;; (substring result 0 -1)))) | |
3233 ;; (kill-buffer (current-buffer)))))) | |
3234 | |
3235 ;; this is the extended version of ange-ftp-copy-file-internal that works | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
3236 ;; asynchronously if asked nicely. |
1106 | 3237 (defun ange-ftp-copy-file-internal (filename newname ok-if-already-exists |
3238 keep-date &optional msg cont nowait) | |
3239 (setq filename (expand-file-name filename) | |
3240 newname (expand-file-name newname)) | |
3241 | |
3242 ;; canonicalize newname if a directory. | |
3243 (if (file-directory-p newname) | |
3244 (setq newname (expand-file-name (file-name-nondirectory filename) newname))) | |
3245 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3246 (let ((f-parsed (ange-ftp-ftp-name filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3247 (t-parsed (ange-ftp-ftp-name newname))) |
1106 | 3248 |
3249 ;; local file to local file copy? | |
3250 (if (and (not f-parsed) (not t-parsed)) | |
3251 (progn | |
3252 (ange-ftp-real-copy-file filename newname ok-if-already-exists | |
3253 keep-date) | |
3254 (if cont | |
3255 (ange-ftp-call-cont cont t "Copied locally"))) | |
3256 ;; one or both files are remote. | |
3257 (let* ((f-host (and f-parsed (nth 0 f-parsed))) | |
3258 (f-user (and f-parsed (nth 1 f-parsed))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3259 (f-name (and f-parsed (ange-ftp-quote-string (nth 2 f-parsed)))) |
1106 | 3260 (f-abbr (ange-ftp-abbreviate-filename filename)) |
3261 (t-host (and t-parsed (nth 0 t-parsed))) | |
3262 (t-user (and t-parsed (nth 1 t-parsed))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3263 (t-name (and t-parsed (ange-ftp-quote-string (nth 2 t-parsed)))) |
1106 | 3264 (t-abbr (ange-ftp-abbreviate-filename newname filename)) |
3265 (binary (or (ange-ftp-binary-file filename) | |
10748
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
3266 (ange-ftp-binary-file newname) |
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
3267 (and (eq (ange-ftp-host-type f-host f-user) 'unix) |
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
3268 (eq (ange-ftp-host-type t-host t-user) 'unix)))) |
1106 | 3269 temp1 |
3270 temp2) | |
3271 | |
3272 ;; check to see if we can overwrite | |
3273 (if (or (not ok-if-already-exists) | |
3274 (numberp ok-if-already-exists)) | |
3275 (ange-ftp-barf-or-query-if-file-exists newname "copy to it" | |
3276 (numberp ok-if-already-exists))) | |
3277 | |
3278 ;; do the copying. | |
3279 (if f-parsed | |
3280 | |
3281 ;; filename was remote. | |
3282 (progn | |
3283 (if (or (ange-ftp-use-gateway-p f-host) | |
3284 t-parsed) | |
3285 ;; have to use intermediate file if we are getting via | |
3286 ;; gateway machine or we are doing a remote to remote copy. | |
3287 (setq temp1 (ange-ftp-make-tmp-name f-host))) | |
3288 | |
3289 (if binary | |
3290 (ange-ftp-set-binary-mode f-host f-user)) | |
3291 | |
3292 (ange-ftp-send-cmd | |
3293 f-host | |
3294 f-user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3295 (list 'get f-name (or temp1 newname)) |
1106 | 3296 (or msg |
3297 (if (and temp1 t-parsed) | |
3298 (format "Getting %s" f-abbr) | |
3299 (format "Copying %s to %s" f-abbr t-abbr))) | |
3300 (list (function ange-ftp-cf1) | |
3301 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3302 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3303 t-parsed t-host t-user t-name t-abbr |
1106 | 3304 temp1 temp2 cont nowait) |
3305 nowait)) | |
3306 | |
3307 ;; filename wasn't remote. newname must be remote. call the | |
3308 ;; function which does the remainder of the copying work. | |
3309 (ange-ftp-cf1 t nil | |
3310 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3311 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3312 t-parsed t-host t-user t-name t-abbr |
1106 | 3313 nil nil cont nowait)))))) |
3314 | |
3315 ;; next part of copying routine. | |
3316 (defun ange-ftp-cf1 (result line | |
3317 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3318 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3319 t-parsed t-host t-user t-name t-abbr |
1106 | 3320 temp1 temp2 cont nowait) |
3321 (if line | |
3322 ;; filename must have been remote, and we must have just done a GET. | |
3323 (unwind-protect | |
3324 (or result | |
3325 ;; GET failed for some reason. Clean up and get out. | |
3326 (progn | |
3327 (and temp1 (ange-ftp-del-tmp-name temp1)) | |
3328 (or cont | |
3329 (signal 'ftp-error (list "Opening input file" | |
3330 (format "FTP Error: \"%s\"" line) | |
3331 filename))))) | |
3332 ;; cleanup | |
3333 (if binary | |
3334 (ange-ftp-set-ascii-mode f-host f-user)))) | |
3335 | |
3336 (if result | |
3337 ;; We now have to copy either temp1 or filename to newname. | |
3338 (if t-parsed | |
3339 | |
3340 ;; newname was remote. | |
3341 (progn | |
3342 (if (ange-ftp-use-gateway-p t-host) | |
3343 (setq temp2 (ange-ftp-make-tmp-name t-host))) | |
3344 | |
3345 ;; make sure data is moved into the right place for the | |
3346 ;; outgoing transfer. gateway temporary files complicate | |
3347 ;; things nicely. | |
3348 (if temp1 | |
3349 (if temp2 | |
3350 (if (string-equal temp1 temp2) | |
3351 (setq temp1 nil) | |
3352 (ange-ftp-real-copy-file temp1 temp2 t)) | |
3353 (setq temp2 temp1 temp1 nil)) | |
3354 (if temp2 | |
3355 (ange-ftp-real-copy-file filename temp2 t))) | |
3356 | |
3357 (if binary | |
3358 (ange-ftp-set-binary-mode t-host t-user)) | |
3359 | |
3360 ;; tell the process filter what size the file is. | |
3361 (let ((attr (file-attributes (or temp2 filename)))) | |
3362 (if attr | |
3363 (ange-ftp-set-xfer-size t-host t-user (nth 7 attr)))) | |
3364 | |
3365 (ange-ftp-send-cmd | |
3366 t-host | |
3367 t-user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3368 (list 'put (or temp2 filename) t-name) |
1106 | 3369 (or msg |
3370 (if (and temp2 f-parsed) | |
3371 (format "Putting %s" newname) | |
3372 (format "Copying %s to %s" f-abbr t-abbr))) | |
3373 (list (function ange-ftp-cf2) | |
3374 newname t-host t-user binary temp1 temp2 cont) | |
3375 nowait)) | |
3376 | |
3377 ;; newname wasn't remote. | |
3378 (ange-ftp-cf2 t nil newname t-host t-user binary temp1 temp2 cont)) | |
3379 | |
3380 ;; first copy failed, tell caller | |
3381 (ange-ftp-call-cont cont result line))) | |
3382 | |
3383 ;; last part of copying routine. | |
3384 (defun ange-ftp-cf2 (result line newname t-host t-user binary temp1 temp2 cont) | |
3385 (unwind-protect | |
3386 (if line | |
3387 ;; result from doing a local to remote copy. | |
3388 (unwind-protect | |
3389 (progn | |
3390 (or result | |
3391 (or cont | |
3392 (signal 'ftp-error | |
3393 (list "Opening output file" | |
3394 (format "FTP Error: \"%s\"" line) | |
3395 newname)))) | |
3396 | |
3397 (ange-ftp-add-file-entry newname)) | |
3398 | |
3399 ;; cleanup. | |
3400 (if binary | |
3401 (ange-ftp-set-ascii-mode t-host t-user))) | |
3402 | |
3403 ;; newname was local. | |
3404 (if temp1 | |
3405 (ange-ftp-real-copy-file temp1 newname t))) | |
3406 | |
3407 ;; clean up | |
3408 (and temp1 (ange-ftp-del-tmp-name temp1)) | |
3409 (and temp2 (ange-ftp-del-tmp-name temp2)) | |
3410 (ange-ftp-call-cont cont result line))) | |
3411 | |
3412 (defun ange-ftp-copy-file (filename newname &optional ok-if-already-exists | |
3413 keep-date) | |
3414 (interactive "fCopy file: \nFCopy %s to file: \np") | |
3415 (ange-ftp-copy-file-internal filename | |
3416 newname | |
3417 ok-if-already-exists | |
3418 keep-date | |
3419 nil | |
3420 nil | |
3421 (interactive-p))) | |
3422 | |
3423 ;;;; ------------------------------------------------------------ | |
3424 ;;;; File renaming support. | |
3425 ;;;; ------------------------------------------------------------ | |
3426 | |
10748
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
3427 (defun ange-ftp-rename-remote-to-remote (filename newname f-parsed t-parsed) |
1106 | 3428 "Rename remote file FILE to remote file NEWNAME." |
3429 (let ((f-host (nth 0 f-parsed)) | |
3430 (f-user (nth 1 f-parsed)) | |
3431 (t-host (nth 0 t-parsed)) | |
3432 (t-user (nth 1 t-parsed))) | |
3433 (if (and (string-equal f-host t-host) | |
3434 (string-equal f-user t-user)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3435 (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
|
3436 (t-name (ange-ftp-quote-string (nth 2 t-parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3437 (cmd (list 'rename f-name t-name)) |
1106 | 3438 (fabbr (ange-ftp-abbreviate-filename filename)) |
3439 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3440 (result (ange-ftp-send-cmd f-host f-user cmd | |
3441 (format "Renaming %s to %s" | |
3442 fabbr | |
3443 nabbr)))) | |
3444 (or (car result) | |
3445 (signal 'ftp-error | |
3446 (list | |
3447 "Renaming" | |
3448 (format "FTP Error: \"%s\"" (cdr result)) | |
3449 filename | |
3450 newname))) | |
3451 (ange-ftp-add-file-entry newname) | |
3452 (ange-ftp-delete-file-entry filename)) | |
3453 (ange-ftp-copy-file-internal filename newname t nil) | |
3454 (delete-file filename)))) | |
3455 | |
3456 (defun ange-ftp-rename-local-to-remote (filename newname) | |
1233 | 3457 "Rename local FILENAME to remote file NEWNAME." |
1106 | 3458 (let* ((fabbr (ange-ftp-abbreviate-filename filename)) |
3459 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3460 (msg (format "Renaming %s to %s" fabbr nabbr))) | |
3461 (ange-ftp-copy-file-internal filename newname t nil msg) | |
3462 (let (ange-ftp-process-verbose) | |
3463 (delete-file filename)))) | |
3464 | |
3465 (defun ange-ftp-rename-remote-to-local (filename newname) | |
1233 | 3466 "Rename remote file FILENAME to local file NEWNAME." |
1106 | 3467 (let* ((fabbr (ange-ftp-abbreviate-filename filename)) |
3468 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3469 (msg (format "Renaming %s to %s" fabbr nabbr))) | |
3470 (ange-ftp-copy-file-internal filename newname t nil msg) | |
3471 (let (ange-ftp-process-verbose) | |
3472 (delete-file filename)))) | |
3473 | |
3474 (defun ange-ftp-rename-file (filename newname &optional ok-if-already-exists) | |
3475 (interactive "fRename file: \nFRename %s to file: \np") | |
3476 (setq filename (expand-file-name filename)) | |
3477 (setq newname (expand-file-name newname)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3478 (let* ((f-parsed (ange-ftp-ftp-name filename)) |
10748
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
3479 (t-parsed (ange-ftp-ftp-name newname))) |
1106 | 3480 (if (and (or f-parsed t-parsed) |
3481 (or (not ok-if-already-exists) | |
3482 (numberp ok-if-already-exists))) | |
3483 (ange-ftp-barf-or-query-if-file-exists | |
3484 newname | |
3485 "rename to it" | |
3486 (numberp ok-if-already-exists))) | |
3487 (if f-parsed | |
3488 (if t-parsed | |
3489 (ange-ftp-rename-remote-to-remote filename newname f-parsed | |
10748
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
3490 t-parsed) |
1106 | 3491 (ange-ftp-rename-remote-to-local filename newname)) |
3492 (if t-parsed | |
3493 (ange-ftp-rename-local-to-remote filename newname) | |
3494 (ange-ftp-real-rename-file filename newname ok-if-already-exists))))) | |
3495 | |
3496 ;;;; ------------------------------------------------------------ | |
3497 ;;;; File name completion support. | |
3498 ;;;; ------------------------------------------------------------ | |
3499 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3500 ;; 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
|
3501 ;; Note that `ange-ftp-this-dir' is used as a free variable. |
1106 | 3502 (defun ange-ftp-file-entry-active-p (sym) |
3503 (let ((val (get sym 'val))) | |
3504 (or (not (stringp val)) | |
3505 (file-exists-p (ange-ftp-expand-symlink val ange-ftp-this-dir))))) | |
3506 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3507 ;; 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
|
3508 ;; 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
|
3509 ;; by completion-ignored-extensions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3510 ;; 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
|
3511 ;; are used as free variables. |
1106 | 3512 (defun ange-ftp-file-entry-not-ignored-p (sym) |
3513 (let ((val (get sym 'val)) | |
3514 (symname (symbol-name sym))) | |
3515 (if (stringp val) | |
3516 (let ((file (ange-ftp-expand-symlink val ange-ftp-this-dir))) | |
3517 (or (file-directory-p file) | |
3518 (and (file-exists-p file) | |
3519 (not (string-match ange-ftp-completion-ignored-pattern | |
3520 symname))))) | |
3521 (or val ; is a directory name | |
3522 (not (string-match ange-ftp-completion-ignored-pattern symname)))))) | |
3523 | |
3524 (defun ange-ftp-file-name-all-completions (file dir) | |
3525 (let ((ange-ftp-this-dir (expand-file-name dir))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3526 (if (ange-ftp-ftp-name ange-ftp-this-dir) |
1106 | 3527 (progn |
3528 (ange-ftp-barf-if-not-directory ange-ftp-this-dir) | |
3529 (setq ange-ftp-this-dir | |
3530 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir)) | |
3531 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir)) | |
3532 (completions | |
3533 (all-completions file tbl | |
3534 (function ange-ftp-file-entry-active-p)))) | |
3535 | |
3536 ;; see whether each matching file is a directory or not... | |
3537 (mapcar | |
3538 (function | |
3539 (lambda (file) | |
3540 (let ((ent (ange-ftp-get-hash-entry file tbl))) | |
3541 (if (and ent | |
3542 (or (not (stringp ent)) | |
3543 (file-directory-p | |
3544 (ange-ftp-expand-symlink ent | |
3545 ange-ftp-this-dir)))) | |
3546 (concat file "/") | |
3547 file)))) | |
3548 completions))) | |
3549 | |
3550 (if (string-equal "/" ange-ftp-this-dir) | |
3551 (nconc (all-completions file (ange-ftp-generate-root-prefixes)) | |
3552 (ange-ftp-real-file-name-all-completions file | |
3553 ange-ftp-this-dir)) | |
3554 (ange-ftp-real-file-name-all-completions file ange-ftp-this-dir))))) | |
3555 | |
3556 (defun ange-ftp-file-name-completion (file dir) | |
3557 (let ((ange-ftp-this-dir (expand-file-name dir))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3558 (if (ange-ftp-ftp-name ange-ftp-this-dir) |
1106 | 3559 (progn |
3560 (ange-ftp-barf-if-not-directory ange-ftp-this-dir) | |
3561 (if (equal file "") | |
3562 "" | |
3563 (setq ange-ftp-this-dir | |
3564 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir)) ;real? | |
3565 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir)) | |
3566 (ange-ftp-completion-ignored-pattern | |
3567 (mapconcat (function | |
3568 (lambda (s) (if (stringp s) | |
3569 (concat (regexp-quote s) "$") | |
3570 "/"))) ; / never in filename | |
3571 completion-ignored-extensions | |
3572 "\\|"))) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
3573 (save-match-data |
1106 | 3574 (or (ange-ftp-file-name-completion-1 |
3575 file tbl ange-ftp-this-dir | |
3576 (function ange-ftp-file-entry-not-ignored-p)) | |
3577 (ange-ftp-file-name-completion-1 | |
3578 file tbl ange-ftp-this-dir | |
3579 (function ange-ftp-file-entry-active-p))))))) | |
3580 | |
3581 (if (string-equal "/" ange-ftp-this-dir) | |
3582 (try-completion | |
3583 file | |
3584 (nconc (ange-ftp-generate-root-prefixes) | |
3585 (mapcar 'list | |
3586 (ange-ftp-real-file-name-all-completions file "/")))) | |
3587 (ange-ftp-real-file-name-completion file ange-ftp-this-dir))))) | |
3588 | |
3589 | |
3590 (defun ange-ftp-file-name-completion-1 (file tbl dir predicate) | |
3591 (let ((bestmatch (try-completion file tbl predicate))) | |
3592 (if bestmatch | |
3593 (if (eq bestmatch t) | |
3594 (if (file-directory-p (expand-file-name file dir)) | |
3595 (concat file "/") | |
3596 t) | |
3597 (if (and (eq (try-completion bestmatch tbl predicate) t) | |
3598 (file-directory-p | |
3599 (expand-file-name bestmatch dir))) | |
3600 (concat bestmatch "/") | |
3601 bestmatch))))) | |
3602 | |
3603 ;; Put these lines uncommmented in your .emacs if you want C-r to refresh | |
3604 ;; ange-ftp's cache whilst doing filename completion. | |
3605 ;; | |
3606 ;;(define-key minibuffer-local-completion-map "\C-r" 'ange-ftp-re-read-dir) | |
3607 ;;(define-key minibuffer-local-must-match-map "\C-r" 'ange-ftp-re-read-dir) | |
3608 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3609 ;; 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
|
3610 ;; to the directory part of the contents of the current buffer. |
1106 | 3611 (defun ange-ftp-re-read-dir (&optional dir) |
3612 (interactive) | |
3613 (if dir | |
3614 (setq dir (expand-file-name dir)) | |
3615 (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
|
3616 (if (ange-ftp-ftp-name dir) |
1106 | 3617 (progn |
3618 (setq ange-ftp-ls-cache-file nil) | |
3619 (ange-ftp-del-hash-entry dir ange-ftp-files-hashtable) | |
3620 (ange-ftp-get-files dir t)))) | |
3621 | |
3611
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3622 (defun ange-ftp-make-directory (dir &optional parents) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3623 (interactive (list (expand-file-name (read-file-name "Make directory: ")))) |
3611
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3624 (if parents |
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3625 (let ((parent (file-name-directory (directory-file-name dir)))) |
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3626 (or (file-exists-p parent) |
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3627 (ange-ftp-make-directory parent parents)))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3628 (if (file-exists-p dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3629 (error "Cannot make directory %s: file already exists" dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3630 (let ((parsed (ange-ftp-ftp-name dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3631 (if parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3632 (let* ((host (nth 0 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3633 (user (nth 1 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3634 ;; Some ftp's on unix machines (at least on Suns) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3635 ;; insist that mkdir take a filename, and not a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3636 ;; 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
|
3637 ;; Non-unix machines will probably always insist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3638 ;; that mkdir takes a directory-name as an arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3639 ;; (as the ftp man page says it should). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3640 (name (ange-ftp-quote-string |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3641 (if (eq (ange-ftp-host-type host) 'unix) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3642 (ange-ftp-real-directory-file-name (nth 2 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3643 (ange-ftp-real-file-name-as-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3644 (nth 2 parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3645 (abbr (ange-ftp-abbreviate-filename dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3646 (result (ange-ftp-send-cmd host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3647 (list 'mkdir name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3648 (format "Making directory %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3649 abbr)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3650 (or (car result) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3651 (ange-ftp-error host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3652 (format "Could not make directory %s: %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3653 dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3654 (cdr result)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3655 (ange-ftp-add-file-entry dir t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3656 (ange-ftp-real-make-directory dir))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3657 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3658 (defun ange-ftp-delete-directory (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3659 (if (file-directory-p dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3660 (let ((parsed (ange-ftp-ftp-name dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3661 (if parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3662 (let* ((host (nth 0 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3663 (user (nth 1 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3664 ;; Some ftp's on unix machines (at least on Suns) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3665 ;; insist that rmdir take a filename, and not a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3666 ;; 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
|
3667 ;; Non-unix machines will probably always insist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3668 ;; that rmdir takes a directory-name as an arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3669 ;; (as the ftp man page says it should). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3670 (name (ange-ftp-quote-string |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3671 (if (eq (ange-ftp-host-type host) 'unix) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3672 (ange-ftp-real-directory-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3673 (nth 2 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3674 (ange-ftp-real-file-name-as-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3675 (nth 2 parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3676 (abbr (ange-ftp-abbreviate-filename dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3677 (result (ange-ftp-send-cmd host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3678 (list 'rmdir name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3679 (format "Removing directory %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3680 abbr)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3681 (or (car result) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3682 (ange-ftp-error host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3683 (format "Could not remove directory %s: %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3684 dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3685 (cdr result)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3686 (ange-ftp-delete-file-entry dir t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3687 (ange-ftp-real-delete-directory dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3688 (error "Not a directory: %s" dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3689 |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3690 ;; Make a local copy of FILE and return its name. |
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3691 |
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3692 (defun ange-ftp-file-local-copy (file) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3693 (let* ((fn1 (expand-file-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3694 (pa1 (ange-ftp-ftp-name fn1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3695 (if pa1 |
10748
0bee4d7bc9a4
(ange-ftp-write-region, ange-ftp-insert-file-contents)
Richard M. Stallman <rms@gnu.org>
parents:
10451
diff
changeset
|
3696 (let ((tmp1 (ange-ftp-make-tmp-name (car pa1)))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3697 (ange-ftp-copy-file-internal fn1 tmp1 t nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3698 (format "Getting %s" fn1)) |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3699 tmp1)))) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3700 |
5840
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3701 (defun ange-ftp-load (file &optional noerror nomessage nosuffix) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3702 (if (ange-ftp-ftp-name file) |
5840
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3703 (let ((tryfiles (if nosuffix |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3704 (list file) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3705 (list (concat file ".elc") (concat file ".el") file))) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3706 copy) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3707 (while (and tryfiles (not copy)) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3708 (condition-case error |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3709 (setq copy (ange-ftp-file-local-copy (car tryfiles))) |
13789
7ccb22bca972
(ange-ftp-load): Added missing form to `cdr' down
Karl Heuer <kwzh@gnu.org>
parents:
13594
diff
changeset
|
3710 (ftp-error nil)) |
7ccb22bca972
(ange-ftp-load): Added missing form to `cdr' down
Karl Heuer <kwzh@gnu.org>
parents:
13594
diff
changeset
|
3711 (setq tryfiles (cdr tryfiles))) |
5840
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3712 (if copy |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3713 (unwind-protect |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3714 (funcall 'load copy noerror nomessage nosuffix) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3715 (delete-file copy)) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3716 (or noerror |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3717 (signal 'file-error (list "Cannot open load file" file))))) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3718 (ange-ftp-real-load file noerror nomessage nosuffix))) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3719 |
1670
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3720 ;; 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
|
3721 (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
|
3722 (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
|
3723 |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3724 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3725 ;; Need the following functions for making filenames of compressed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3726 ;; 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
|
3727 ;; have two extensions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3728 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3729 (defvar ange-ftp-make-compressed-filename-alist nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3730 "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
|
3731 Each element has the form (TYPE . FUNC). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3732 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
|
3733 of the form (COMPRESSING NEWNAME). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3734 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
|
3735 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
|
3736 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
|
3737 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3738 (defun ange-ftp-dired-compress-file (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3739 (let ((parsed (ange-ftp-ftp-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3740 conversion-func) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3741 (if (and parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3742 (setq conversion-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3743 (cdr (assq (ange-ftp-host-type (car parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3744 ange-ftp-make-compressed-filename-alist)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3745 (let* ((decision |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
3746 (save-match-data (funcall conversion-func name))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3747 (compressing (car decision)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3748 (newfile (nth 1 decision))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3749 (if compressing |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3750 (ange-ftp-compress name newfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3751 (ange-ftp-uncompress name newfile))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3752 (let (file-name-handler-alist) |
3230
103f34320cb5
(ange-ftp-dired-compress-file):
Richard M. Stallman <rms@gnu.org>
parents:
3000
diff
changeset
|
3753 (dired-compress-file name))))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3754 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3755 ;; 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
|
3756 (defun ange-ftp-compress (file nfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3757 (let* ((parsed (ange-ftp-ftp-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3758 (tmp1 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3759 (tmp2 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3760 (abbr (ange-ftp-abbreviate-filename file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3761 (nabbr (ange-ftp-abbreviate-filename nfile)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3762 (msg1 (format "Getting %s" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3763 (msg2 (format "Putting %s" nabbr))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3764 (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3765 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3766 (ange-ftp-copy-file-internal file tmp1 t nil msg1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3767 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3768 (ange-ftp-message "Compressing %s..." abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3769 (call-process-region (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3770 (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3771 shell-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3772 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3773 t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3774 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3775 "-c" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3776 (format "compress -f -c < %s > %s" tmp1 tmp2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3777 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3778 (ange-ftp-message "Compressing %s...done" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3779 (if (zerop (buffer-size)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3780 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3781 (let (ange-ftp-process-verbose) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3782 (delete-file file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3783 (ange-ftp-copy-file-internal tmp2 nfile t nil msg2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3784 (ange-ftp-del-tmp-name tmp1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3785 (ange-ftp-del-tmp-name tmp2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3786 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3787 ;; 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
|
3788 (defun ange-ftp-uncompress (file nfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3789 (let* ((parsed (ange-ftp-ftp-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3790 (tmp1 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3791 (tmp2 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3792 (abbr (ange-ftp-abbreviate-filename file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3793 (nabbr (ange-ftp-abbreviate-filename nfile)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3794 (msg1 (format "Getting %s" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3795 (msg2 (format "Putting %s" nabbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3796 ;; ;; Cheap hack because of problems with binary file transfers from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3797 ;; ;; VMS hosts. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3798 ;; (gbinary (not (eq 'vms (ange-ftp-host-type (car parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3799 ) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3800 (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3801 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3802 (ange-ftp-copy-file-internal file tmp1 t nil msg1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3803 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3804 (ange-ftp-message "Uncompressing %s..." abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3805 (call-process-region (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3806 (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3807 shell-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3808 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3809 t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3810 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3811 "-c" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3812 (format "uncompress -c < %s > %s" tmp1 tmp2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3813 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3814 (ange-ftp-message "Uncompressing %s...done" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3815 (if (zerop (buffer-size)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3816 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3817 (let (ange-ftp-process-verbose) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3818 (delete-file file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3819 (ange-ftp-copy-file-internal tmp2 nfile t nil msg2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3820 (ange-ftp-del-tmp-name tmp1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3821 (ange-ftp-del-tmp-name tmp2)))) |
10407
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3822 |
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3823 (defun ange-ftp-find-backup-file-name (fn) |
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3824 ;; Either return the ordinary backup name, etc., |
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3825 ;; or return nil meaning don't make a backup. |
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3826 (if ange-ftp-make-backup-files |
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3827 (ange-ftp-real-find-backup-file-name fn))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3828 |
1106 | 3829 ;;; Define the handler for special file names |
3830 ;;; that causes ange-ftp to be invoked. | |
3831 | |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3832 ;;;###autoload |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3833 (defun ange-ftp-hook-function (operation &rest args) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3834 (let ((fn (get operation 'ange-ftp))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3835 (if fn (apply fn args) |
7143
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3836 (ange-ftp-run-real-handler operation args)))) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3837 |
3893
d04e12f9153f
* ange-ftp.el: Loosen file-name-handler-alist regexp so we can do
Jim Blandy <jimb@redhat.com>
parents:
3831
diff
changeset
|
3838 |
d04e12f9153f
* ange-ftp.el: Loosen file-name-handler-alist regexp so we can do
Jim Blandy <jimb@redhat.com>
parents:
3831
diff
changeset
|
3839 ;;; This regexp takes care of real ange-ftp file names (with a slash |
4185
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3840 ;;; and colon). |
12741
bcaa94db623c
(file-name-handler-alist): Don't match host name ending in period.
Richard M. Stallman <rms@gnu.org>
parents:
12441
diff
changeset
|
3841 ;;; Don't allow the host name to end in a period--some systems use /.: |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3842 ;;;###autoload |
12741
bcaa94db623c
(file-name-handler-alist): Don't match host name ending in period.
Richard M. Stallman <rms@gnu.org>
parents:
12441
diff
changeset
|
3843 (or (assoc "^/[^/:]*[^/:.]:" file-name-handler-alist) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3844 (setq file-name-handler-alist |
12741
bcaa94db623c
(file-name-handler-alist): Don't match host name ending in period.
Richard M. Stallman <rms@gnu.org>
parents:
12441
diff
changeset
|
3845 (cons '("^/[^/:]*[^/:.]:" . ange-ftp-hook-function) |
4185
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3846 file-name-handler-alist))) |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3847 |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3848 ;;; This regexp recognizes and absolute filenames with only one component, |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3849 ;;; for the sake of hostname completion. |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3850 ;;;###autoload |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3851 (or (assoc "^/[^/:]*\\'" file-name-handler-alist) |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3852 (setq file-name-handler-alist |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3853 (cons '("^/[^/:]*\\'" . ange-ftp-completion-hook-function) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3854 file-name-handler-alist))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3855 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3856 ;;; 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
|
3857 ;;; 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
|
3858 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3859 ;;; This sets the mode |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3860 (or (memq 'ange-ftp-set-buffer-mode find-file-hooks) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3861 (setq find-file-hooks |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3862 (cons 'ange-ftp-set-buffer-mode find-file-hooks))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3863 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3864 ;;; Now say where to find the handlers for particular operations. |
1106 | 3865 |
3866 (put 'file-name-directory 'ange-ftp 'ange-ftp-file-name-directory) | |
3867 (put 'file-name-nondirectory 'ange-ftp 'ange-ftp-file-name-nondirectory) | |
3868 (put 'file-name-as-directory 'ange-ftp 'ange-ftp-file-name-as-directory) | |
3869 (put 'directory-file-name 'ange-ftp 'ange-ftp-directory-file-name) | |
3870 (put 'expand-file-name 'ange-ftp 'ange-ftp-expand-file-name) | |
3871 (put 'make-directory 'ange-ftp 'ange-ftp-make-directory) | |
3872 (put 'delete-directory 'ange-ftp 'ange-ftp-delete-directory) | |
3873 (put 'insert-file-contents 'ange-ftp 'ange-ftp-insert-file-contents) | |
3874 (put 'directory-files 'ange-ftp 'ange-ftp-directory-files) | |
3875 (put 'file-directory-p 'ange-ftp 'ange-ftp-file-directory-p) | |
3876 (put 'file-writable-p 'ange-ftp 'ange-ftp-file-writable-p) | |
3877 (put 'file-readable-p 'ange-ftp 'ange-ftp-file-readable-p) | |
4674
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3878 (put 'file-executable-p 'ange-ftp 'ange-ftp-file-executable-p) |
1106 | 3879 (put 'file-symlink-p 'ange-ftp 'ange-ftp-file-symlink-p) |
3880 (put 'delete-file 'ange-ftp 'ange-ftp-delete-file) | |
3881 (put 'read-file-name-internal 'ange-ftp 'ange-ftp-read-file-name-internal) | |
3882 (put 'verify-visited-file-modtime 'ange-ftp | |
3883 'ange-ftp-verify-visited-file-modtime) | |
3884 (put 'file-exists-p 'ange-ftp 'ange-ftp-file-exists-p) | |
3885 (put 'write-region 'ange-ftp 'ange-ftp-write-region) | |
3886 (put 'backup-buffer 'ange-ftp 'ange-ftp-backup-buffer) | |
3887 (put 'copy-file 'ange-ftp 'ange-ftp-copy-file) | |
3888 (put 'rename-file 'ange-ftp 'ange-ftp-rename-file) | |
3889 (put 'file-attributes 'ange-ftp 'ange-ftp-file-attributes) | |
3890 (put 'file-name-all-completions 'ange-ftp 'ange-ftp-file-name-all-completions) | |
3891 (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
|
3892 (put 'insert-directory 'ange-ftp 'ange-ftp-insert-directory) |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3893 (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
|
3894 (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
|
3895 'ange-ftp-unhandled-file-name-directory) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3896 (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
|
3897 (put 'dired-uncache 'ange-ftp 'ange-ftp-dired-uncache) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3898 (put 'dired-compress-file 'ange-ftp 'ange-ftp-dired-compress-file) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3899 (put 'load 'ange-ftp 'ange-ftp-load) |
10407
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3900 (put 'find-backup-file-name 'ange-ftp 'ange-ftp-find-backup-file-name) |
1454
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3901 |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3902 ;; 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
|
3903 ;; 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
|
3904 (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
|
3905 |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3906 ;; 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
|
3907 ;; 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
|
3908 (put 'vc-registered 'ange-ftp 'null) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3909 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3910 ;;; Define ways of getting at unmodified Emacs primitives, |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3911 ;;; turning off our handler. |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3912 |
7042 | 3913 (defun ange-ftp-run-real-handler (operation args) |
3914 (let ((inhibit-file-name-handlers | |
3915 (cons 'ange-ftp-hook-function | |
7143
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3916 (cons 'ange-ftp-completion-hook-function |
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3917 (and (eq inhibit-file-name-operation operation) |
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3918 inhibit-file-name-handlers)))) |
7042 | 3919 (inhibit-file-name-operation operation)) |
3920 (apply operation args))) | |
3921 | |
1106 | 3922 (defun ange-ftp-real-file-name-directory (&rest args) |
7042 | 3923 (ange-ftp-run-real-handler 'file-name-directory args)) |
1106 | 3924 (defun ange-ftp-real-file-name-nondirectory (&rest args) |
7042 | 3925 (ange-ftp-run-real-handler 'file-name-nondirectory args)) |
1106 | 3926 (defun ange-ftp-real-file-name-as-directory (&rest args) |
7042 | 3927 (ange-ftp-run-real-handler 'file-name-as-directory args)) |
1106 | 3928 (defun ange-ftp-real-directory-file-name (&rest args) |
7042 | 3929 (ange-ftp-run-real-handler 'directory-file-name args)) |
1106 | 3930 (defun ange-ftp-real-expand-file-name (&rest args) |
7042 | 3931 (ange-ftp-run-real-handler 'expand-file-name args)) |
1106 | 3932 (defun ange-ftp-real-make-directory (&rest args) |
7042 | 3933 (ange-ftp-run-real-handler 'make-directory args)) |
1106 | 3934 (defun ange-ftp-real-delete-directory (&rest args) |
7042 | 3935 (ange-ftp-run-real-handler 'delete-directory args)) |
1106 | 3936 (defun ange-ftp-real-insert-file-contents (&rest args) |
7042 | 3937 (ange-ftp-run-real-handler 'insert-file-contents args)) |
1106 | 3938 (defun ange-ftp-real-directory-files (&rest args) |
7042 | 3939 (ange-ftp-run-real-handler 'directory-files args)) |
1106 | 3940 (defun ange-ftp-real-file-directory-p (&rest args) |
7042 | 3941 (ange-ftp-run-real-handler 'file-directory-p args)) |
1106 | 3942 (defun ange-ftp-real-file-writable-p (&rest args) |
7042 | 3943 (ange-ftp-run-real-handler 'file-writable-p args)) |
1106 | 3944 (defun ange-ftp-real-file-readable-p (&rest args) |
7042 | 3945 (ange-ftp-run-real-handler 'file-readable-p args)) |
4674
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3946 (defun ange-ftp-real-file-executable-p (&rest args) |
7042 | 3947 (ange-ftp-run-real-handler 'file-executable-p args)) |
1106 | 3948 (defun ange-ftp-real-file-symlink-p (&rest args) |
7042 | 3949 (ange-ftp-run-real-handler 'file-symlink-p args)) |
1106 | 3950 (defun ange-ftp-real-delete-file (&rest args) |
7042 | 3951 (ange-ftp-run-real-handler 'delete-file args)) |
1106 | 3952 (defun ange-ftp-real-read-file-name-internal (&rest args) |
7042 | 3953 (ange-ftp-run-real-handler 'read-file-name-internal args)) |
1106 | 3954 (defun ange-ftp-real-verify-visited-file-modtime (&rest args) |
7042 | 3955 (ange-ftp-run-real-handler 'verify-visited-file-modtime args)) |
1106 | 3956 (defun ange-ftp-real-file-exists-p (&rest args) |
7042 | 3957 (ange-ftp-run-real-handler 'file-exists-p args)) |
1106 | 3958 (defun ange-ftp-real-write-region (&rest args) |
7042 | 3959 (ange-ftp-run-real-handler 'write-region args)) |
1106 | 3960 (defun ange-ftp-real-backup-buffer (&rest args) |
7042 | 3961 (ange-ftp-run-real-handler 'backup-buffer args)) |
1106 | 3962 (defun ange-ftp-real-copy-file (&rest args) |
7042 | 3963 (ange-ftp-run-real-handler 'copy-file args)) |
1106 | 3964 (defun ange-ftp-real-rename-file (&rest args) |
7042 | 3965 (ange-ftp-run-real-handler 'rename-file args)) |
1106 | 3966 (defun ange-ftp-real-file-attributes (&rest args) |
7042 | 3967 (ange-ftp-run-real-handler 'file-attributes args)) |
1106 | 3968 (defun ange-ftp-real-file-name-all-completions (&rest args) |
7042 | 3969 (ange-ftp-run-real-handler 'file-name-all-completions args)) |
1106 | 3970 (defun ange-ftp-real-file-name-completion (&rest args) |
7042 | 3971 (ange-ftp-run-real-handler 'file-name-completion args)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3972 (defun ange-ftp-real-insert-directory (&rest args) |
7042 | 3973 (ange-ftp-run-real-handler 'insert-directory args)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3974 (defun ange-ftp-real-file-name-sans-versions (&rest args) |
7042 | 3975 (ange-ftp-run-real-handler 'file-name-sans-versions args)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3976 (defun ange-ftp-real-shell-command (&rest args) |
7042 | 3977 (ange-ftp-run-real-handler 'shell-command args)) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3978 (defun ange-ftp-real-load (&rest args) |
7042 | 3979 (ange-ftp-run-real-handler 'load args)) |
10407
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3980 (defun ange-ftp-real-find-backup-file-name (&rest args) |
8b26137996f9
(ange-ftp-set-buffer-mode): Don't set make-backup-files.
Richard M. Stallman <rms@gnu.org>
parents:
10244
diff
changeset
|
3981 (ange-ftp-run-real-handler 'find-backup-file-name args)) |
1106 | 3982 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3983 ;; Here we support using dired on remote hosts. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3984 ;; 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
|
3985 ;; That involves too many unclean hooks. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3986 ;; It would be cleaner to support such operations by |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3987 ;; converting the foreign directory format to something dired can understand; |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3988 ;; something close to ls -l output. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3989 ;; 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
|
3990 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3991 ;; 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
|
3992 ;; I have preserved (and modernized) those hooks. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3993 ;; So the format conversion should be all that is needed. |
1106 | 3994 |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3995 (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
|
3996 (let ((short (ange-ftp-abbreviate-filename file)) |
7747
40d992ff4662
(ange-ftp-insert-directory): Expand file name to
Richard M. Stallman <rms@gnu.org>
parents:
7664
diff
changeset
|
3997 (parsed (ange-ftp-ftp-name (expand-file-name file)))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3998 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3999 (insert |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4000 (if wildcard |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4001 (let ((default-directory (file-name-directory file))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4002 (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
|
4003 (ange-ftp-ls file switches full))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4004 (ange-ftp-real-insert-directory file switches wildcard full)))) |
1106 | 4005 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4006 (defun ange-ftp-dired-uncache (dir) |
4887
78c004148b7c
(ange-ftp-dired-uncache): Fix parens so that `(setq ...' is a result
Brian Fox <bfox@gnu.org>
parents:
4674
diff
changeset
|
4007 (if (ange-ftp-ftp-name (expand-file-name dir)) |
78c004148b7c
(ange-ftp-dired-uncache): Fix parens so that `(setq ...' is a result
Brian Fox <bfox@gnu.org>
parents:
4674
diff
changeset
|
4008 (setq ange-ftp-ls-cache-file nil))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4009 |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4010 (defvar ange-ftp-sans-version-alist nil |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4011 "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
|
4012 |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4013 (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
|
4014 (setq file (ange-ftp-abbreviate-filename file)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4015 (let ((parsed (ange-ftp-ftp-name file)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4016 host-type func) |
1106 | 4017 (if parsed |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4018 (setq host-type (ange-ftp-host-type (car parsed)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4019 func (cdr (assq (ange-ftp-host-type (car parsed)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4020 ange-ftp-sans-version-alist)))) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4021 (if func (funcall func file keep-backup-version) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
4022 (ange-ftp-real-file-name-sans-versions file keep-backup-version)))) |
1106 | 4023 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4024 ;;; 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
|
4025 ;;; Maybe the new hook should be in call-process. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4026 (defun ange-ftp-shell-command (command) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4027 (let* ((parsed (ange-ftp-ftp-name default-directory)) |
1106 | 4028 (host (nth 0 parsed)) |
4029 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4030 (name (nth 2 parsed))) |
1106 | 4031 (if (not parsed) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4032 (ange-ftp-real-shell-command command) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4033 (if (> (length name) 0) ; else it's $HOME |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4034 (setq command (concat "cd " name "; " command))) |
1106 | 4035 (setq command |
4036 (format "%s %s \"%s\"" ; remsh -l USER does not work well | |
4037 ; on a hp-ux machine I tried | |
10451
bc83756f19ad
(ange-ftp-gateway-program, ange-ftp-shell-command): Use new global
Karl Heuer <kwzh@gnu.org>
parents:
10407
diff
changeset
|
4038 remote-shell-program host command)) |
1106 | 4039 (ange-ftp-message "Remote command '%s' ..." command) |
4040 ;; Cannot call ange-ftp-real-dired-run-shell-command here as it | |
4041 ;; would prepend "cd default-directory" --- which bombs because | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4042 ;; 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
|
4043 (ange-ftp-real-shell-command command)))) |
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 ;;; Thisis not hooked up yet. |
1106 | 4046 (defun ange-ftp-dired-call-process (program discard &rest arguments) |
4047 ;; PROGRAM is always one of those below in the cond in dired.el. | |
4048 ;; The ARGUMENTS are (nearly) always files. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4049 (if (ange-ftp-ftp-name default-directory) |
1106 | 4050 ;; Can't use ange-ftp-dired-host-type here because the current |
4051 ;; buffer is *dired-check-process output* | |
4052 (condition-case oops | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4053 (cond ((equal "chmod" program) |
1106 | 4054 (ange-ftp-call-chmod arguments)) |
4055 ;; ((equal "chgrp" program)) | |
4056 ;; ((equal dired-chown-program program)) | |
4057 (t (error "Unknown remote command: %s" program))) | |
4058 (ftp-error (insert (format "%s: %s, %s\n" | |
4059 (nth 1 oops) | |
4060 (nth 2 oops) | |
4061 (nth 3 oops)))) | |
4062 (error (insert (format "%s\n" (nth 1 oops))))) | |
4063 (apply 'call-process program nil (not discard) nil arguments))) | |
4064 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4065 ;;; This currently does not work; it is never called. |
1106 | 4066 (defun ange-ftp-call-chmod (args) |
4067 (if (< (length args) 2) | |
4068 (error "ange-ftp-call-chmod: missing mode and/or filename: %s" args)) | |
4069 (let ((mode (car args))) | |
4070 (mapcar | |
4071 (function | |
4072 (lambda (file) | |
4073 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4074 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 4075 (if parsed |
4076 (let* ((host (nth 0 parsed)) | |
4077 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4078 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 4079 (abbr (ange-ftp-abbreviate-filename file)) |
4080 (result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4081 (list 'chmod mode name) |
1106 | 4082 (format "doing chmod %s" |
4083 abbr)))) | |
4084 (or (car result) | |
4085 (ange-ftp-error host user | |
4086 (format "chmod: %s: \"%s\"" | |
4087 file | |
4088 (cdr result))))))))) | |
4089 (cdr args))) | |
4090 (setq ange-ftp-ls-cache-file nil)) ;stop confusing dired | |
4091 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4092 ;;; 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
|
4093 ;;; with dired. It could be reasonable to adapt this to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4094 ;;; replace ange-ftp-copy-file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4095 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4096 ;;;;; ------------------------------------------------------------ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4097 ;;;;; Noddy support for async copy-file within dired. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4098 ;;;;; ------------------------------------------------------------ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4099 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4100 ;;(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
|
4101 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4102 ;; (dired-handle-overwrite to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4103 ;; (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
|
4104 ;; cont nowait)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4105 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4106 ;;(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
|
4107 ;; &optional marker-char op1 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4108 ;; how-to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4109 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4110 ;; ;; 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
|
4111 ;; ;; called it rather than somebody else. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4112 ;; (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
|
4113 ;; (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
|
4114 ;; arg marker-char op1 how-to))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4115 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4116 ;;(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
|
4117 ;; &optional marker-char) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4118 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4119 ;; (if (and (boundp 'ange-ftp-dired-do-create-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4120 ;; ;; called from ange-ftp-dired-do-create-files? |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4121 ;; ange-ftp-dired-do-create-files |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4122 ;; ;; any files worth copying? |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4123 ;; fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4124 ;; ;; we only support async copy-file at the mo. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4125 ;; (eq file-creator 'dired-copy-file) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4126 ;; ;; 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
|
4127 ;; ;; as we tie ourself in recursive knots otherwise. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4128 ;; (or (ange-ftp-ftp-name (car fn-list)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4129 ;; ;; 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
|
4130 ;; ;; since the one for regexps starts prompting here, there and |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4131 ;; ;; everywhere. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4132 ;; (ange-ftp-ftp-name (funcall name-constructor (car fn-list))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4133 ;; ;; 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
|
4134 ;; (ange-ftp-dcf-1 file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4135 ;; operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4136 ;; fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4137 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4138 ;; (and (boundp 'target) target) ;dynamically bound |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4139 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4140 ;; (current-buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4141 ;; nil ;overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4142 ;; nil ;overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4143 ;; nil ;failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4144 ;; nil ;skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4145 ;; 0 ;success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4146 ;; (length fn-list) ;total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4147 ;; ) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
4148 ;; ;; normal case... use the interactive routine... much cheaper. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4149 ;; (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
|
4150 ;; name-constructor marker-char))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4151 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4152 ;;(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
|
4153 ;; target marker-char buffer overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4154 ;; overwrite-backup-query failures skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4155 ;; success-count total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4156 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4157 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4158 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4159 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4160 ;; (if (null fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4161 ;; (ange-ftp-dcf-3 failures operation total skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4162 ;; success-count buffer) |
1106 | 4163 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4164 ;; (let* ((from (car fn-list)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4165 ;; (to (funcall name-constructor from))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4166 ;; (if (equal to from) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4167 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4168 ;; (setq to nil) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4169 ;; (dired-log "Cannot %s to same file: %s\n" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4170 ;; (downcase operation) from))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4171 ;; (if (not to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4172 ;; (ange-ftp-dcf-1 file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4173 ;; operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4174 ;; (cdr fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4175 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4176 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4177 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4178 ;; buffer |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4179 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4180 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4181 ;; failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4182 ;; (cons (dired-make-relative from) skipped) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4183 ;; success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4184 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4185 ;; (let* ((overwrite (file-exists-p to)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4186 ;; (overwrite-confirmed ; for dired-handle-overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4187 ;; (and overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4188 ;; (let ((help-form '(format "\ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4189 ;;Type SPC or `y' to overwrite file `%s', |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4190 ;;DEL or `n' to skip to next, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4191 ;;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
|
4192 ;;`!' to overwrite all remaining files with no more questions." to))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4193 ;; (dired-query 'overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4194 ;; "Overwrite `%s'?" to)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4195 ;; ;; must determine if FROM is marked before file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4196 ;; ;; 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
|
4197 ;; (actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4198 ;; (cond ((integerp marker-char) marker-char) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4199 ;; (marker-char (dired-file-marker from)) ; slow |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4200 ;; (t nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4201 ;; (condition-case err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4202 ;; (funcall file-creator from to overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4203 ;; (list (function ange-ftp-dcf-2) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4204 ;; nil ;err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4205 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4206 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4207 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4208 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4209 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4210 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4211 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4212 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4213 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4214 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4215 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4216 ;; t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4217 ;; (file-error ; FILE-CREATOR aborted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4218 ;; (ange-ftp-dcf-2 nil ;result |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4219 ;; nil ;line |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4220 ;; err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4221 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4222 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4223 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4224 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4225 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4226 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4227 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4228 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4229 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4230 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4231 ;; total)))))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4232 ;; (set-buffer old-buf)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4233 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4234 ;;(defun ange-ftp-dcf-2 (result line err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4235 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4236 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4237 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4238 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4239 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4240 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4241 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4242 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4243 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4244 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4245 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4246 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4247 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4248 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4249 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4250 ;; (if (or err (not result)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4251 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4252 ;; (setq failures (cons (dired-make-relative from) failures)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4253 ;; (dired-log "%s `%s' to `%s' failed:\n%s\n" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4254 ;; operation from to (or err line))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4255 ;; (if overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4256 ;; ;; If we get here, file-creator hasn't been aborted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4257 ;; ;; and the old entry (if any) has to be deleted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4258 ;; ;; before adding the new entry. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4259 ;; (dired-remove-file to)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4260 ;; (setq success-count (1+ success-count)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4261 ;; (message "%s: %d of %d" operation success-count total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4262 ;; (dired-add-file to actual-marker-char)) |
1106 | 4263 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4264 ;; (ange-ftp-dcf-1 file-creator operation (cdr fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4265 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4266 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4267 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4268 ;; buffer |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4269 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4270 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4271 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4272 ;; total)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4273 ;; (set-buffer old-buf)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4274 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4275 ;;(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
|
4276 ;; buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4277 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4278 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4279 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4280 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4281 ;; (cond |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4282 ;; (failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4283 ;; (dired-log-summary |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4284 ;; (message "%s failed for %d of %d file%s %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4285 ;; operation (length failures) total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4286 ;; (dired-plural-s total) failures))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4287 ;; (skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4288 ;; (dired-log-summary |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4289 ;; (message "%s: %d of %d file%s skipped %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4290 ;; operation (length skipped) total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4291 ;; (dired-plural-s total) skipped))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4292 ;; (t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4293 ;; (message "%s: %s file%s." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4294 ;; operation success-count (dired-plural-s success-count)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4295 ;; (dired-move-to-filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4296 ;; (set-buffer old-buf)))) |
1106 | 4297 |
4298 ;;;; ----------------------------------------------- | |
4299 ;;;; Unix Descriptive Listing (dl) Support | |
4300 ;;;; ----------------------------------------------- | |
4301 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4302 ;; This is turned off because nothing uses it currently |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4303 ;; 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
|
4304 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4305 ;;(defconst ange-ftp-dired-dl-re-dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4306 ;; "^. [^ /]+/[ \n]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4307 ;; "Regular expression to use to search for dl directories.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4308 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4309 ;;(or (assq 'unix:dl ange-ftp-dired-re-dir-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4310 ;; (setq ange-ftp-dired-re-dir-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4311 ;; (cons (cons 'unix:dl ange-ftp-dired-dl-re-dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4312 ;; ange-ftp-dired-re-dir-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4313 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4314 ;;(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
|
4315 ;; "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
|
4316 ;; ;; This is the Unix dl version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4317 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4318 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4319 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4320 ;; (if (looking-at ". [^ ]+ +\\([0-9]+\\|-\\|=\\) ") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4321 ;; (goto-char (+ (point) 2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4322 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4323 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4324 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4325 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4326 ;;(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
|
4327 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4328 ;; (cons '(unix:dl . ange-ftp-dired-dl-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4329 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4330 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4331 ;;(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
|
4332 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4333 ;; ;; 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
|
4334 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4335 ;; ;; This is the Unix dl version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4336 ;; (let ((opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4337 ;; case-fold-search hidden) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4338 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4339 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4340 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4341 ;; (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4342 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4343 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4344 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4345 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4346 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4347 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4348 ;; (skip-chars-forward "^ /" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4349 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4350 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4351 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4352 ;; (error "No file on this line")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4353 ;; (point))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4354 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4355 ;;(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
|
4356 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4357 ;; (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
|
4358 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 4359 |
4360 ;;;; ------------------------------------------------------------ | |
4361 ;;;; VOS support (VOS support is probably broken, | |
4362 ;;;; but I don't know anything about VOS.) | |
4363 ;;;; ------------------------------------------------------------ | |
4364 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4365 ;(defun ange-ftp-fix-name-for-vos (name &optional reverse) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4366 ; (setq name (copy-sequence name)) |
1106 | 4367 ; (let ((from (if reverse ?\> ?\/)) |
4368 ; (to (if reverse ?\/ ?\>)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4369 ; (i (1- (length name)))) |
1106 | 4370 ; (while (>= i 0) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4371 ; (if (= (aref name i) from) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4372 ; (aset name i to)) |
1106 | 4373 ; (setq i (1- i))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4374 ; name)) |
1106 | 4375 ; |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4376 ;(or (assq 'vos ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4377 ; (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4378 ; (cons '(vos . ange-ftp-fix-name-for-vos) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4379 ; ange-ftp-fix-name-func-alist))) |
1106 | 4380 ; |
4381 ;(or (memq 'vos ange-ftp-dumb-host-types) | |
4382 ; (setq ange-ftp-dumb-host-types | |
4383 ; (cons 'vos ange-ftp-dumb-host-types))) | |
4384 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4385 ;(defun ange-ftp-fix-dir-name-for-vos (dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4386 ; (ange-ftp-fix-name-for-vos |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4387 ; (concat dir-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4388 ; (if (eq ?/ (aref dir-name (1- (length dir-name)))) |
1106 | 4389 ; "" "/") |
4390 ; "*"))) | |
4391 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4392 ;(or (assq 'vos ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4393 ; (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4394 ; (cons '(vos . ange-ftp-fix-dir-name-for-vos) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4395 ; ange-ftp-fix-dir-name-func-alist))) |
1106 | 4396 ; |
4397 ;(defvar ange-ftp-vos-host-regexp nil | |
4398 ; "If a host matches this regexp then it is assumed to be running VOS.") | |
4399 ; | |
4400 ;(defun ange-ftp-vos-host (host) | |
4401 ; (and ange-ftp-vos-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4402 ; (save-match-data |
1106 | 4403 ; (string-match ange-ftp-vos-host-regexp host)))) |
4404 ; | |
4405 ;(defun ange-ftp-parse-vos-listing () | |
4406 ; "Parse the current buffer which is assumed to be in VOS list -all | |
4407 ;format, and return a hashtable as the result." | |
4408 ; (let ((tbl (ange-ftp-make-hashtable)) | |
4409 ; (type-list | |
4410 ; '(("^Files: [0-9]+ +Blocks: [0-9]+\n+" nil 40) | |
4411 ; ("^Dirs: [0-9]+\n+" t 30))) | |
4412 ; type-regexp type-is-dir type-col file) | |
4413 ; (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4414 ; (save-match-data |
1106 | 4415 ; (while type-list |
4416 ; (setq type-regexp (car (car type-list)) | |
4417 ; type-is-dir (nth 1 (car type-list)) | |
4418 ; type-col (nth 2 (car type-list)) | |
4419 ; type-list (cdr type-list)) | |
4420 ; (if (re-search-forward type-regexp nil t) | |
4421 ; (while (eq (char-after (point)) ? ) | |
4422 ; (move-to-column type-col) | |
4423 ; (setq file (buffer-substring (point) | |
4424 ; (progn | |
4425 ; (end-of-line 1) | |
4426 ; (point)))) | |
4427 ; (ange-ftp-put-hash-entry file type-is-dir tbl) | |
4428 ; (forward-line 1)))) | |
4429 ; (ange-ftp-put-hash-entry "." 'vosdir tbl) | |
4430 ; (ange-ftp-put-hash-entry ".." 'vosdir tbl)) | |
4431 ; tbl)) | |
4432 ; | |
4433 ;(or (assq 'vos ange-ftp-parse-list-func-alist) | |
4434 ; (setq ange-ftp-parse-list-func-alist | |
4435 ; (cons '(vos . ange-ftp-parse-vos-listing) | |
4436 ; ange-ftp-parse-list-func-alist))) | |
4437 | |
4438 ;;;; ------------------------------------------------------------ | |
4439 ;;;; VMS support. | |
4440 ;;;; ------------------------------------------------------------ | |
4441 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4442 ;; 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
|
4443 ;; to UNIX-ish. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4444 (defun ange-ftp-fix-name-for-vms (name &optional reverse) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4445 (save-match-data |
1106 | 4446 (if reverse |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4447 (if (string-match "^\\([^:]+:\\)?\\(\\[.*\\]\\)?\\([^][]*\\)$" name) |
1106 | 4448 (let (drive dir file) |
4449 (if (match-beginning 1) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4450 (setq drive (substring name |
1106 | 4451 (match-beginning 1) |
4452 (match-end 1)))) | |
4453 (if (match-beginning 2) | |
4454 (setq dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4455 (substring name (match-beginning 2) (match-end 2)))) |
1106 | 4456 (if (match-beginning 3) |
4457 (setq file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4458 (substring name (match-beginning 3) (match-end 3)))) |
1106 | 4459 (and dir |
4460 (setq dir (apply (function concat) | |
4461 (mapcar (function | |
4462 (lambda (char) | |
4463 (if (= char ?.) | |
4464 (vector ?/) | |
4465 (vector char)))) | |
4466 (substring dir 1 -1))))) | |
4467 (concat (and drive | |
4468 (concat "/" drive "/")) | |
4469 dir (and dir "/") | |
4470 file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4471 (error "name %s didn't match" name)) |
1106 | 4472 (let (drive dir file tmp) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4473 (if (string-match "^/[^:]+:/" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4474 (setq drive (substring name 1 |
1106 | 4475 (1- (match-end 0))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4476 name (substring name (match-end 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4477 (setq tmp (file-name-directory name)) |
1106 | 4478 (if tmp |
4479 (setq dir (apply (function concat) | |
4480 (mapcar (function | |
4481 (lambda (char) | |
4482 (if (= char ?/) | |
4483 (vector ?.) | |
4484 (vector char)))) | |
4485 (substring tmp 0 -1))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4486 (setq file (file-name-nondirectory name)) |
1106 | 4487 (concat drive |
4488 (and dir (concat "[" (if drive nil ".") dir "]")) | |
4489 file))))) | |
4490 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4491 ;; (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
|
4492 ;; (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
|
4493 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4494 (or (assq 'vms ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4495 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4496 (cons '(vms . ange-ftp-fix-name-for-vms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4497 ange-ftp-fix-name-func-alist))) |
1106 | 4498 |
4499 (or (memq 'vms ange-ftp-dumb-host-types) | |
4500 (setq ange-ftp-dumb-host-types | |
4501 (cons 'vms ange-ftp-dumb-host-types))) | |
4502 | |
4503 ;; It is important that this function barf for directories for which we know | |
4504 ;; that we cannot possibly get a directory listing, such as "/" and "/DEV:/". | |
4505 ;; This is because it saves an unnecessary FTP error, or possibly the listing | |
4506 ;; might succeed, but give erroneous info. This last case is particularly | |
4507 ;; likely for OS's (like MTS) for which we need to use a wildcard in order | |
4508 ;; to list a directory. | |
4509 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4510 ;; 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
|
4511 (defun ange-ftp-fix-dir-name-for-vms (dir-name) |
1106 | 4512 ;; Should there be entries for .. -> [-] and . -> [] below. Don't |
4513 ;; think so, because expand-filename should have already short-circuited | |
4514 ;; them. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4515 (cond ((string-equal dir-name "/") |
1106 | 4516 (error "Cannot get listing for fictitious \"/\" directory.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4517 ((string-match "^/[-A-Z0-9_$]+:/$" dir-name) |
1106 | 4518 (error "Cannot get listing for device.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4519 ((ange-ftp-fix-name-for-vms dir-name)))) |
1106 | 4520 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4521 (or (assq 'vms ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4522 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4523 (cons '(vms . ange-ftp-fix-dir-name-for-vms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4524 ange-ftp-fix-dir-name-func-alist))) |
1106 | 4525 |
4526 (defvar ange-ftp-vms-host-regexp nil) | |
4527 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4528 ;; Return non-nil if HOST is running VMS. |
1106 | 4529 (defun ange-ftp-vms-host (host) |
4530 (and ange-ftp-vms-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4531 (save-match-data |
1106 | 4532 (string-match ange-ftp-vms-host-regexp host)))) |
4533 | |
4534 ;; Because some VMS ftp servers convert filenames to lower case | |
4535 ;; we allow a-z in the filename regexp. I'm not too happy about this. | |
4536 | |
4537 (defconst ange-ftp-vms-filename-regexp | |
4538 (concat | |
6309
9217f29851c2
Don't use triple-hyphen in a character class.
Karl Heuer <kwzh@gnu.org>
parents:
6192
diff
changeset
|
4539 "\\(\\([_A-Za-z0-9$]?\\|[_A-Za-z0-9$][-_A-Za-z0-9$]*\\)\\." |
9217f29851c2
Don't use triple-hyphen in a character class.
Karl Heuer <kwzh@gnu.org>
parents:
6192
diff
changeset
|
4540 "[-_A-Za-z0-9$]*;+[0-9]*\\)") |
1106 | 4541 "Regular expression to match for a valid VMS file name in Dired buffer. |
4542 Stupid freaking bug! Position of _ and $ shouldn't matter but they do. | |
4543 Having [A-Z0-9$_] bombs on filename _$$CHANGE_LOG$.TXT$ and $CHANGE_LOG$.TX | |
4544 Other orders of $ and _ seem to all work just fine.") | |
4545 | |
4546 ;; These parsing functions are as general as possible because the syntax | |
4547 ;; of ftp listings from VMS hosts is a bit erratic. What saves us is that | |
4548 ;; the VMS filename syntax is so rigid. If they bomb on a listing in the | |
4549 ;; standard VMS Multinet format, then this is a bug. If they bomb on a listing | |
4550 ;; from vms.weird.net, then too bad. | |
4551 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4552 ;; Extract the next filename from a VMS dired-like listing. |
1106 | 4553 (defun ange-ftp-parse-vms-filename () |
4554 (if (re-search-forward | |
4555 ange-ftp-vms-filename-regexp | |
4556 nil t) | |
4557 (buffer-substring (match-beginning 0) (match-end 0)))) | |
4558 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4559 ;; 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
|
4560 ;; format, and return a hashtable as the result. |
1106 | 4561 (defun ange-ftp-parse-vms-listing () |
4562 (let ((tbl (ange-ftp-make-hashtable)) | |
4563 file) | |
4564 (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4565 (save-match-data |
1106 | 4566 (while (setq file (ange-ftp-parse-vms-filename)) |
4567 (if (string-match "\\.\\(DIR\\|dir\\);[0-9]+" file) | |
4568 ;; deal with directories | |
4569 (ange-ftp-put-hash-entry | |
4570 (substring file 0 (match-beginning 0)) t tbl) | |
4571 (ange-ftp-put-hash-entry file nil tbl) | |
4572 (if (string-match ";[0-9]+$" file) ; deal with extension | |
4573 ;; sans extension | |
4574 (ange-ftp-put-hash-entry | |
4575 (substring file 0 (match-beginning 0)) nil tbl))) | |
4576 (forward-line 1)) | |
4577 ;; Would like to look for a "Total" line, or a "Directory" line to | |
4578 ;; make sure that the listing isn't complete garbage before putting | |
4579 ;; in "." and "..", but we can't even count on all VAX's giving us | |
4580 ;; either of these. | |
4581 (ange-ftp-put-hash-entry "." t tbl) | |
4582 (ange-ftp-put-hash-entry ".." t tbl)) | |
4583 tbl)) | |
4584 | |
4585 (or (assq 'vms ange-ftp-parse-list-func-alist) | |
4586 (setq ange-ftp-parse-list-func-alist | |
4587 (cons '(vms . ange-ftp-parse-vms-listing) | |
4588 ange-ftp-parse-list-func-alist))) | |
4589 | |
4590 ;; This version only deletes file entries which have | |
4591 ;; explicit version numbers, because that is all VMS allows. | |
4592 | |
4593 ;; Can the following two functions be speeded up using file | |
4594 ;; completion functions? | |
4595 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4596 (defun ange-ftp-vms-delete-file-entry (name &optional dir-p) |
1106 | 4597 (if dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4598 (ange-ftp-internal-delete-file-entry name t) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4599 (save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4600 (let ((file (ange-ftp-get-file-part name))) |
1106 | 4601 (if (string-match ";[0-9]+$" file) |
4602 ;; In VMS you can't delete a file without an explicit | |
4603 ;; version number, or wild-card (e.g. FOO;*) | |
4604 ;; For now, we give up on wildcards. | |
4605 (let ((files (ange-ftp-get-hash-entry | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4606 (file-name-directory name) |
1106 | 4607 ange-ftp-files-hashtable))) |
4608 (if files | |
4609 (let* ((root (substring file 0 | |
4610 (match-beginning 0))) | |
4611 (regexp (concat "^" | |
4612 (regexp-quote root) | |
4613 ";[0-9]+$")) | |
4614 versions) | |
4615 (ange-ftp-del-hash-entry file files) | |
4616 ;; Now we need to check if there are any | |
4617 ;; versions left. If not, then delete the | |
4618 ;; root entry. | |
4619 (mapatoms | |
4620 '(lambda (sym) | |
4621 (and (string-match regexp (get sym 'key)) | |
4622 (setq versions t))) | |
4623 files) | |
4624 (or versions | |
4625 (ange-ftp-del-hash-entry root files)))))))))) | |
4626 | |
4627 (or (assq 'vms ange-ftp-delete-file-entry-alist) | |
4628 (setq ange-ftp-delete-file-entry-alist | |
4629 (cons '(vms . ange-ftp-vms-delete-file-entry) | |
4630 ange-ftp-delete-file-entry-alist))) | |
4631 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4632 (defun ange-ftp-vms-add-file-entry (name &optional dir-p) |
1106 | 4633 (if dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4634 (ange-ftp-internal-add-file-entry name t) |
1106 | 4635 (let ((files (ange-ftp-get-hash-entry |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4636 (file-name-directory name) |
1106 | 4637 ange-ftp-files-hashtable))) |
4638 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4639 (let ((file (ange-ftp-get-file-part name))) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4640 (save-match-data |
1106 | 4641 (if (string-match ";[0-9]+$" file) |
4642 (ange-ftp-put-hash-entry | |
4643 (substring file 0 (match-beginning 0)) | |
4644 nil files) | |
4645 ;; Need to figure out what version of the file | |
4646 ;; is being added. | |
4647 (let ((regexp (concat "^" | |
4648 (regexp-quote file) | |
4649 ";\\([0-9]+\\)$")) | |
4650 (version 0)) | |
4651 (mapatoms | |
4652 '(lambda (sym) | |
4653 (let ((name (get sym 'key))) | |
4654 (and (string-match regexp name) | |
4655 (setq version | |
4656 (max version | |
4657 (string-to-int | |
4658 (substring name | |
4659 (match-beginning 1) | |
4660 (match-end 1)))))))) | |
4661 files) | |
4662 (setq version (1+ version)) | |
4663 (ange-ftp-put-hash-entry | |
4664 (concat file ";" (int-to-string version)) | |
4665 nil files)))) | |
4666 (ange-ftp-put-hash-entry file nil files)))))) | |
4667 | |
4668 (or (assq 'vms ange-ftp-add-file-entry-alist) | |
4669 (setq ange-ftp-add-file-entry-alist | |
4670 (cons '(vms . ange-ftp-vms-add-file-entry) | |
4671 ange-ftp-add-file-entry-alist))) | |
4672 | |
4673 | |
4674 (defun ange-ftp-add-vms-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4675 "Mark HOST as the name of a machine running VMS." |
1106 | 4676 (interactive |
4677 (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
|
4678 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4679 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 4680 (if (not (ange-ftp-vms-host host)) |
4681 (setq ange-ftp-vms-host-regexp | |
4682 (concat "^" (regexp-quote host) "$" | |
4683 (and ange-ftp-vms-host-regexp "\\|") | |
4684 ange-ftp-vms-host-regexp) | |
4685 ange-ftp-host-cache nil))) | |
4686 | |
4687 | |
4688 (defun ange-ftp-vms-file-name-as-directory (name) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4689 (save-match-data |
1106 | 4690 (if (string-match "\\.\\(DIR\\|dir\\)\\(;[0-9]+\\)?$" name) |
4691 (setq name (substring name 0 (match-beginning 0)))) | |
4692 (ange-ftp-real-file-name-as-directory name))) | |
4693 | |
4694 (or (assq 'vms ange-ftp-file-name-as-directory-alist) | |
4695 (setq ange-ftp-file-name-as-directory-alist | |
4696 (cons '(vms . ange-ftp-vms-file-name-as-directory) | |
4697 ange-ftp-file-name-as-directory-alist))) | |
4698 | |
4699 ;;; Tree dired support: | |
4700 | |
4701 ;; For this code I have borrowed liberally from Sebastian Kremer's | |
4702 ;; dired-vms.el | |
4703 | |
4704 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4705 ;;;; These regexps must be anchored to beginning of line. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4706 ;;;; 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
|
4707 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4708 ;;(defconst ange-ftp-dired-vms-re-exe "^. [^ \t.]+\\.\\(EXE\\|exe\\)[; ]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4709 ;; "Regular expression to use to search for VMS executable files.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4710 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4711 ;;(defconst ange-ftp-dired-vms-re-dir "^. [^ \t.]+\\.\\(DIR\\|dir\\)[; ]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4712 ;; "Regular expression to use to search for VMS directories.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4713 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4714 ;;(or (assq 'vms ange-ftp-dired-re-exe-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4715 ;; (setq ange-ftp-dired-re-exe-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4716 ;; (cons (cons 'vms ange-ftp-dired-vms-re-exe) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4717 ;; ange-ftp-dired-re-exe-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4718 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4719 ;;(or (assq 'vms ange-ftp-dired-re-dir-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4720 ;; (setq ange-ftp-dired-re-dir-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4721 ;; (cons (cons 'vms ange-ftp-dired-vms-re-dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4722 ;; ange-ftp-dired-re-dir-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4723 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4724 ;;(defun ange-ftp-dired-vms-insert-headerline (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4725 ;; ;; VMS inserts a headerline. I would prefer the headerline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4726 ;; ;; to be in ange-ftp format. This version tries to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4727 ;; ;; be careful, because we can't count on a headerline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4728 ;; ;; over ftp, and we wouldn't want to delete anything |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4729 ;; ;; important. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4730 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4731 ;; (if (looking-at "^ wildcard ") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4732 ;; (forward-line 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4733 ;; (if (looking-at "^[ \n\t]*[^\n]+\\][ \t]*\n") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4734 ;; (delete-region (point) (match-end 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4735 ;; (ange-ftp-real-dired-insert-headerline dir)) |
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 ;;(or (assq 'vms ange-ftp-dired-insert-headerline-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4738 ;; (setq ange-ftp-dired-insert-headerline-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4739 ;; (cons '(vms . ange-ftp-dired-vms-insert-headerline) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4740 ;; ange-ftp-dired-insert-headerline-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4741 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4742 ;;(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
|
4743 ;; "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
|
4744 ;;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
|
4745 ;; ;; This is the VMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4746 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4747 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4748 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4749 ;; (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
|
4750 ;; (goto-char (match-beginning 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4751 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4752 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4753 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4754 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4755 ;;(or (assq 'vms ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4756 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4757 ;; (cons '(vms . ange-ftp-dired-vms-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4758 ;; ange-ftp-dired-move-to-filename-alist))) |
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-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4761 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4762 ;; ;; 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
|
4763 ;; ;; case-fold-search must be nil, at least for VMS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4764 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4765 ;; ;; This is the VMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4766 ;; (let (opoint hidden case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4767 ;; (setq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4768 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4769 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4770 ;; (save-excursion (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4771 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4772 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4773 ;; (re-search-forward ange-ftp-vms-filename-regexp eol t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4774 ;; (or no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4775 ;; (not (eq opoint (point))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4776 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4777 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4778 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4779 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4780 ;; "No file on this line"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4781 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4782 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4783 ;; (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4784 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4785 ;;(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
|
4786 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4787 ;; (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
|
4788 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4789 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4790 ;;(defun ange-ftp-dired-vms-between-files () |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4791 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4792 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4793 ;; (or (equal (following-char) 10) ; newline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4794 ;; (equal (following-char) 9) ; tab |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4795 ;; (progn (forward-char 2) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4796 ;; (or (looking-at "Total of") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4797 ;; (equal (following-char) 32)))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4798 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4799 ;;(or (assq 'vms ange-ftp-dired-between-files-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4800 ;; (setq ange-ftp-dired-between-files-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4801 ;; (cons '(vms . ange-ftp-dired-vms-between-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4802 ;; ange-ftp-dired-between-files-alist))) |
1106 | 4803 |
4804 ;; Beware! In VMS filenames must be of the form "FILE.TYPE". | |
4805 ;; Therefore, we cannot just append a ".Z" to filenames for | |
4806 ;; compressed files. Instead, we turn "FILE.TYPE" into | |
4807 ;; "FILE.TYPE-Z". Hope that this is a reasonable thing to do. | |
4808 | |
4809 (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
|
4810 (cond |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4811 ((string-match "-Z;[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4812 (list nil (substring name 0 (match-beginning 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4813 ((string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4814 (list nil (substring name 0 (match-beginning 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4815 ((string-match "-Z$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4816 (list nil (substring name 0 -2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4817 (t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4818 (list t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4819 (if (string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4820 (concat (substring name 0 (match-beginning 0)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4821 "-Z") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4822 (concat name "-Z")))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4823 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4824 (or (assq 'vms ange-ftp-make-compressed-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4825 (setq ange-ftp-make-compressed-filename-alist |
1106 | 4826 (cons '(vms . ange-ftp-vms-make-compressed-filename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4827 ange-ftp-make-compressed-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4828 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4829 ;;;; 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
|
4830 ;;;; (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
|
4831 ;;;; 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
|
4832 ;;;; (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
|
4833 ;;;; If dired gets confused, revert-buffer will fix it. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4834 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4835 ;;(defun ange-ftp-dired-vms-ls-trim () |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4836 ;; (goto-char (point-min)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4837 ;; (let ((case-fold-search nil)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4838 ;; (re-search-forward ange-ftp-vms-filename-regexp)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4839 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4840 ;; (delete-region (point-min) (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4841 ;; (forward-line 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4842 ;; (delete-region (point) (point-max))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4843 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4844 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4845 ;;(or (assq 'vms ange-ftp-dired-ls-trim-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4846 ;; (setq ange-ftp-dired-ls-trim-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4847 ;; (cons '(vms . ange-ftp-dired-vms-ls-trim) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4848 ;; ange-ftp-dired-ls-trim-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4849 |
12977
046bc1e2acc9
(ange-ftp-vms-sans-version): Accept extra args.
Richard M. Stallman <rms@gnu.org>
parents:
12741
diff
changeset
|
4850 (defun ange-ftp-vms-sans-version (name &rest args) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4851 (save-match-data |
1106 | 4852 (if (string-match ";[0-9]+$" name) |
4853 (substring name 0 (match-beginning 0)) | |
4854 name))) | |
4855 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4856 (or (assq 'vms ange-ftp-sans-version-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4857 (setq ange-ftp-sans-version-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4858 (cons '(vms . ange-ftp-vms-sans-version) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4859 ange-ftp-sans-version-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4860 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4861 ;;(defvar ange-ftp-file-version-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4862 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4863 ;;;;; 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
|
4864 ;;;;; 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
|
4865 ;;;;; ange-ftp-dired-vms-flag-backup-files. |
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-clean-directory (keep &optional marker msg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4868 ;; "Flag numerical backups for deletion. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4869 ;;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
|
4870 ;;Positive prefix arg KEEP overrides `dired-kept-versions'; |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4871 ;;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
|
4872 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4873 ;;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
|
4874 ;;with a prefix argument." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4875 ;;; (interactive "P") ; Never actually called interactively. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4876 ;; (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
|
4877 ;; (let ((early-retention (if (< keep 0) (- keep) kept-old-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4878 ;; ;; 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
|
4879 ;; ;; This could wipe ALL copies of the file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4880 ;; (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
|
4881 ;; (action (or msg "Cleaning")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4882 ;; (ange-ftp-trample-marker (or marker dired-del-marker)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4883 ;; (ange-ftp-file-version-alist ())) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4884 ;; (message (concat action |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4885 ;; " numerical backups (keeping %d late, %d old)...") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4886 ;; late-retention early-retention) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4887 ;; ;; Look at each file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4888 ;; ;; If the file has numeric backup versions, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4889 ;; ;; 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
|
4890 ;; ;; (FILENAME . VERSION-NUMBER-LIST) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4891 ;; (dired-map-dired-file-lines (function |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4892 ;; ange-ftp-dired-vms-collect-file-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4893 ;; ;; Sort each VERSION-NUMBER-LIST, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4894 ;; ;; and remove the versions not to be deleted. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4895 ;; (let ((fval ange-ftp-file-version-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4896 ;; (while fval |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4897 ;; (let* ((sorted-v-list (cons 'q (sort (cdr (car fval)) '<))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4898 ;; (v-count (length sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4899 ;; (if (> v-count (+ early-retention late-retention)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4900 ;; (rplacd (nthcdr early-retention sorted-v-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4901 ;; (nthcdr (- v-count late-retention) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4902 ;; sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4903 ;; (rplacd (car fval) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4904 ;; (cdr sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4905 ;; (setq fval (cdr fval)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4906 ;; ;; 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
|
4907 ;; ;; 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
|
4908 ;; (dired-map-dired-file-lines |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4909 ;; (function |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4910 ;; ange-ftp-dired-vms-trample-file-versions mark)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4911 ;; (message (concat action " numerical backups...done")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4912 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4913 ;;(or (assq 'vms ange-ftp-dired-clean-directory-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4914 ;; (setq ange-ftp-dired-clean-directory-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4915 ;; (cons '(vms . ange-ftp-dired-vms-clean-directory) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4916 ;; ange-ftp-dired-clean-directory-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4917 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4918 ;;(defun ange-ftp-dired-vms-collect-file-versions (fn) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4919 ;; ;; "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
|
4920 ;; ;;That is a list of strings which are file names. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4921 ;; ;;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
|
4922 ;;(let ((name (nth 2 (ange-ftp-ftp-name fn)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4923 ;; (if (string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4924 ;; (let* ((name (substring name 0 (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4925 ;; (fn (ange-ftp-replace-name-component fn name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4926 ;; (if (not (assq fn ange-ftp-file-version-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4927 ;; (let* ((base-versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4928 ;; (concat (file-name-nondirectory name) ";")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4929 ;; (bv-length (length base-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4930 ;; (possibilities (file-name-all-completions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4931 ;; base-versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4932 ;; (file-name-directory fn))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4933 ;; (versions (mapcar |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4934 ;; '(lambda (arg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4935 ;; (if (and (string-match |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4936 ;; "[0-9]+$" arg bv-length) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4937 ;; (= (match-beginning 0) bv-length)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4938 ;; (string-to-int (substring arg bv-length)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4939 ;; 0)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4940 ;; possibilities))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4941 ;; (if versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4942 ;; (setq |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4943 ;; ange-ftp-file-version-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4944 ;; (cons (cons fn versions) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4945 ;; ange-ftp-file-version-alist))))))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4946 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4947 ;;(defun ange-ftp-dired-vms-trample-file-versions (fn) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4948 ;; (let* ((start-vn (string-match ";[0-9]+$" fn)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4949 ;; base-version-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4950 ;; (and start-vn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4951 ;; (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
|
4952 ;; (assoc (substring fn 0 start-vn) ; this looks like a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4953 ;; ange-ftp-file-version-alist)) ; subversion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4954 ;; (not (memq (string-to-int (substring fn (1+ start-vn))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4955 ;; base-version-list)) ; this one doesn't make the cut |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4956 ;; (progn (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4957 ;; (delete-char 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4958 ;; (insert ange-ftp-trample-marker))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4959 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4960 ;;(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
|
4961 ;; (let ((dired-kept-versions 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4962 ;; (kept-old-versions 0) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4963 ;; marker msg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4964 ;; (if unflag-p |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4965 ;; (setq marker ?\040 msg "Unflagging") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4966 ;; (setq marker dired-del-marker msg "Cleaning")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4967 ;; (ange-ftp-dired-vms-clean-directory nil marker msg))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4968 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4969 ;;(or (assq 'vms ange-ftp-dired-flag-backup-files-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4970 ;; (setq ange-ftp-dired-flag-backup-files-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4971 ;; (cons '(vms . ange-ftp-dired-vms-flag-backup-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4972 ;; ange-ftp-dired-flag-backup-files-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4973 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4974 ;;(defun ange-ftp-dired-vms-backup-diff (&optional switches) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4975 ;; (let ((file (dired-get-filename 'no-dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4976 ;; bak) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4977 ;; (if (and (string-match ";[0-9]+$" file) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4978 ;; ;; Find most recent previous version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4979 ;; (let ((root (substring file 0 (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4980 ;; (ver |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4981 ;; (string-to-int (substring file (1+ (match-beginning 0))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4982 ;; found) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4983 ;; (setq ver (1- ver)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4984 ;; (while (and (> ver 0) (not found)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4985 ;; (setq bak (concat root ";" (int-to-string ver))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4986 ;; (and (file-exists-p bak) (setq found t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4987 ;; (setq ver (1- ver))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4988 ;; found)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4989 ;; (if switches |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4990 ;; (diff (expand-file-name bak) (expand-file-name file) switches) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4991 ;; (diff (expand-file-name bak) (expand-file-name file))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4992 ;; (error "No previous version found for %s" file)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4993 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4994 ;;(or (assq 'vms ange-ftp-dired-backup-diff-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4995 ;; (setq ange-ftp-dired-backup-diff-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4996 ;; (cons '(vms . ange-ftp-dired-vms-backup-diff) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4997 ;; ange-ftp-dired-backup-diff-alist))) |
1106 | 4998 |
4999 | |
5000 ;;;; ------------------------------------------------------------ | |
5001 ;;;; MTS support | |
5002 ;;;; ------------------------------------------------------------ | |
5003 | |
5004 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5005 ;; 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
|
5006 ;; MTS to UNIX-ish. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5007 (defun ange-ftp-fix-name-for-mts (name &optional reverse) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5008 (save-match-data |
1106 | 5009 (if reverse |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5010 (if (string-match "^\\([^:]+:\\)?\\(.*\\)$" name) |
1106 | 5011 (let (acct file) |
5012 (if (match-beginning 1) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5013 (setq acct (substring name 0 (match-end 1)))) |
1106 | 5014 (if (match-beginning 2) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5015 (setq file (substring name |
1106 | 5016 (match-beginning 2) (match-end 2)))) |
5017 (concat (and acct (concat "/" acct "/")) | |
5018 file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5019 (error "name %s didn't match" name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5020 (if (string-match "^/\\([^:]+:\\)/\\(.*\\)$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5021 (concat (substring name 1 (match-end 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5022 (substring name (match-beginning 2) (match-end 2))) |
1106 | 5023 ;; Let's hope that mts will recognize it anyway. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5024 name)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5025 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5026 (or (assq 'mts ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5027 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5028 (cons '(mts . ange-ftp-fix-name-for-mts) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5029 ange-ftp-fix-name-func-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5030 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5031 ;; 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
|
5032 ;; Remember that there are no directories in MTS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5033 (defun ange-ftp-fix-dir-name-for-mts (dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5034 (if (string-equal dir-name "/") |
1106 | 5035 (error "Cannot get listing for fictitious \"/\" directory.") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5036 (let ((dir-name (ange-ftp-fix-name-for-mts dir-name))) |
1106 | 5037 (cond |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5038 ((string-equal dir-name "") |
1106 | 5039 "?") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5040 ((string-match ":$" dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5041 (concat dir-name "?")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5042 (dir-name))))) ; It's just a single file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5043 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5044 (or (assq 'mts ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5045 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5046 (cons '(mts . ange-ftp-fix-dir-name-for-mts) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5047 ange-ftp-fix-dir-name-func-alist))) |
1106 | 5048 |
5049 (or (memq 'mts ange-ftp-dumb-host-types) | |
5050 (setq ange-ftp-dumb-host-types | |
5051 (cons 'mts ange-ftp-dumb-host-types))) | |
5052 | |
5053 (defvar ange-ftp-mts-host-regexp nil) | |
5054 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5055 ;; Return non-nil if HOST is running MTS. |
1106 | 5056 (defun ange-ftp-mts-host (host) |
5057 (and ange-ftp-mts-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5058 (save-match-data |
1106 | 5059 (string-match ange-ftp-mts-host-regexp host)))) |
5060 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5061 ;; Parse the current buffer which is assumed to be in mts ftp dir format. |
1106 | 5062 (defun ange-ftp-parse-mts-listing () |
5063 (let ((tbl (ange-ftp-make-hashtable))) | |
5064 (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5065 (save-match-data |
1106 | 5066 (while (re-search-forward ange-ftp-date-regexp nil t) |
5067 (end-of-line) | |
5068 (skip-chars-backward " ") | |
5069 (let ((end (point))) | |
5070 (skip-chars-backward "-A-Z0-9_.!") | |
5071 (ange-ftp-put-hash-entry (buffer-substring (point) end) nil tbl)) | |
5072 (forward-line 1))) | |
5073 ;; Don't need to bother with .. | |
5074 (ange-ftp-put-hash-entry "." t tbl) | |
5075 tbl)) | |
5076 | |
5077 (or (assq 'mts ange-ftp-parse-list-func-alist) | |
5078 (setq ange-ftp-parse-list-func-alist | |
5079 (cons '(mts . ange-ftp-parse-mts-listing) | |
5080 ange-ftp-parse-list-func-alist))) | |
5081 | |
5082 (defun ange-ftp-add-mts-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5083 "Mark HOST as the name of a machine running MTS." |
1106 | 5084 (interactive |
5085 (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
|
5086 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5087 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 5088 (if (not (ange-ftp-mts-host host)) |
5089 (setq ange-ftp-mts-host-regexp | |
5090 (concat "^" (regexp-quote host) "$" | |
5091 (and ange-ftp-mts-host-regexp "\\|") | |
5092 ange-ftp-mts-host-regexp) | |
5093 ange-ftp-host-cache nil))) | |
5094 | |
5095 ;;; Tree dired support: | |
5096 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5097 ;;;; 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
|
5098 ;;;; 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
|
5099 ;;;; 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
|
5100 ;;;; following more flexible. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5101 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5102 ;;(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
|
5103 ;; "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
|
5104 ;;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
|
5105 ;; ;; This is the MTS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5106 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5107 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5108 ;; (if (re-search-forward |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5109 ;; ange-ftp-date-regexp eol t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5110 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5111 ;; (skip-chars-forward " ") ; Eat blanks after date |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5112 ;; (skip-chars-forward "0-9:" eol) ; Eat time or year |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5113 ;; (skip-chars-forward " " eol) ; one space before filename |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5114 ;; ;; 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
|
5115 ;; ;; ACCT: to the beginning of the filename. Skip over this. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5116 ;; (and (looking-at "[A-Z0-9_.]+:") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5117 ;; (goto-char (match-end 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5118 ;; (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5119 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5120 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5121 ;; nil))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5122 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5123 ;;(or (assq 'mts ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5124 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5125 ;; (cons '(mts . ange-ftp-dired-mts-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5126 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5127 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5128 ;;(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
|
5129 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5130 ;; ;; 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
|
5131 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5132 ;; ;; This is the MTS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5133 ;; (let (opoint hidden case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5134 ;; (setq opoint (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5135 ;; eol (save-excursion (end-of-line) (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5136 ;; hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5137 ;; (save-excursion (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5138 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5139 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5140 ;; (skip-chars-forward "-A-Z0-9._!" eol)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5141 ;; (or no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5142 ;; (not (eq opoint (point))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5143 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5144 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5145 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5146 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5147 ;; "No file on this line"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5148 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5149 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5150 ;; (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5151 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5152 ;;(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
|
5153 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5154 ;; (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
|
5155 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 5156 |
5157 ;;;; ------------------------------------------------------------ | |
5158 ;;;; CMS support | |
5159 ;;;; ------------------------------------------------------------ | |
5160 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5161 ;; Since CMS doesn't have any full file name syntax, we have to fudge |
4498
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
5162 ;; things with cd's. We actually send too many cd's, but it's dangerous |
1106 | 5163 ;; to try to remember the current minidisk, because if the connection |
5164 ;; is closed and needs to be reopened, we will find ourselves back in | |
5165 ;; the default minidisk. This is fairly likely since CMS ftp servers | |
5166 ;; usually close the connection after 5 minutes of inactivity. | |
5167 | |
5168 ;; Have I got the filename character set right? | |
5169 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5170 (defun ange-ftp-fix-name-for-cms (name &optional reverse) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5171 (save-match-data |
1106 | 5172 (if reverse |
5173 ;; Since we only convert output from a pwd in this direction, | |
5174 ;; we'll assume that it's a minidisk, and make it into a | |
5175 ;; directory file name. Note that the expand-dir-hashtable | |
5176 ;; stores directories without the trailing /. Is this | |
5177 ;; consistent? | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5178 (concat "/" name) |
1106 | 5179 (if (string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5180 name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5181 (let ((minidisk (substring name 1 (match-end 1)))) |
1106 | 5182 (if (match-beginning 2) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5183 (let ((file (substring name (match-beginning 2) |
1106 | 5184 (match-end 2))) |
5185 (cmd (concat "cd " minidisk)) | |
5186 | |
5187 ;; Note that host and user are bound in the call | |
5188 ;; to ange-ftp-send-cmd | |
5189 (proc (ange-ftp-get-process ange-ftp-this-host | |
5190 ange-ftp-this-user))) | |
5191 | |
5192 ;; Must use ange-ftp-raw-send-cmd here to avoid | |
5193 ;; an infinite loop. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5194 (if (car (ange-ftp-raw-send-cmd proc cmd ange-ftp-this-msg)) |
1106 | 5195 file |
5196 ;; failed... try ONCE more. | |
5197 (setq proc (ange-ftp-get-process ange-ftp-this-host | |
5198 ange-ftp-this-user)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5199 (let ((result (ange-ftp-raw-send-cmd proc cmd |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5200 ange-ftp-this-msg))) |
1106 | 5201 (if (car result) |
5202 file | |
5203 ;; failed. give up. | |
5204 (ange-ftp-error ange-ftp-this-host ange-ftp-this-user | |
5205 (format "cd to minidisk %s failed: %s" | |
5206 minidisk (cdr result))))))) | |
5207 ;; return the minidisk | |
5208 minidisk)) | |
5209 (error "Invalid CMS filename"))))) | |
5210 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5211 (or (assq 'cms ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5212 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5213 (cons '(cms . ange-ftp-fix-name-for-cms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5214 ange-ftp-fix-name-func-alist))) |
1106 | 5215 |
5216 (or (memq 'cms ange-ftp-dumb-host-types) | |
5217 (setq ange-ftp-dumb-host-types | |
5218 (cons 'cms ange-ftp-dumb-host-types))) | |
5219 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5220 ;; 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
|
5221 (defun ange-ftp-fix-dir-name-for-cms (dir-name) |
1106 | 5222 (cond |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5223 ((string-equal "/" dir-name) |
1106 | 5224 (error "Cannot get listing for fictitious \"/\" directory.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5225 ((string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5226 (let* ((minidisk (substring dir-name (match-beginning 1) (match-end 1))) |
1106 | 5227 ;; 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
|
5228 (proc (ange-ftp-get-process ange-ftp-this-host ange-ftp-this-user)) |
1106 | 5229 (cmd (concat "cd " minidisk)) |
5230 (file (if (match-beginning 2) | |
5231 ;; it's a single file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5232 (substring dir-name (match-beginning 2) |
1106 | 5233 (match-end 2)) |
5234 ;; use the wild-card | |
5235 "*"))) | |
5236 (if (car (ange-ftp-raw-send-cmd proc cmd)) | |
5237 file | |
5238 ;; try again... | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5239 (setq proc (ange-ftp-get-process ange-ftp-this-host |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5240 ange-ftp-this-user)) |
1106 | 5241 (let ((result (ange-ftp-raw-send-cmd proc cmd))) |
5242 (if (car result) | |
5243 file | |
5244 ;; give up | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5245 (ange-ftp-error ange-ftp-this-host ange-ftp-this-user |
1106 | 5246 (format "cd to minidisk %s failed: " |
5247 minidisk (cdr result)))))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5248 (t (error "Invalid CMS file name")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5249 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5250 (or (assq 'cms ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5251 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5252 (cons '(cms . ange-ftp-fix-dir-name-for-cms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5253 ange-ftp-fix-dir-name-func-alist))) |
1106 | 5254 |
5255 (defvar ange-ftp-cms-host-regexp nil | |
5256 "Regular expression to match hosts running the CMS operating system.") | |
5257 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5258 ;; Return non-nil if HOST is running CMS. |
1106 | 5259 (defun ange-ftp-cms-host (host) |
5260 (and ange-ftp-cms-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5261 (save-match-data |
1106 | 5262 (string-match ange-ftp-cms-host-regexp host)))) |
5263 | |
5264 (defun ange-ftp-add-cms-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5265 "Mark HOST as the name of a CMS host." |
1106 | 5266 (interactive |
5267 (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
|
5268 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5269 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 5270 (if (not (ange-ftp-cms-host host)) |
5271 (setq ange-ftp-cms-host-regexp | |
5272 (concat "^" (regexp-quote host) "$" | |
5273 (and ange-ftp-cms-host-regexp "\\|") | |
5274 ange-ftp-cms-host-regexp) | |
5275 ange-ftp-host-cache nil))) | |
5276 | |
5277 (defun ange-ftp-parse-cms-listing () | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5278 ;; Parse the current buffer which is assumed to be a CMS directory listing. |
1106 | 5279 ;; If we succeed in getting a listing, then we will assume that the minidisk |
5280 ;; exists. file is bound by the call to ange-ftp-ls. This doesn't work | |
5281 ;; because ange-ftp doesn't know that the root hashtable has only part of | |
5282 ;; the info. It will assume that if a minidisk isn't in it, then it doesn't | |
5283 ;; exist. It would be nice if completion worked for minidisks, as we | |
5284 ;; discover them. | |
5285 ; (let* ((dir-file (directory-file-name file)) | |
5286 ; (root (file-name-directory dir-file)) | |
5287 ; (minidisk (ange-ftp-get-file-part dir-file)) | |
5288 ; (root-tbl (ange-ftp-get-hash-entry root ange-ftp-files-hashtable))) | |
5289 ; (if root-tbl | |
5290 ; (ange-ftp-put-hash-entry minidisk t root-tbl) | |
5291 ; (setq root-tbl (ange-ftp-make-hashtable)) | |
5292 ; (ange-ftp-put-hash-entry minidisk t root-tbl) | |
5293 ; (ange-ftp-put-hash-entry "." t root-tbl) | |
5294 ; (ange-ftp-set-files root root-tbl))) | |
5295 ;; Now do the usual parsing | |
5296 (let ((tbl (ange-ftp-make-hashtable))) | |
5297 (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5298 (save-match-data |
1106 | 5299 (while |
5300 (re-search-forward | |
5301 "^\\([-A-Z0-9$_]+\\) +\\([-A-Z0-9$_]+\\) +[VF] +[0-9]+ " nil t) | |
5302 (ange-ftp-put-hash-entry | |
5303 (concat (buffer-substring (match-beginning 1) | |
5304 (match-end 1)) | |
5305 "." | |
5306 (buffer-substring (match-beginning 2) | |
5307 (match-end 2))) | |
5308 nil tbl) | |
5309 (forward-line 1)) | |
5310 (ange-ftp-put-hash-entry "." t tbl)) | |
5311 tbl)) | |
5312 | |
5313 (or (assq 'cms ange-ftp-parse-list-func-alist) | |
5314 (setq ange-ftp-parse-list-func-alist | |
5315 (cons '(cms . ange-ftp-parse-cms-listing) | |
5316 ange-ftp-parse-list-func-alist))) | |
5317 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5318 ;;;;; Tree dired support: |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5319 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5320 ;;(defconst ange-ftp-dired-cms-re-exe |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5321 ;; "^. [-A-Z0-9$_]+ +EXEC " |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5322 ;; "Regular expression to use to search for CMS executables.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5323 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5324 ;;(or (assq 'cms ange-ftp-dired-re-exe-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5325 ;; (setq ange-ftp-dired-re-exe-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5326 ;; (cons (cons 'cms ange-ftp-dired-cms-re-exe) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5327 ;; ange-ftp-dired-re-exe-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5328 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5329 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5330 ;;(defun ange-ftp-dired-cms-insert-headerline (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5331 ;; ;; 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
|
5332 ;; ;; aesthetics. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5333 ;; (insert "\n") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5334 ;; (forward-char -1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5335 ;; (ange-ftp-real-dired-insert-headerline dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5336 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5337 ;;(or (assq 'cms ange-ftp-dired-insert-headerline-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5338 ;; (setq ange-ftp-dired-insert-headerline-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5339 ;; (cons '(cms . ange-ftp-dired-cms-insert-headerline) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5340 ;; ange-ftp-dired-insert-headerline-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5341 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5342 ;;(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
|
5343 ;; "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
|
5344 ;; ;; This is the CMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5345 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5346 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5347 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5348 ;; (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
|
5349 ;; (goto-char (1+ (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5350 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5351 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5352 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5353 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5354 ;;(or (assq 'cms ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5355 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5356 ;; (cons '(cms . ange-ftp-dired-cms-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5357 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5358 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5359 ;;(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
|
5360 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5361 ;; ;; 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
|
5362 ;; ;; case-fold-search must be nil, at least for VMS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5363 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5364 ;; ;; This is the CMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5365 ;; (let ((opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5366 ;; case-fold-search hidden) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5367 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5368 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5369 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5370 ;; (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5371 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5372 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5373 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5374 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5375 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5376 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5377 ;; (skip-chars-forward "-A-Z0-9$_" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5378 ;; (skip-chars-forward " " eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5379 ;; (skip-chars-forward "-A-Z0-9$_" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5380 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5381 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5382 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5383 ;; (error "No file on this line")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5384 ;; (point))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5385 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5386 ;;(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
|
5387 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5388 ;; (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
|
5389 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 5390 |
5391 (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
|
5392 (if (string-match "-Z$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5393 (list nil (substring name 0 -2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5394 (list t (concat name "-Z")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5395 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5396 (or (assq 'cms ange-ftp-make-compressed-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5397 (setq ange-ftp-make-compressed-filename-alist |
1106 | 5398 (cons '(cms . ange-ftp-cms-make-compressed-filename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5399 ange-ftp-make-compressed-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5400 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5401 ;;(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
|
5402 ;; (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
|
5403 ;; (and name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5404 ;; (if (string-match "^\\([^ ]+\\) +\\([^ ]+\\)$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5405 ;; (concat (substring name 0 (match-end 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5406 ;; "." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5407 ;; (substring name (match-beginning 2) (match-end 2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5408 ;; name)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5409 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5410 ;;(or (assq 'cms ange-ftp-dired-get-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5411 ;; (setq ange-ftp-dired-get-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5412 ;; (cons '(cms . ange-ftp-dired-cms-get-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5413 ;; ange-ftp-dired-get-filename-alist))) |
1106 | 5414 |
5415 ;;;; ------------------------------------------------------------ | |
5416 ;;;; Finally provide package. | |
5417 ;;;; ------------------------------------------------------------ | |
5418 | |
5419 (provide 'ange-ftp) | |
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
5420 |
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
5421 ;;; ange-ftp.el ends here |